Re: Surface fitting question
- To: mathgroup at smc.vnet.net
 - Subject: [mg38520] Re: [mg38472] Surface fitting question
 - From: Omega Consulting <info at omegaconsultinggroup.com>
 - Date: Fri, 20 Dec 2002 23:40:32 -0500 (EST)
 - Sender: owner-wri-mathgroup at wolfram.com
 
At 12:54 AM 12/18/2002, Bob Priester wrote:
>I have data in an ascii text file that consists of 26 rows and 17
>colums of numbers.  I would like to fit a surface to the data in order
>to get an equation for the contents of the table in terms of the
>values that the rows and colums represent. I'm new to mathematica. So
>far, this is what I've been able to do (not much):
>
>data = Table[ReadList["curves.txt", Number, RecordLists -> True]];
>
>ListPlot3D[data]
>
>Then I see a plot of my real data (a surface). It looks correct. But I
>can't figure out how to do the following:
>
>1. get the real data values on the x & y axes. Ie, the x axis goes
>from 0 to 17 and the y axis goes from 0 to 26. What I really need is
>the x axis to be from 0.0 to 3.0 (but the steps are not evenly
>spaced), and the y axis to go from 0 to 250.  At least the z axis (the
>surface) is plotting like I need it.
You're looking for the MeshRange option.
data = Table[x^2+y^2, {y,0,5},{x,0,5}];
ListPlot3D[data, MeshRange->{{0,5},{0,5}}]
>2. I think that I'd need the real x and y arrays (not just use the
>index)  for Fit[] to compute the correct answer.
You must know what the x and y values are. Then make a table from them.
vals = Table[{x,y}, {y,0,5},{x,0,5}];
Then combine the table of {x,y} values with the z values. And use Flatten 
to get a list of 3d data.
data3d = Flatten[MapThread[Append,{vals,data}, 2], 1];
Now you can fit
Fit[data3d, {1,x,y,x^2,y^2},{x,y}]
>Does anyone have a list of necessary commands to do this?
>
>thanks,
>Bob
--------------------------------------------------------------
Omega Consulting
"The final answer to your Mathematica needs"
http://omegaconsultinggroup.com