Main Content

Create and Configure Flight Instrument Component and an Animation Object

You can display flight data using any of the standard flight instrument components:

  • Airspeed indicator

  • Altimeter

  • Climb indicator

  • Exhaust gas temperature (EGT) indicator

  • Heading indicator

  • Artificial horizon

  • Revolutions per minute (RPM) indicator

  • Turn coordinator

As a general workflow:

  1. Load simulation data.

  2. Create an animation object.

  3. Create a figure window.

  4. Create a flight control panel to contain the flight instrument components.

  5. Create the flight instrument components.

  6. Trigger a display of the animation in the instrument panel.

Note

Use Aerospace Toolbox flight instruments only with figures created using the uifigure function. Apps created using GUIDE or the figure function do not support flight instrument components.

Load and Visualize Data

To load and visualize data, consider this workflow. It relies on the Display Flight Trajectory Data Using Flight Instruments and Flight Animation example.

  1. Load simulation data. For example, the simdata variable contains logged simulated flight trajectory data.

    load simdata
  2. To visualize animation data, create an animation object. For example:

    1. Create an Aero.Animation object.

      h = Aero.Animation;
    2. Create a body using the pa24-250_orange.ac AC3D file and its associated patches.

      h.createBody('pa24-250_orange.ac','Ac3d');
    3. Set up the bodies of the animation object h. Set the TimeSeriesSource property to the loaded simdata.

      h.Bodies{1}.TimeSeriesSource = simdata;
    4. Set up the camera and figure positions.

      h.Camera.PositionFcn = @staticCameraPosition;
      h.Figure.Position(1) = h.Figure.Position(1) + 572/2;
      
    5. Create and show the figure graphics object for h.

      h.updateBodies(simdata(1,1));
      h.updateCamera(simdata(1,1));
      h.show();

To create the flight instrument components, see Create Flight Instrument Components.

Create Flight Instrument Components

This workflow assumes that you have loaded data and created an animation object as described in Load and Visualize Data.

  1. Create a uifigure figure window. This example creates fig, to contain the flight instrument for h.

    fig = uifigure('Name','Flight Instruments',...
    'Position',[h.Figure.Position(1)-572 h.Figure.Position(2)+h.Figure.Position(4)-502 572 502],...
    'Color',[0.2667 0.2706 0.2784],'Resize','off');
  2. Create a flight instrument panel image for the flight instruments and save it as a graphic file, such as a PNG file.

  3. Read the flight instrument panel image into MATLAB® and create and load it into UI axes in App Designer using the uiaxes function. To display the flight instrument panel image in the current axes, use the image function. For example:

    imgPanel = imread('astFlightInstrumentPanel.png');
    ax = uiaxes('Parent',fig,'Visible','off','Position',[10 30 530 460],...
    'BackgroundColor',[0.2667 0.2706 0.2784]);
    image(ax,imgPanel);
  4. Create a flight instruments component. For example, create an artificial horizon component. Specify the parent object as the uifigure and the position and size of the artificial horizon.

    hor = uiaerohorizon('Parent',fig,'Position',[212 299 144 144]);
  5. To trigger a display of the animation in the instrument panel, you must input a time step. For example, connect a time input device such as a slider or knob that can change the time. As you change the time on the time input device, the flight instrument component updates to show the result. This example uses the uislider function to create a slider component.

    sl = uislider('Parent',fig,'Limits',[simdata(1,1),...
    simdata(end,1)],'FontColor','white');
    sl.Position = [50 60 450 3];
    
  6. The slider component has a ValueChangingFcn callback, which executes when you move the slider thumb. To update the flight instruments and animation figure, assign the ValueChangingFcn callback to a helper function. This example uses the flightInstrumentsAnimationCallback helper function, which is available only if you click Open Live Script for the Display Flight Trajectory Data Using Flight Instruments and Flight Animation example.

    sl.ValueChangingFcn = @(sl,event) flightInstrumentsAnimationCallback(fig,simdata,h,event);
  7. To display the time selected in the slider, use the uilabel function to create a label component. This code creates the label text in white and places the label at position [230 10 90 30].

    lbl = uilabel('Parent',fig,'Text',['Time: ' num2str(sl.Value,4) ' sec'],'FontColor','white');
    lbl.Position = [230 10 90 30];

For a complete example, see Display Flight Trajectory Data Using Flight Instruments and Flight Animation.

See Also

Functions

Properties

Related Topics