image thumbnail

International Flight Route Planning Simulator using Aerospace Blockset

by

 

Example that shows how you can visualize airline routes on the globe.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

run_me_now.m
%Analysis in MATLAB

% Clean before you animate
clear all;
bdclose all;

% N cities
N=9;

% Initializing N cities
latitude=zeros(N,1);
longitude=zeros(N,1);

% City 1: Natick
latitude(1,1)=42; % 42E degrees
longitude(1,1)=-71; % 71W degres

% City 2: Auckland, New Zealand
% 19  26 N  99  7 W 
latitude(2,1)=-36; %36S degrees 
longitude(2,1)=174; %174E degrees

% City 3: Beijing China  39  55 N  116  25 E  
latitude(3,1)=39+55/60; %39N degrees
longitude(3,1)=116+25/60; %116E degrees

% City 4: Singapore, Singapore 1  14 N  103  55E 
latitude(4,1)=1+14/60;
longitude(4,1)=103+55/60;

% City 5: New Delhi
latitude(5,1)=28.53; %2N.53N degrees
longitude(5,1)=77.2; %77.2E degrees

% City 6: Teheran Iran 35  45 N  51  45 E 
latitude(6,1)=35+45/60;
longitude(6,1)=51+45/60;

% City 7: Rome, Italy 41  54 N  12  27 E 
latitude(7,1)=41+54/60;
longitude(7,1)=12+27/60;

% City 8: London 51 32 N 0 5 W
latitude(8,1)=51+32/60; 
longitude(8,1)=-5;

% City 9: Mexico 19 26 N 99 7 W
latitude(9,1)=19+26/60;  
longitude(9,1)=-99-7/60; 

% Scaling calculations

% If the aircraft moves along the great circle fully, then use 20,000
% points to sample that interval. If not, scale it. 
t_scaled=2*10000/360;

% These two variables will help in creating the complete list of latitudes
% and longitudes for all the N cities
t_index=1;
t_span=1;

% Assess the size of the final array that you need to initialize that will
% store all the latitudes and longitudes for the animation. This will
% eventually be fed as a vector into the Simulink model. The Simulink model
% has the appropriate transformations to transform this data for animation.
for i=1:N
     k=mod(i,N)+1;
     t_span=round(t_scaled*distance(latitude(i,1),longitude(i,1),latitude(k,1),longitude(k,1)));
     t_index=t_index+t_span-1;
end
LL=zeros(t_index, 2);
% Reinitializing t_index because we want to use it again 
t_index=1;

% Compute the trajectory based on two points along great circle-Mapping
% Toolbox function track2,
for i=1:N
    k=mod(i,N)+1;
    t_span=round(t_scaled*distance(latitude(i,1),longitude(i,1),latitude(k,1),longitude(k,1)));
    LL(t_index:t_index+t_span-1, :) = track2('gc',latitude(i,1),longitude(i,1),latitude(k,1),longitude(k,1), [],[], t_span);    
    t_index=t_index+t_span-1;
end

% Create the input structure to feed into the Simulink model
Input.time=1:1:t_index;
Input.signals.dimensions=2;
Input.signals.values=[LL(1:t_index,1), LL(1:t_index,2)];
mdlname='fly_747_earth';
open_system(mdlname);
sim(mdlname);

Contact us