1
$\begingroup$

I have a following data,

 x , y , z, f(x,y,z)
0.0,0.0,0.0,1.532704
0.04,0.0,0.0,1.520342
0.08,0.0,0.0,1.484285
0.12,0.0,0.0,1.426193
0.16,0.0,0.0,1.353395
0.2,0.0,0.0,1.269138
0.24,0.0,0.0,1.17861
0.28,0.0,0.0,1.090471
0.32,0.0,0.0,1.005581
0.36,0.0,0.0,0.933414
0.4,0.0,0.0,0.877248
0.44,0.0,0.0,0.836819
0.48,0.0,0.0,0.816123
0.04,0.04,0.0,1.504544
0.08,0.04,0.0,1.478109
0.12,0.04,0.0,1.43574
0.16,0.04,0.0,1.373018
0.2,0.04,0.0,1.294042
0.24,0.04,0.0,1.204979
0.28,0.04,0.0,1.108072
0.32,0.04,0.0,1.016175
0.4,0.04,0.0,0.857493
0.44,0.04,0.0,0.820139
0.48,0.04,0.0,0.802623

I want to make a 3D interpolating function using this data. If I use the simple Interpolation,

Interpolation[Transpose[{Transpose[{x, y, z}], f}]];

Then the following error occurs, enter image description here

Does anyone have a solution?

$\endgroup$
4
  • $\begingroup$ Some of the data rows have four elements and some have five elements. Fix the data. $\endgroup$
    – Bob Hanlon
    Oct 20, 2023 at 2:46
  • $\begingroup$ @BobHanlon Fixed it $\endgroup$
    – sslucifer
    Oct 20, 2023 at 3:13
  • $\begingroup$ How are you importing the data? Are they in a csv file? $\endgroup$
    – MelaGo
    Oct 20, 2023 at 3:29
  • $\begingroup$ @MelaGo Yes. Then assigning x = First Column, y = Second Column, and so on. $\endgroup$
    – sslucifer
    Oct 20, 2023 at 3:51

1 Answer 1

3
$\begingroup$
data = Import["data.csv"]
  (* {{0, 0, 0, 1.5327}, {0.04, 0, 0, 1.52034}, ... *)

All of the z values are 0, so disregarding this dimension

ListPlot3D[data[[All, {1, 2, 4}]]]

enter image description here

f = Interpolation[data[[All, {1, 2, 4}]]]
Plot3D[f[x, y], {x, 0, .48}, {y, 0, .04}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.