       Re: surface fitting question

• To: mathgroup at smc.vnet.net
• Subject: [mg61330] Re: [mg61328] surface fitting question
• From: "David Annetts" <davidannetts at aapt.net.au>
• Date: Sun, 16 Oct 2005 00:17:46 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Hi Ralph,
> I have this data in a file. It is a 2D table that 26 rows and
>  17 columns.
>      |
> --------------------------------------------------------------
> ---------
>      |   0.000    0.000   0.000   ...     0.000     0.000     0.000
>      |   0.050    0.050   0.155   ...    16.409    19.375    20.156
>      |                       .
>      |                       .
>      |                       .
>      |  47.500  50.000  55.000   ...   2017.500  2075.580  2182.765
> --------------------------------------------------------------
> ---------
>      |
>
> I would like to find an equation that describes this surface
> using mathematica. I think that 3rd degree polynomials would
> be what I'm looking for. So, maybe
>    data[x,y] = ax^3 + bx^2 + cx + d + ey^3 + fy^2 + gy
>
> I've seen and example that uses Fit[], so I think this can be
> done, but I'm a novice at mathematica and don't know how to
> set this problem up. I have been able to fit a polynomial to
> curve data, but now I need to fit a surface.

This sort of thing is described by online help.  You can use Fit[], or any
of the ?*Regress options from Statistics`.

As an example,

(* geneate some data *)
data = Table[{x, y, 10 x^3 + 5 x^2 + 6 x + 10 - 5y^3 - 5y^2 - 10y},
{x, -5, 5, .5}, {y, -5, 5, .5}];

(* try and fit these data *)
Needs["Statistics`"]
NonlinearFit[Partition[Flatten[data], 3],  a
x^3 + b x ^2 + c x + d +  e y^3 + f y^2 +
g y, {x, y}, {{a, 1}, {b, 1}, {c, 1}, {d, 1}, {e, 1}, {f, 1},  {g, 1}}]

To get a better idea of the fit (obviously not needed here), change Fit to
Regress.

Regards,

Dave.

```

• Prev by Date: Re: DSolve and matrix form of system of equations
• Next by Date: Re: surface fitting question
• Previous by thread: Re: Function, Command, Operator, Object...etc.
• Next by thread: Re: surface fitting question