How to get the aircraft location from a flight path plot?

I have the below data (dummy data) of a aircraft flight path, with the time, latitude. longitude and heading of the aircraft in a table.
The actual data consists of more than 100k rows, and file is too big to be uploaded.
Based on the actual data, I am able to plot the flight path on a map. The flight path map has an x-axis of Longitude and y-axis of Latitude. Problem is if I want to know the location of the aircraft at a particular time (say at 7220sec), how can I get the latitude, longitude and heading of the aircraft from the plot?

 Accepted Answer

% Generate some data
t = (7020:210:10080)';
lon = 102.915 - t/10080;
lat = 1.363 - t/20000;
heading = 153 + t/50040;
% Create an interpolant
F = griddedInterpolant(t, [lon lat heading]);
t = 8024;
F(t) % lat lon heading
ans = 1×3
102.1190 0.9618 153.1604

13 Comments

Hi Chunru,
Thanks for your help. However I encountered an error when it runs until
F=griddedInterpolant(t,[lon lat headin]);
The error is "The grid vectors do not define a grid of points that match the given values".
Can you show the size of your variables by running "whos"? If possible, show the variable "t".
Can you show the variable "t"? The sample points in t must be unique.
The values of t are as below, The t values are unique.
7020
7230
7440
7650
7860
8070
8280
8490
8700
8910
9120
9330
9540
9750
9960
If I replaced F = griddedInterpolant(t, [lon lat heading]) with either of the below,
1) F = griddedInterpolant(t, lon);
2) F = griddedInterpolant(t, lat);
3) F = griddedInterpolant(t, heading);
then it will work.
However, by using the above, it is quite tedious as I will have to run the griddedInterpolant command for each of lon, lat, heading, and then combine them into a matrix.
Can you post your code and data (the data looks very small)?
Thanks for your help.
I actually run your code (as pasted below) , and there's an error encountered at the line "F=griddedInterpolant(t,[lon lat headin]);", and hence can't continue.
My internet facing computer (which I am using to communicate with you) does not have matlab installed. I am running matlab in another laptop that does not have internet connection.
% Generate some data
t = (7020:210:10080)';
lon = 102.915 - t/10080;
lat = 1.363 - t/20000;
heading = 153 + t/50040;
% Create an interpolant
F = griddedInterpolant(t, [lon lat heading]);
t = 8024;
F(t) % lat lon heading
Below is the values of t, lon, lat, heading generated.
Save the data in .txt or .mat file. Use the paper-clip (attachment) to attach the data. It difficult to use the screen-capture data.
Ok, I will send by tonight. Thanks for your help.
Hi,
I run the code at home using Matlab ver R2021a, and there is no error. It runs fine. In the office, my Matlab version is 2015b, and error will occur at the line "F = griddedInterpolant(t, [lon lat heading]);".
Attached is the data in .mat format. Thanks.
load data
whos
Name Size Bytes Class Attributes F 1x1 976 griddedInterpolant ans 1x3 24 double heading 15x1 120 double lat 15x1 120 double lon 15x1 120 double t 15x1 120 double
%T = table(t, lat, lon, heading)
% Create an interpolant
F = griddedInterpolant(t, [lon lat heading]);
tq = 8024;
F(tq) % lat lon heading
ans = 1×3
102.1190 0.9618 153.1604
% If you have problem with griddedInterpolant on older version MATLAB
% you can try the following
z = interp1(t, [lon lat heading], tq)
z = 1×3
102.1190 0.9618 153.1604
Thanks a lot. The command line "z = interp1(t, [lon lat heading], tq)" works.

Sign in to comment.

More Answers (0)

Products

Release

R2015b

Asked:

on 21 Sep 2021

Commented:

on 23 Sep 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!