Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!not-for-mail
From: predictr@bellatlantic.net (Will Dwinnell)
Newsgroups: comp.soft-sys.matlab
Subject: Re: Curve fitting a 3D data set
Date: 19 Nov 2004 17:27:27 -0800
Organization: http://groups.google.com
Lines: 62
Message-ID: <2b7b8021.0411191727.35c5f736@posting.google.com>
References: <eef3579.-1@webx.raydaftYaTP> <cnjb5n$guv$1@news-int2.gatech.edu> <eef3579.2@webx.raydaftYaTP>
NNTP-Posting-Host: 68.162.81.203
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1100914048 26401 127.0.0.1 (20 Nov 2004 01:27:28 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 20 Nov 2004 01:27:28 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:243166



MATLAB provides an easy way to calculate least-squares fits of linear
functions:

    Coefficients = Inputs \ Outputs;

...where 'Inputs' and 'Outputs' are data arrays holding the
independent and dependent variables, respectively, with variables in
columns and observations in rows.

Adding a constant term simply requires a column of ones in the
'Inputs' matrix:

    Coefficients = [ones(size(Inputs,1),1) Inputs] \ Outputs;

This process is readily extended to functions which are nonlinear, but
linear in their inputs by performing whatever transformations are
necessary on the input data before performing the fit.  For instance,
if the model were to include squares and cubes of the input variables
(but no interactions), one could try:

    Coefficients = [ones(size(Inputs,1),1) Inputs Inputs.^2 Inputs.^3]
\ Outputs;

Cross-terms are more work, but it should be straightforward at this
point.


-Will Dwinnell
http://will.dwinnell.com


Sanne <sc_trold@hotmail.com> wrote in message news:<eef3579.2@webx.raydaftYaTP>...
> That is exactly what I am trying to do. My data should fit to
> something like a poly of second order (parabola) and I could only
> find functions (polyfit) which could do it in 2D
> 
> Teddy Hsung wrote:
> >
> >
> > My understanding to you question is that you have a known form of
> > function
> > with some unknown parameters. And you have bunch of 3D data. You
> > want to fit
> > those data to get the parameters??
> >
> > If so, the optimization toolbox can help you out. If you can
> > provide more
> > details, I would be happy to give it a try.
> >
> > Rentian
> >
> > "Sanne Christensen" <sc_trold@hotmail.com> wrote in message
> > news:eef3579.-1@webx.raydaftYaTP...
> >> I'm pretty new in the Matlab-world. How do I make curve fitting
>  on a
> >> 3D data set (x, y, z)? Do I need a special toolbox for it?
> >>
> >> Thanx for your help :)
> >> Sanne
> >
> >
> >