0
$\begingroup$

This question already has an answer here:

I have four column data with first 3 column denoting x,y,z and fourth column energy. x variable is actually angle. Now I want to interpolate over all three indepdent variable (x,y.z) with corresponding energy value. I have done Mathematica script which i attach below

f1 = Interpolation[d1]

This gives an error :

Interpolation::indim: The coordinates do not lie on a structured tensor product grid. >>

What could be the correct way of interpolation over 3 variables?

I have modified the data as you said. Modified reduced data set (total 155 points) also gave me the above mentioned error message. If you look at the data carefully, for 0deg second column data range from 4:5.5(0.25) and this is not so for other angles. If I delete data corresponding to 5.25 then above code works. fine. If I keep the data corresponding to 5.25 then code fails. Is there any way to force Mathematica interpolate keeping 5.25 data.

Here I provide the data as taken from Mathematica

Here is my data:

d1 = {{{0., 4., 1.3}, -103.005}, {{0., 4., 1.32}, -103.002}, 
    {{0., 4., 1.34}, -102.999}, {{0., 4., 1.35}, -102.997}, 
    {{0., 4., 1.36}, -102.995}, {{0., 4.25, 1.3}, -103.005}, 
    {{0., 4.25, 1.32}, -103.002}, {{0., 4.25, 1.34}, -102.999}, 
    {{0., 4.25, 1.35}, -102.997}, {{0., 4.25, 1.36}, -102.996}, 
    {{0., 4.5, 1.3}, -103.004}, {{0., 4.5, 1.32}, -103.001}, 
    {{0., 4.5, 1.34}, -102.998}, {{0., 4.5, 1.35}, -102.997}, 
    {{0., 4.5, 1.36}, -102.995}, {{0., 4.75, 1.3}, -103.003}, 
    {{0., 4.75, 1.32}, -103.}, {{0., 4.75, 1.34}, -102.997}, 
    {{0., 4.75, 1.35}, -102.996}, {{0., 4.75, 1.36}, -102.994}, 
    {{0., 5., 1.3}, -103.003}, {{0., 5., 1.32}, -102.999}, {{0., 5., 1.34}, -102.996}, 
    {{0., 5., 1.35}, -102.995}, {{0., 5., 1.36}, -102.993}, 
    {{0., 5.25, 1.3}, -103.002}, {{0., 5.25, 1.32}, -102.999}, 
    {{0., 5.25, 1.34}, -102.995}, {{0., 5.25, 1.35}, -102.994}, 
    {{0., 5.25, 1.36}, -102.992}, {{0., 5.5, 1.3}, -103.001}, 
    {{0., 5.5, 1.32}, -102.998}, {{0., 5.5, 1.34}, -102.995}, 
    {{0., 5.5, 1.35}, -102.993}, {{0., 5.5, 1.36}, -102.992}, 
    {{15., 4., 1.3}, -103.003}, {{15., 4., 1.32}, -103.}, {{15., 4., 1.34}, -102.997}, 
    {{15., 4., 1.35}, -102.995}, {{15., 4., 1.36}, -102.993}, 
    {{15., 4.25, 1.3}, -103.004}, {{15., 4.25, 1.32}, -103.001}, 
    {{15., 4.25, 1.34}, -102.997}, {{15., 4.25, 1.35}, -102.996}, 
    {{15., 4.25, 1.36}, -102.994}, {{15., 4.5, 1.3}, -103.003}, 
    {{15., 4.5, 1.32}, -103.}, {{15., 4.5, 1.34}, -102.997}, 
    {{15., 4.5, 1.35}, -102.995}, {{15., 4.5, 1.36}, -102.994}, 
    {{15., 4.75, 1.3}, -103.003}, {{15., 4.75, 1.32}, -103.}, 
    {{15., 4.75, 1.34}, -102.996}, {{15., 4.75, 1.35}, -102.995}, 
    {{15., 4.75, 1.36}, -102.993}, {{15., 5., 1.3}, -103.002}, 
    {{15., 5., 1.32}, -102.999}, {{15., 5., 1.34}, -102.996}, 
    {{15., 5., 1.35}, -102.994}, {{15., 5., 1.36}, -102.992}, 
    {{15., 5.5, 1.3}, -103.001}, {{15., 5.5, 1.32}, -102.998}, 
    {{15., 5.5, 1.34}, -102.995}, {{15., 5.5, 1.35}, -102.993}, 
    {{15., 5.5, 1.36}, -102.991}, {{30., 4., 1.3}, -103.}, 
    {{30., 4., 1.32}, -102.997}, {{30., 4., 1.34}, -102.993}, 
    {{30., 4., 1.35}, -102.992}, {{30., 4., 1.36}, -102.99}, 
    {{30., 4.25, 1.3}, -103.001}, {{30., 4.25, 1.32}, -102.998}, 
    {{30., 4.25, 1.34}, -102.995}, {{30., 4.25, 1.35}, -102.993}, 
    {{30., 4.25, 1.36}, -102.992}, {{30., 4.5, 1.3}, -103.001}, 
    {{30., 4.5, 1.32}, -102.998}, {{30., 4.5, 1.34}, -102.995}, 
    {{30., 4.5, 1.35}, -102.993}, {{30., 4.5, 1.36}, -102.992}, 
    {{30., 4.75, 1.3}, -103.001}, {{30., 4.75, 1.32}, -102.998}, 
    {{30., 4.75, 1.34}, -102.995}, {{30., 4.75, 1.35}, -102.993}, 
    {{30., 4.75, 1.36}, -102.992}, {{30., 5., 1.3}, -103.001}, 
    {{30., 5., 1.32}, -102.998}, {{30., 5., 1.34}, -102.994}, 
    {{30., 5., 1.35}, -102.993}, {{30., 5., 1.36}, -102.991}, 
    {{30., 5.5, 1.3}, -103.}, {{30., 5.5, 1.32}, -102.997}, 
    {{30., 5.5, 1.34}, -102.994}, {{30., 5.5, 1.35}, -102.992}, 
    {{30., 5.5, 1.36}, -102.991}, {{45., 4., 1.3}, -102.999}, 
    {{45., 4., 1.32}, -102.996}, {{45., 4., 1.34}, -102.993}, 
    {{45., 4., 1.35}, -102.991}, {{45., 4., 1.36}, -102.989}, 
    {{45., 4.25, 1.3}, -103.}, {{45., 4.25, 1.32}, -102.997}, 
    {{45., 4.25, 1.34}, -102.993}, {{45., 4.25, 1.35}, -102.992}, 
    {{45., 4.25, 1.36}, -102.99}, {{45., 4.5, 1.3}, -103.}, 
    {{45., 4.5, 1.32}, -102.997}, {{45., 4.5, 1.34}, -102.994}, 
    {{45., 4.5, 1.35}, -102.992}, {{45., 4.5, 1.36}, -102.99}, 
    {{45., 4.75, 1.3}, -103.}, {{45., 4.75, 1.32}, -102.997}, 
    {{45., 4.75, 1.34}, -102.994}, {{45., 4.75, 1.35}, -102.992}, 
    {{45., 4.75, 1.36}, -102.99}, {{45., 5., 1.3}, -103.}, 
    {{45., 5., 1.32}, -102.997}, {{45., 5., 1.34}, -102.994}, 
    {{45., 5., 1.35}, -102.992}, {{45., 5., 1.36}, -102.99}, {{45., 5.5, 1.3}, -103.}, 
    {{45., 5.5, 1.32}, -102.997}, {{45., 5.5, 1.34}, -102.993}, 
    {{45., 5.5, 1.35}, -102.992}, {{45., 5.5, 1.36}, -102.99}, 
    {{60., 4., 1.3}, -102.999}, {{60., 4., 1.32}, -102.996}, 
    {{60., 4., 1.34}, -102.993}, {{60., 4., 1.35}, -102.991}, 
    {{60., 4., 1.36}, -102.99}, {{60., 4.25, 1.3}, -103.}, 
    {{60., 4.25, 1.32}, -102.996}, {{60., 4.25, 1.34}, -102.993}, 
    {{60., 4.25, 1.35}, -102.991}, {{60., 4.25, 1.36}, -102.99}, 
    {{60., 4.5, 1.3}, -103.}, {{60., 4.5, 1.32}, -102.996}, 
    {{60., 4.5, 1.34}, -102.993}, {{60., 4.5, 1.35}, -102.992}, 
    {{60., 4.5, 1.36}, -102.99}, {{60., 4.75, 1.3}, -103.}, 
    {{60., 4.75, 1.32}, -102.996}, {{60., 4.75, 1.34}, -102.993}, 
    {{60., 4.75, 1.35}, -102.991}, {{60., 4.75, 1.36}, -102.99}, 
    {{60., 5., 1.3}, -102.999}, {{60., 5., 1.32}, -102.996}, 
    {{60., 5., 1.34}, -102.993}, {{60., 5., 1.35}, -102.991}, 
    {{60., 5., 1.36}, -102.99}, {{60., 5.5, 1.3}, -102.999}, 
    {{60., 5.5, 1.32}, -102.996}, {{60., 5.5, 1.34}, -102.993}, 
    {{60., 5.5, 1.35}, -102.991}, {{60., 5.5, 1.36}, -102.99}}; 
