On Feb 24, 10:31 am, Charlie <charliebis...@gmail.com> wrote:
> Hello Everyone.
>
> I have a series of about 3000 coordinate pairs of Latitude,Longitude
> from a scientific cruise I was recently (I can very easily convert
> this into X,Y points). When plotted, they are basically a jumble, but
> I can see that at some points the ship was travelling in straight
> transects.
>
> I would like to write a loop that breaks the series of points up so
> that the pairs forming fairly straight lines can be grouped together
> (so I can do some contour plotting of the data obtained underneath the
> vessel).
>
> I cannot think of an easy way to do this. Perhaps a loop that checks
> that slope of the first two points, and then compares the slope of the
> first and third points, and the first and fourth points, and groups
> together ones that have a slope within a certain tolerance? There can
> be a little "bending" in the line segments, it doesn't have to be
> perfectly straight.
>
> Can anyone help me think of a simple algorithm that will do this?
>
> cheers,
3000 points is not very many.
You could do some of the work by eye.
Plot the points up, then do:
[xx,yy]=ginput;
and pick off the start and finish coordinates of each transect.
Now, locate the indexes of the actual coordinates:
nt=length(xx);
imn=zeros(nt,1);
for it=1:nt
[zmn,imn(it)]=min((xx(it)x).^2+(yy(it)y).^2);
end
So, now you have the start and finish indexes of each transect and you
can process the sequences of data.
