Re: 3D Curve fitting
- To: mathgroup at smc.vnet.net
- Subject: [mg4035] Re: 3D Curve fitting
- From: ianc (Ian Collier)
- Date: Tue, 28 May 1996 01:45:40 -0400
- Organization: Wolfram Research, Inc.
- Sender: owner-wri-mathgroup at wolfram.com
In article <4ne6e4$car at dragonfly.wolfram.com>, nishioka at nntp1.best.com
(Owen Nishioka) wrote:
> I'm not sure if this is a trivial question, but I haven't been able
> to figure it out. I'm trying to fit a surface through a series of
> points, (similar to Fit, but in z for x and y) and generate an
> equation. Any ideas on how to do this?
>
> Thanks,
> Owen
>
> --
Yes. You can simply use Fit.
Here is a simple example.
In[20]:=
?Fit
Fit[data, funs, vars] finds a least-squares fit to a list of
data as a linear combination of the functions funs of
variables vars. The data can have the form {{x1, y1, ...,
f1}, {x2, y2, ..., f2}, ...}, where the number of
coordinates x, y, ... is equal to the number of variables
in the list vars. The data can also be of the form {f1,
f2, ...}, with a single coordinate assumed to take values
1, 2, .... The argument funs can be any list of functions
that depend only on the objects vars.
In[21]:=
data = Flatten[
Table[ {x, y,
2 x + 3 x^3 + 7 y - 2 y^3 + .5 Random[]},
{x, 0, 2, .2}, {y, 0, 2, .2}],
1];
In[22]:=
Fit[ data, {x, x^3, y, y^3}, {x, y}]
Out[22]=
3 3
2.18738 x + 2.96728 x + 7.1637 y - 2.02183 y
Fit is documented in some detail, including an example of
fitting a set of data to a function of x and y, in section
3.8.1 of the Mathematica book (pp 672-676) .
If you require further help with this I would suggest that you
contact Wolfram Research Technical Support (support at wolfram.com)
directly.
I hope this helps.
--Ian
-----------------------------------------------------------
Ian Collier
Wolfram Research, Inc.
-----------------------------------------------------------
tel:(217)-398-0700 fax:(217)-398-0747 ianc at wolfram.com
Wolfram Research Home Page: http://www.wolfram.com/
-----------------------------------------------------------
==== [MESSAGE SEPARATOR] ====