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:
Load simulation data.
Create an animation object.
Create a figure window.
Create a flight control panel to contain the flight instrument components.
Create the flight instrument components.
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.
Load simulation data. For example, the
simdatavariable contains logged simulated flight trajectory data.load simdataTo visualize animation data, create an animation object. For example:
Create an
Aero.Animationobject.h = Aero.Animation;
Create a body using the
pa24-250_orange.acAC3D file and its associated patches.h.createBody('pa24-250_orange.ac','Ac3d');
Set up the bodies of the animation object
h. Set theTimeSeriesSourceproperty to the loadedsimdata.h.Bodies{1}.TimeSeriesSource = simdata;Set up the camera and figure positions.
h.Camera.PositionFcn = @staticCameraPosition; h.Figure.Position(1) = h.Figure.Position(1) + 572/2;
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.
Create a
uifigurefigure window. This example createsfig, to contain the flight instrument forh.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');
Create a flight instrument panel image for the flight instruments and save it as a graphic file, such as a PNG file.
Read the flight instrument panel image into MATLAB® and create and load it into UI axes in App Designer using the
uiaxesfunction. To display the flight instrument panel image in the current axes, use theimagefunction. 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);
Create a flight instruments component. For example, create an artificial horizon component. Specify the parent object as the
uifigureand the position and size of the artificial horizon.hor = uiaerohorizon('Parent',fig,'Position',[212 299 144 144]);
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
uisliderfunction to create a slider component.sl = uislider('Parent',fig,'Limits',[simdata(1,1),... simdata(end,1)],'FontColor','white'); sl.Position = [50 60 450 3];
The slider component has a
ValueChangingFcncallback, which executes when you move the slider thumb. To update the flight instruments and animation figure, assign theValueChangingFcncallback to a helper function. This example uses theflightInstrumentsAnimationCallbackhelper function, which is available only if you click Open Live Script for theDisplay Flight Trajectory Data Using Flight Instruments and Flight Animationexample.sl.ValueChangingFcn = @(sl,event) flightInstrumentsAnimationCallback(fig,simdata,h,event);
To display the time selected in the slider, use the
uilabelfunction 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
uiaeroairspeed|uiaeroaltimeter|uiaeroclimb|uiaeroegt|uiaeroheading|uiaerohorizon|uiaerorpm|uiaeroturn|uifigure|uiaxes|uislider|uilabel|imread
Properties
- AirspeedIndicator Properties | Altimeter Properties | ArtificialHorizon Properties | ClimbIndicator Properties | EGTIndicator Properties | HeadingIndicator Properties | RPMIndicator Properties | TurnCoordinator Properties