Hi Harrison,
I understand from your query that you need assistance in determining the deviation of the flight's actual path from an ideal descent path, given the GPS coordinates and altitude of the flight.
Based on the example you mentioned, it seems there is a deviation in altitude only. I have created dummy data for the latitude, longitude, and altitude, assuming that the landing follows a non-linear descent profile, exponential decay. The altitude of the ideal trajectory is obtained by using tangent with the expected 2d trajectory. Kindly refer to the code snippet attached below:
format long
%Assumptions:
% 1. deviation is possible only in altitude
% Define the number of data points
numPoints = 100;
% Define the starting and ending altitudes in meters
% Assuming the starting altitude is 3000 meters and the plane lands at 0 meters
start_altitude = 3000; % in meters
end_altitude = 0; % touchdown
% Create a non-linear vector for altitude using an exponential decay
% The decay rate determines how quickly the altitude decreases
decay_rate = 2;
altitude = start_altitude * exp(-decay_rate * (0:numPoints-1));
altitude(end) = end_altitude;
% Generate dummy latitude and longitude values assuming a straight path
% Define the starting and ending coordinates for the approach
% Assuming the runway threshold is at latitude 40.0 and longitude -75.0
start_latitude = 40.1; % 0.1 degrees north of the runway
end_latitude = 40.0;
start_longitude = -75.05; % 0.05 degrees west of the runway
end_longitude = -75.0;
% Create linearly spaced vectors for latitude and longitude
latitude = linspace(start_latitude, end_latitude, numPoints);
longitude = linspace(start_longitude, end_longitude, numPoints);
% Combine the latitude, longitude, and altitude into a single array
% Each row of the array represents a point in the format [latitude, longitude, altitude]
planeLandingPath = [latitude', longitude', altitude'];
%Ideal landing path 3 degree slope
expectedAltitude = tan(3*pi/180)*sqrt((latitude - end_latitude).^2+(longitude - end_longitude).^2)
deviation = abs(altitude-expectedAltitude)
plot3(latitude,longitude,altitude)
hold on;
plot3(latitude,longitude,expectedAltitude)
Here is the obtained altitude deviation:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1580256/image.png)
Figure 1 Altitude deviation of the flight
Hope this helps,
Regards,
Neelanshu