Hi all,
Thank you in advance for the help you will provide, I really appreciate.
I am new to matlab so this could be very hard or very basic to do I don't know, Basically, I am trying to calculate a trajectory of an object on earth at different years.
I am calculating the distance that an object has done on earth using the Lat and long values.
My data are in three column, first column the year in which the distance was achieved (so the year is repeated as long as it is the same object), second column the latitude and third column the longitude.
What I want to do is calculate the distance in km between each point and sum them up for the same object. All the objects are consecutive in the columns but separated by a 0 (in the second and third column, so the program knows when to stop summing the points). My problem is that with what I wrote I only get the first object distance and I would like to get a loop so it goes to the next object below and so on.
Also, i would like to export the numbers in an excel file in three columns: year, distance and number of point that defined the distance. (I have 11000 object and more than 350,000 points that's why I need an automated program)
Can some one help me with this? Below is the program that I wrote nd example of my data:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
clear all
close all
load data.txt
earth_radius = 6371;
flag=1;
p=0;
angle=0;
for
while (flag==1);
p=p+1;
% Add angles between points.
angle=angle+distance(data(p,1),data(p,2),data(p+1,1),data(p+1,2));
% if the following point is [0 0], stop counting
if (data(p+2,1)==0 && data(p+2,2)==0)
flag=0;
end
end
%conversion from degrees to rad
ang_rad=pi*angle/180;
% conversion from rad to distance on the sphere in km.
distance=ang_rad*earth_radius;
disp('distance is (km) ');
disp(distance);
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Example of my data:
1922 39.87 60.61
1922 40.87 60.21
1922 41.87 59.86
1922 42.87 59.54
0 0
1924 29.87 64.9
1924 30.87 64.5
1924 31.87 64.11
1924 32.87 63.68
1924 33.87 63.23
0 0
1925 29.87 64.9
1925 30.87 64.5
1925 31.87 64.11
1925 32.87 63.68
0 0
Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thank you