Re: surface fitting question
- To: mathgroup at smc.vnet.net
- Subject: [mg61336] Re: surface fitting question
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Sun, 16 Oct 2005 00:17:52 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <diprth$hpc$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Ralph Smith wrote:
> 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.
>
> thanks,
> Ralph
>
>
>
Hi Ralph,
You must provide to *Fit* a list of three coordinates for each points as
in the following example:
In[1]:=
data = Flatten[Table[Table[{i, j, Random[Real, {0, 2500}]}, {j, 17}],
{i, 26}], 1];
In[2]:=
myFit = Fit[data, {x^3, x^2, x, 1, y^3, y^2, y}, {x, y}]
Out[2]=
901.9358457174038 + 69.00000405849856*x - 4.965777107187227*x^2 +
0.11341669401419147*x^3 - 18.948955500363553*y +
5.111441786546051*y^2 - 0.23474750193421623*y^3
In[3]:=
Plot3D[myFit, {x, 1, 26}, {y, 1, 17}];
Best regards,
/J.M.