Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

If I try to make a table SimpleTable and to interpolate a function of two variables, I encounter a problem.

For example:

SimpleTable = Table[{j, i, 2 i - 3 j}, {j, 0, 5}, {i, -5, 5}];

and interpolation:

f := Interpolation[SimpleTable]

and if I try:

f[1, 2]

I get the error messages:

Interpolation::udeg: Interpolation on unstructured grids is currently only supported for InterpolationOrder->1 or InterpolationOrder->All. Order will be reduced to 1. >>

Interpolation::inder: The order-2 derivative of {0,-2,-4} is not a tensor of rank 2 with dimensions 3. >>*)

To me the table SimpleTable seems to have a "rectangular domain". What is wrong here? How to tackle this problem, to get an interpolated function from the table? Does the domain have to be changed?

Although the unstructured grids have already been mentioned here, I was hoping that somebody could make clear how to interpolate a function from 3-D data, without the unstructured grid warning.

share|improve this question
1  
f = ListInterpolation[SimpleTable] ? –  Sektor Mar 10 at 12:44
    
user113891, welcome to mma.se! (a bit delayed, but still from the heart :P). Would you please consider setting a username? –  Jacob Akkerboom Mar 10 at 12:50
1  
@JacobAkkerboom Thanks for the advice –  david1983 Mar 10 at 12:57
    
@Sektor. I tried with f = ListInterpolation[SimpleTable] , and after: f[1,2] didn't get the function value, but the error message: ListInterpolation::inhr: "Requested order is too high; order has been reduced to {3,3,2}." –  david1983 Mar 10 at 12:59
    
@david1983 Well, you are trying to pass 2 arguments to a function that accepts 3... That's not gonna work :) Try f[1,2,3] and see what happens SimpleTable//MatrixForm –  Sektor Mar 10 at 13:03

1 Answer 1

If you check the documentation for Interpolation the correct syntax for multidimensional data is

Interpolation[{{{x1, y1, ...}, f1}, {{x2, y2, ...}, f2}, ...}]

So you will need to modify your code to put the {x, y} coordinates in a list, and Flatten the table:

SimpleTable = Table[{{j, i}, 2 i - 3 j}, {j, 0, 5}, {i, -5, 5}] ~Flatten~ 1;
f = Interpolation[SimpleTable];
f[1, 2]
(* 1 *)

Alternatively you can omit the x,y coordinates entirely and use ListInterpolation:

data = Table[2 i - 3 j, {j, 0, 5}, {i, -5, 5}];    
fun = ListInterpolation[data, {{0, 5}, {-5, 5}}];    
fun[1, 2]

(* ==> 1 *)
share|improve this answer
    
+1, I learned something. I will be tougher on myself and try to answer new users questions with only elementary functions/constructions, in order to gain the right to complain about this infix notation, though :P. –  Jacob Akkerboom Mar 10 at 13:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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