$\endgroup$

marked as duplicate by Oleksandr R., Karsten 7., MarcoB, m_goldberg, Jens Sep 27 '15 at 5:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 7
    $\begingroup$ Please format your data so that we can actually evaluate your code. You could also reduce the amount of data, which might even help to reduce the problem. Without working code helping will be difficult and the question may be closed due to that. $\endgroup$ – Yves Klett Jul 3 '15 at 17:04
  • $\begingroup$ I Formated the data and explained in more detail and kindly please have a look at it $\endgroup$ – george Jul 4 '15 at 21:26
  • 1
    $\begingroup$ Please provide the data as a comma-separated list / matrix. Essentially jusy copy & paste from Mathematica. See e.g. mathematica.stackexchange.com/q/77838/131. $\endgroup$ – Yves Klett Jul 5 '15 at 7:42
  • $\begingroup$ Interpolation[d1, InterpolationOrder -> 1] seems to work without any problem. $\endgroup$ – Karsten 7. Jul 7 '15 at 13:54
  • $\begingroup$ This post explains how to copy code. $\endgroup$ – Karsten 7. Jul 7 '15 at 13:58
1
$\begingroup$

I am using Mathematica 10.1 on Win7-64 bit. Using Interpolation and the data you posted, the following seems to work fine on my system:

