Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to measure the length of curve with Matlab?

Status
Not open for further replies.

mapi

Mechanical
Jan 30, 2007
53
Hi,

I have a picture with a curved body. Now I need to get the length of some curves on the body. How to do that with Matlab? One thing to do is to determine the mask of the curve and thus the coordinate on this curve. Anybody knows how to do it?

Thanks,

mapi
 
Replies continue below

Recommended for you

The Spline Toolbox contains a function CSCVN that will hand you the total length as the last value of the arc sequence.
 
Thanks.

But CSCVN can work only if I have the coordinates on the curve I want. Now I have to first find the coordinate on the curve. Now if I have a picture, first we need to find/determine the curve, and then find the coordinates on these curve.
 
Seems to me you're going about it backwards. The first thing you should be doing is to digitize the curve and apply the correct scaling to get valid values long the curve.

Then, you can simply brute force the arc length using pairwise segment lengths.

TTFN

FAQ731-376
 
Now I reduce the problem to a simpler one:

Suppose that I have got the coordinates of points along the curve from one end to the other. And I use spline to fit the coordinate data. So now I need to obtain the length of the spline curve. How to do that?

Mapi

----------
Matlab code:

figure(2)
x1=[1 0.7 0.4 0.7 1.1 1.5 1.9 2.2 2.1 1.9];
y1=[1 1.15 1.4 1.6 1.7 1.8 1.75 1.5 1.3 1.1];
plot(x1,y1,'o')
figure(3)
xy(1,:)=x1;
xy(2,:)=y1;

fnplt(cscvn(xy))
 
Why can't you brute force the piecewise segment lengths? If you need more precision, you can interpolate between data points using your spline.

TTFN

FAQ731-376
 
Thanks.

In this problem, I also need to break the curve into three parts and calculate their lengths individually. The reason is that y-x curve is not one-to-one curve (one x can have two y values and vice versa).

Mapi
 
I still don't see the problem. Piecewise linear still seems like the solution.

TTFN

FAQ731-376
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor