"bo " <bobpong1979@hotmail.com> wrote in message <hq1d9k$17c$1@fred.mathworks.com>...
> > There are other problems here beyond the mechanical
> > on that your function failed on. You cannot quite so
> > trivially convert to polar coordinates.
> >
> > Where is the origin in this polar coordinate system?
> > Don't forget that when you do as you did, you
> > implicitly make an assumption about the location of
> > that polar origin. When you make this incorrect
> > assumption about the origin, that quadratic polynomial
> > now becomes wildly insufficient as a model for the
> > curve that you try to fit it with. If you don't believe
> > me, PLOT IT!!!!!!!!
> >
> > plot(degree,r)
> >
> > Do you think that this curve looks like a quadratic
> > polynomial as you have generated it????????
> >
> > Think about what you are doing, BEFORE you blindly
> > do things. ALWAYS PLOT YOUR DATA.
> >
> > I'll point out that I did submit a function to compute
> > the arclength of a general curve to the FEX, although
> > as this is homework, you will not find it to be of value.
> >
> > John
>
> Hi,John
>
> It is like a 4th degree polynomial.
NO. It is not.
LOOK AT THE DATA. PLOT IT. THINK ABOUT IT.
I plotted your curve.
plot(degree,R)
As a function of the independent variable degree,
this is not even a single valued function as you have
computed it, not with that implicit origin.
> I used quadratic function because I want to find the arc length between each pair of data.The origin of the cordinate is 0,0 but my radius data ranges only from 180 to 310
Sigh. A quadratic function is no better.
Try plotting the function as you have fit it, compared
to the actual data points. I don't care what order
polynomial you use. Polynomials simply are not
multivalued functions. They do not have points where
they go through derivative singularities. Or perhaps you
just use better polynomials than I do. No.
If this is not homework, then you can download
the function I put on the FEX. I compute arclength
in a way there that is fully independent of the
orientation of the curve. It may be any curve in
any number of dimensions. I allow you to compute
a linear chordal arclength or that which you get
from a parametric spline or pchip model.
The arclength function that I posted also returns the
length of each segment of the curve.
http://www.mathworks.com/matlabcentral/fileexchange/26848arclength
y=[235.69,267.97,291.67,303.98,305.59,302.03,285.44,257.99,224.26,190.37,160.33];
z=[85.24,73.95,49.29,17.39,16.77,50.79,80.7,101.09,106.73,102.09,85.75];
[totallenth,seglength] = arclength(y,z,'linear')
totallenth =
341.99
seglength =
34.197
34.202
34.193
34.198
34.206
34.203
34.194
34.198
34.206
34.196
[totallength,seglength] = arclength(y,z,'spline')
totallenth =
344.18
seglength =
34.585
34.456
34.402
34.256
34.305
34.478
34.502
34.417
34.33
34.452
As you would expect, the spline fit is longer than the
linear one. This must be, since a connectthedots
curve is the shortest possible way to connect the
points in that sequence.
If you insist on writing your own code for this, then
do it well. See what happens when you use a different
origin. (Sigh. Why do I need to go to this extent?)
y0 = mean(y);
z0 = mean(z);
r = sqrt((yy0).^2+(zz0).^2);
degree = atan2(zz0,yy0)*180/pi;
plot(degree,r)
Try it. It should be no surprise that the is a viable
functional form. Of course, the arclength is incorrect
when you do it that way, since the variables of the
curve now have the units of degrees on one axis,
and radius on the other.
So regardless of how you try to do it using degrees,
the arclength of that curve will be meaningless.
But feel free to do meaningless computations. They
don't charge you more for your license if you do.
I would strongly recommend that you don't publish
what you compute this way though. (Sorry, but the
sarcasm is coming through here.)
John
