How to determine dates when aircraft moving northwards or southwards?
Show older comments
Hello community,
I have a aircraft track dataset name Test.xlsx attached. It contains time, latitude, longitude and height of aircraft tracks. Now I want to find the dates when aircraft was heading towards north and also dates when aircraft heading towards south.
I am at beginner stage of coding, therefore, looking forward to any helps.
Thanks in advance.
Accepted Answer
More Answers (1)
Selena Mastrodonato
on 10 May 2023
I would do it in this way
Test = readtimetable("Test.xlsx","VariableNamingRule","preserve"); % to import data (or using Import Data tool)
d = diff(Test.Obs_Lat); % difference between latitudes
south = Test.Time(find(d<0)); % if the right element is lower than left element the aircraft heads south
north = Test.Time(find(d>0)); % otherwise tha aicraft heads north
3 Comments
Subhodh Sharma
on 10 May 2023
William Rose
on 10 May 2023
Edited: William Rose
on 10 May 2023
@Selena Mastrodonato, excellent answer!
[Edit: change red and blue colors in plot, to match the colors used by @Subhodh Sharma. Add comments about the plotting code.]
You can also leave out the "find()" function and get the exact same results:
Test = readtimetable("Test.xlsx","VariableNamingRule","preserve"); % to import data (or using Import Data tool)
d = diff(Test.Obs_Lat); % difference between latitudes
south = Test.Time(d<0); % if the right element is lower than left element the aircraft heads south
north = Test.Time(d>0); % otherwise tha aicraft heads north
Or you could eliminate d entirely.
Test = readtimetable("Test.xlsx","VariableNamingRule","preserve"); % to import data (or using Import Data tool)
south = Test.Time(diff(Test.Obs_Lat)<0); % if the right element is lower than left element the aircraft heads south
north = Test.Time(diff(Test.Obs_Lat)>0); % otherwise tha aicraft heads north
@Selena Mastrodonato uses many comments to explain her code. May we all follow her good example.
"otherwise the aircraft heads north" suggests an aircraft must have non-zero north/ south velocity at all times. However, the north-south velocity could be zero, and sometimes is, in this example. The code correctly find the times when the norh-south velocity is non-zero.
Make a plot:
plot(Test.Obs_Lon,Test.Obs_Lat,'-k',...
Test.Obs_Lon(d>0),Test.Obs_Lat(d>0),'-r',...
Test.Obs_Lon(d<0),Test.Obs_Lat(d<0),'-b')
legend('Entire Track','Northbound','Southbound') %add legend
grid on; xlabel('Longitude'); ylabel('Latitude') %grid, axis titles
The plotting code above does not attempt to identify separate flight segments. Therefore the plot includes straight lines connecting the end of one segent to the start of a separate segment. You could identify separate flight segments by finding where the time or the position changes by a large amount from one row to the next.
Good luck.
William Rose
on 10 May 2023
@Subhodh Sharma, The difference between Coming.png and Expected.png may be due to the order in which the north and south plots were done, since they overlap one another.
Provide the code you used to make Coming.png, if you want further assistance.
Categories
Find more on Time Series Events in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

