#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Posts: 2Member
Hi all,

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

flag=1;
p=0;
angle=0;
for
while (flag==1);

p=p+1;
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 rad to distance on the sphere in km.

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

[b][size=3]Thank you[/size][/b]
· ·