Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

3d curve fitting

137 views
Skip to first unread message

simone

unread,
Apr 22, 2004, 2:40:50 AM4/22/04
to
a wonderfull good morning everyone,

i have some 3d data to which i would like to fit a curve.
i already searched thourgh this newsgroup and some other sites and
found the hint to do that with lsqcurvefit. that sounds good to me
and i would like to try it but honestly i just don't get it. i mean i
read the help text and everything but i still have no idea how to
start or do it.

so i wanted to ask if someone can help me out with an example or
something?

thank ya.
simone

Steven Lord

unread,
Apr 22, 2004, 8:50:30 AM4/22/04
to

Keep in mind that the XDATA you pass to LSQCURVEFIT does not have to be a
vector; you can pass a multi-column matrix, one column per independent
variable, for the XDATA parameter. As long as your function to be fitted
can pull off each column and treat it as an independent variable, yoiu
should be all set.

As a sample objective function:

function v = fitfun(coeff, xdata)
x = xdata(:,1);
y = xdata(:,2);
v = coeff(1)+coeff(2)*x+coeff(3)*x.^2+coeff(4)*y+coeff(5)*y.^2;

This fits z = a+b*x+c*x^2+d*y+e*y^2.

--
Steve Lord
sl...@mathworks.com


Peter Spellucci

unread,
Apr 22, 2004, 2:07:00 PM4/22/04
to

In article <eeda1...@webx.raydaftYaTP>,

for using lsqcurvefit for a curve in 3d, i.e. some thing like

(x(t),y(t),z(t))

having data (x(i),y(i),z(i)) i=1,.,N you must have a model for the curve:
x(t) = FX(param,t)
y(t) = FY(param,t)
z(t) = FZ(param,t)
where param are the parameters to be fitted and the three functions FX,FY andFZ
are not neccessarily of the same type. If I understand your problem right,
then you have simply those
data points and want a curve trough these points, not a specific model.
then using splines is a good idea: take an artificial parameter t for
your curve points . a natural choice would be the arclength of the interpolating
piecewise linear arc. (!! this assumes that you have the order in which the curve
goes through the points) so
t(1)=0,
t(i)=t(i-1)+norm(P(i)-P(i-1)); i=2,...,n with P(i)=[x(i),y(i),z(i)];
then compute 3 splines (independently) through the data (t(i),x(i))
(t(i),y(i)), (t(i),z(i)) and you have your curve
in the form

(x,y,z)=(s1(t),s2(t),s3(t)), 0<=t<= t_end=t(n)

the normal cubic spline
might be somewhat wavy, hence it might be advisable to use a spline under tension
instead. this depeds a lot on your data, best try it out on a representative set
of examples
hth
peter

Message has been deleted

K Nagarajoo

unread,
Jun 2, 2004, 5:06:33 PM6/2/04
to
I used the 30-days demo. I already got an equation with a very good Z
prediction.But, once I wanted to validate the equation,the Z that I
obtained varies very much with the actual Z or the predicted Z(from
the data summary file).I'm afraid I can't further my work as the model
cant be proved. I did the calculation by imputting the value of x and
y to the equation (as in my case, I obtained equation 524) and compare
it with the actual Z or the predicted Z, the variation is very much
high. I used matlab to do the validation. Do advise me on this.Cheers.

K Nagarajoo

On 22 Apr 2004 17:27:27 -0700, Joel Bondurant wrote:
>You can fit 3D data with a single click, and get beautiful 3D graphs
>in realtime with TableCurve 3D from www.systat.com. They have a
>30-day demo that will allow you to do the fitting in seconds with
>graphs and matlab code output. No coding or supplying models is
>required. TableCurve 3D will fit thousands of models to your data in
>seconds with a few mouse clicks.
>
>-Joel
>
>simone <simone...@biocam.de> wrote in message
news:<eeda1...@webx.raydaftYaTP>...

0 new messages