% Runway simulator plotter

% Script retrieves the output file produced by the Simulink aircraft
% takeoff roll model simuator demonstrated in class.
% Script plots important state variables including:

% Plot 1 - Distance versus speed diagram
% Plot 2 - Distance versus time (called time-space diagram)
% Plot 3 - Composite plot of speed and distance versus time


% Simulink model produces an output file named "out". Out is a structured
% array with multiple "children"

% out = 
% 
%   Simulink.SimulationOutput:
% 
%       Airport_Altitude: [1x1 timeseries] 
%      Distance_meters: [1x1 timeseries] 
%      RotationSpeed_knots: [1x1 timeseries] 
%      Speed_difference: [1x1 timeseries] 
%      Speed_knots: [1x1 timeseries] 
%      logsout: [1x1 Simulink.SimulationData.Dataset] 
%      tout: [65x1 double] 

% Convert airport altitude to a string

airportAlttitudeString = num2str(out.Airport_Altitude.Data);

% Plot the distance versus speed profile

figure
plot(out.Distance_meters.Data,out.Speed_knots.Data,'-or')
xlabel('Distance Traveled (meters)','fontsize',24)
ylabel('Speed (knots)','fontsize',24)
title(['Airport Altitude  ',airportAlttitudeString, '  meters'],'fontsize',20)
grid

% Plot the distance traveled versus time

figure
plot(out.tout,out.Distance_meters.Data,'-ob')
xlabel('Time (seconds)','fontsize',24)
ylabel('Distance Traveled (meters)','fontsize',24)
title(['Airport Altitude  ',airportAlttitudeString, '  meters'],'fontsize',20)
grid

% Make a compositve plot of speed, distance and time

figure
subplot(2,1,1)
plot(out.tout,out.Distance_meters.Data,'-ob')
xlabel('Time (seconds)','fontsize',24)
ylabel('Distance Traveled (meters)','fontsize',24)
title(['Airport Altitude  ',airportAlttitudeString, '  meters'],'fontsize',20)
grid

subplot(2,1,2)
plot(out.tout,out.Speed_knots.Data,'-or')
xlabel('Time (seconds)','fontsize',24)
ylabel('Speed (knots)','fontsize',24)
title(['Airport Altitude  ',airportAlttitudeString, '  meters'],'fontsize',20)
grid

