Main Content

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
yaw = simdata(:,7);
yaw(yaw<0) = yaw(yaw<0)+2*pi;
simdata(:,7) = yaw;

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.Bodies{1}.TimeSeriesSource = simdata;
h.Camera.PositionFcn = @staticCameraPosition;
h.Figure.Position(1) = h.Figure.Position(1) + 572/2;

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

To prevent the live script from adding a new image for each ui element added, set the visibility property to "off".

fig.Visible = "off";

Load panel image into an axis:

imgPanel = imread('FlightInstrumentPanel.png');
ax = uiaxes('Parent',fig,'Visible','off','Position',[10 30 530 460],...
    'BackgroundColor',[0.2667 0.2706 0.2784]);

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 = [25 250];
air.ScaleColorLimits = [0,60; 50,200; 200,225; 225,250];

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 = 8000;

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 flightInstrumentsAnimationCallback 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) flightInstrumentsAnimationCallback(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];

To display the figure, set the Visibility property to "on".

fig.Visible = "on";

Figure Flight Instruments contains an axes object and other objects of type uiaeroaltimeter, uiaeroheading, uiaeroairspeed, uiaerohorizon, uiaeroclimb, uiaeroturn, uislider, uilabel. The axes object contains an object of type image.