Re: interpolation and plotting 3d data

*To*: mathgroup at smc.vnet.net*Subject*: [mg44724] Re: interpolation and plotting 3d data*From*: drbob at bigfoot.com (Bobby R. Treat)*Date*: Sat, 22 Nov 2003 02:17:17 -0500 (EST)*References*: <200307120919.FAA29502@smc.vnet.net> <bphub9$1o8$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

I suspect somebody will have a better solution, but, assuming your data points are {x,y,f[x,y]} values, here's a cubic fit in both directions: allpoints = {{0.19, 0.54, 0.39}, {0.19, 0.6, 0.34}, {0.19, 0.64, 0.31}, {0.19, 1.04, 0.29}, {0.19, 1.07, 0.31}, {0.2, 0.54, 0.39}, {0.2, 0.59, 0.35}, {0.2, 0.63, 0.32}, {0.2, 0.66, 0.3}, {0.2, 0.69, 0.28}, {0.2, 1, 0.28}, {0.2, 1.03, 0.3}, {0.2, 1.06, 0.32}, {0.2, 1.09, 0.34}, {0.21, 0.47, 0.45}, {0.21, 0.54, 0.39}, {0.21, 0.62, 0.33}, {0.21, 0.65, 0.31}, {0.21, 1, 0.3}, {0.21, 1.02, 0.31}, {0.21, 1.05, 0.33}, {0.21, 1.08, 0.35}, {0.22, 0.53, 0.4}, {0.22, 0.66, 0.31}, {0.22, 0.68, 0.3}, {0.22, 0.7, 0.29}, {0.22, 0.92, 0.28}, {0.22, 0.95, 0.29}}; ClearAll@f f[x_, y_] = Fit[allpoints, {1, x, y, x^2, y^2, x^3, y^3}, {x, y}] tabdata = Table[f[x, y], {x, 0.25, 0.7, 0.05}, {y, 0.3, 1.1, 0.1}]; ListPlot3D[tabdata] Bobby Michael Alfaro <malfaro at ucsd.edu> wrote in message news:<bphub9$1o8$1 at smc.vnet.net>... > Hello, > > I have a list of 3D data that is not uniformly spaced (obtained through > monte carlo sampling). Is it possible to interpolate a function across > the range of the sampled points and plot the interpolated 3d function? > > A sample of the data in the table (allpoints) looks like this: > > {{0.19, 0.54, 0.39}, {0.19, 0.6, 0.34}, {0.19, 0.64, 0.31}, {0.19, > 1.04, 0.29}, {0.19, 1.07, 0.31}, {0.2, 0.54, 0.39}, { > 0.2, 0.59, 0.35}, {0.2, 0.63, 0.32}, {0.2, 0.66, 0.3}, {0.2, 0.69, > 0.28}, {0.2, > 1, 0.28}, {0.2, 1.03, 0.3}, {0.2, 1.06, 0.32}, {0.2, 1.09, > 0.34}, {0.21, 0.47, 0.45}, {0.21, 0.54, 0.39}, {0.21, > 0.62, 0.33}, {0.21, 0.65, 0.31}, {0.21, 1, 0.3}, {0.21, 1.02, 0.31}, > {0.21, > 1.05, 0.33}, {0.21, 1.08, 0.35}, {0.22, 0.53, 0.4}, { > 0.22, 0.66, 0.31}, {0.22, 0.68, 0.3}, {0.22, 0.7, 0.29}, {0.22, > 0.92, 0.28}, {0.22, 0.95, 0.29} } > > I had something in mind like: > > f[x_, y_, z_] = Interpolation[Flatten[allpoints, 1]] > tabdata = Table[f[x, y, z ], {x, 0.25, 0.7, > 0.05}, {y, 0.3, 1.1, 0.1}, {z, 0.3, 1.1, 0.1}] > ListPlot3D[tabdata] > > but must be missing something important because I can't get a plot out > of Mathematica. Would someone please help me with the correct use of > interpolation for 3d data? Also, is another plot type more appropriate? > Thanks for any help! > > Michael