1
|
5877 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
GROUPS:

# ListPointPlot3D & Interpolation: alternative way to enter the arguments?

Posted 10 years ago
 Hi, I am using ListPointPlot3D a lot recently. The arguments seem to have been given in the pattern: ListPointPlot3D[{...,{xi,yj,zij},...}] Also, I use Interpolation[ ] to interpolate the data. And this command wants the arguments in the form: Interpolation[{...,{{xi,yj},zij},...}] I usually have my data in the form: x={x1,x2,...}; (* 1D array with the x-values *) y={y1,y2,...}; (* 1D array with the y-values *) z={{z11,z12,...},{z21,z22,...},...}; (* 2D array with the z-values *) And it is a bit cumbersome to having to rearrange the data every time, especially when entering the data for Interpolation. Therefore my question: Is there a way to either give my data to ListPointPlot3D and Interpolation in this way, or alternatively, is there a simple way to rearrange my data in the way so I can feed it to ListPointPlot3D? Cheers! Gernot
3 Replies
Sort By:
Posted 10 years ago
 Hi Gernot,Try the following: x = Range[10] y = Range[12, 14] z = Table[i^2 j^2, {j, Length[y]}, {i, Length[x]}] Transpose[{Tuples[{x, y}], Flatten[z, 1]}]
Posted 10 years ago
 Hi, thanks for the help.Thats not quite what I need, since zij should correspond to xi and yj.I did it this way so far: Table[{x[[i]],y[[j]],z[[i,j]]},{i,Length[x]},{j,Length[y]}] That works. I was just wondering if there was a smarter way to do it. But anyway, since it works, maybe i shouldn't bother too much.Edit: Now I remember again why I found it so annoying:In certain cases I want to interpolate over the data, and the Interpolation command only accepts the arguments in the form: {...,{{xi,yj},zij},...} And THIS is really the cumbersome part. Sorry for my confusion, I will edit my start post to address this question.
Posted 10 years ago
 Try Transpose[{x,y,#}]&/@z Here's a (simple) symbolic example: In[10]:= x = {x1, x2};(*1D array with the x-values*) In[11]:= y = {y1, y2};(*1D array with the y-values*) In[12]:= z = {{z11, z12}, {z21, z22}};(*2D array with the z-values*) In[13]:= Transpose[{x, y, #}] & /@ z Out[13]= {{{x1, y1, z11}, {x2, y2, z12}}, {{x1, y1, z21}, {x2, y2, z22}}}