This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Display Flight Trajectory Data Using Flight Instruments and Flight Animation

This example shows how to visualize flight trajectories in a UI figure window using flight instrument components. In this example, you will create and configure standard flight instruments in conjunction with the Aero.Animation object.

Load Recorded Data for Flight Trajectories and Instrument Display

Load logged aircraft position, attitude, and time to the workspace.

load simdata

Create Animation Interface

To display the flight trajectories stored in the flight trajectory data, create an Aero.Animation object. The aircraft used in this example is the Piper PA24-250 Comanche.

h = Aero.Animation;
h.createBody('pa24-250_orange.ac','Ac3d');
h.Bodies{1}.TimeSeriesSource = simdata;
h.Camera.PositionFcn = @staticCameraPosition;
h.Figure.Position(1) = h.Figure.Position(1) + 572/2;
h.show();

Create Flight Instruments

Create a UI figure window to contain the flight instruments.

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');

Load panel image into an axis:

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);
disableDefaultInteractivity(ax);

Create standard flight instruments for navigation:

Create altimeter:

alt = uiaeroaltimeter('Parent',fig,'Position',[369 299 144 144]);

Create heading indicator:

head = uiaeroheading('Parent',fig,'Position',[212 104 144 144]);

Create airspeed indicator:

air = uiaeroairspeed('Parent',fig,'Position',[56 299 144 144]);

Change the airspeed indicator limits according to the Piper PA 24-250 Comanche capabilities:

air.Limits = [20 200];
air.ScaleColorLimits = [0 50;40 160;160 190;190 200];

Create artificial horizon:

hor = uiaerohorizon('Parent',fig,'Position',[212 299 144 144]);

Create climb rate indicator:

climb = uiaeroclimb('Parent',fig,'Position',[369 104 144 144]);

Change the climb indicator maximum climb rate according to the aircraft capabilities:

climb.MaximumRate = 4000;

Create turn coordinator:

turn = uiaeroturn('Parent',fig,'Position',[56 104 144 144]);

To update the flight instruments and animation figure, assign the ValueChangingFcn callback to the astHelperFlightInstrumentsAnimation helper function. Then, when a time is selected on the slider, the flight instruments and animation figure will be updated according to the selected time value.

sl = uislider('Parent',fig,'Limits',[simdata(1,1) simdata(end,1)],'FontColor','white');
sl.Position = [50 60 450 3];
sl.ValueChangingFcn = @(sl,event) astHelperFlightInstrumentsAnimation(fig,simdata,h,event);

To display the time selected in the slider, create a label component.

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