|
On Feb 10, 1:58 pm, "maya tunal" <nur...@hotmail.com> wrote:
> TideMan <mul...@gmail.com> wrote in message <4e2e4135-a8f3-4765-b73b-9fbeecfd7...@t34g2000prm.googlegroups.com>...
> > On Feb 10, 12:30 pm, "maya tunal" <nur...@hotmail.com> wrote:
> > > Hi,
> > > I am working with contour data (X,Y) and I try to find the contour lengths and at the end I want to plot a diagram which shows the lengths (vertical axis) and contour heights (hor. axis), my working data is as below, in the first row there are contour height(1,1) and number of points on contour (1,2), and then it goes as. How can I calculate the S(lengths) on each contour. Could you help me, please?
> > > thanks in advance,
> > > Maya
>
> > > 610 8
> > > 549005.01 5126026.065
> > > 549005.5707 5126025.01
> > > 549008.7453 5126020.01
> > > 549010.01 5126018.283
> > > 549011.7846 5126015.01
> > > 549015.01 5126010.133
> > > 549015.105 5126010.01
> > > 549016.5238 5126005.01
> > > 620 22
> > > 549005.01 5126064.949
> > > 549007.0596 5126060.01
> > > 549010.01 5126055.486
> > > 549010.4421 5126055.01
> > > 549015.01 5126051.211
> > > 549015.9745 5126050.01
> > > ... ....
>
> > It's pretty simple mathematics:
> > dx=x(2:end)-x(1:end-1);
> > dy=y(2:end)-y(1:end-1);
> > ds=sqrt(dx.^2+dy.^2);
> > s=sum(ds);
>
> yes, I know the equation but my problem is to make an automation to this code, first load to .xls data to matlab, and then read the contour heights and number of points on contours, and calculate the lengths for each contours.
> I have found the contour (in the dataset)
> contour =
>
> 610 8
> 620 22
> 630 35
> as this. (first column is height and second one is number of points),
> but i didnt evaulate lengths (S1 (for 610 contour height-with 8 points), S2(..)) automatically. (I want to use this code for a series of data with different values)
> I am so confused,and work really alot on this matter,but I couldnt solve.
You'll have to put it in a loop:
nrows=size(c,1); % c is the matrix output from contour, transposed
indx=1;
while 1
height=c(indx,1);
n=c(indx,2);
put the equation you say you know how to do here,
remembering to address the matrix c correctly:
the indexes will go from indx+1 to indx+n, won't they?
% Go to the next contour
indx=indx+n +1;
if indx > nrows,break,end
end
|