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.
To load and visualize data, consider this workflow:
Load simulation data. For example, the simdata
variable contains
logged simulated flight trajectory data.
load simdata
To visualize animation data, create an animation object. For example:
Create an Aero.Animation
object.
h = Aero.Animation;
Create a body using the pa24-250_orange.ac
AC3D file and its
associated patches.
h.createBody('pa24-250_orange.ac','Ac3d');
Set up the bodies of the animation object h
. Set the
TimeSeriesSource
property to the loaded
simdata
.
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
This workflow assumes that you have loaded data and created an animation object as described in Load and Visualize Data.
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');
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
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);
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]);
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];
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 astHelperFlightInstrumentsAnimation
helper
function.
sl.ValueChangingFcn = @(sl,event) astHelperFlightInstrumentsAnimation(sl,fig,simdata,h);
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.
imread
| uiaeroairspeed
| uiaeroaltimeter
| uiaeroclimb
| uiaeroegt
| uiaeroheading
| uiaerohorizon
| uiaerorpm
| uiaeroturn
| uiaxes
| uifigure
| uilabel
| uislider