interpfun = Interpolation[data, InterpolationOrder -> All]

Mathematica graphics

You can then use the interpfun object we obtained to calculate interpolated values:

interpfun[15, 4.3, 1.32]
(* Out: -102.963 *)
$\endgroup$
  • $\begingroup$ I use mathematica 7 and using it, I checked your command given above and it did not work and instead gave me error message given below Interpolation::inord: Value of option InterpolationOrder -> All should be a non-negative machine-sized integer or a list of integers with length equal to the number of dimensions, $\endgroup$ – george Jul 7 '15 at 17:04
  • $\begingroup$ @george that option may not be applicable to MMA v.7. What happens if you remove it altogether? Alternatively, what if you specify an explicit order of interpolation (e.g. InterpolationOrder -> 1)? $\endgroup$ – MarcoB Jul 7 '15 at 17:20
  • $\begingroup$ In both cases too(removing and specifying an order), it does not work in MMA v.7. $\endgroup$ – george Jul 7 '15 at 17:38
  • $\begingroup$ @george Could you be more specific? What error message do you get in those cases? $\endgroup$ – MarcoB Jul 7 '15 at 18:04
  • $\begingroup$ The same error message as before. Interpolation::indim: The coordinates do not lie on a structured tensor product grid. >> $\endgroup$ – george Jul 7 '15 at 20:38

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