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.

This question already has an answer here:

I have a smooth data distribution on a 2D regular grid that is not a rectangular (it is a cross-section of a channel) and I need to find an Interpolating function f[x,y]. I have tried Interpolation[{{x1,y1},f1},{x2,y2},f2},...}] but it doesn't work. Does Interpolation work only on rectangular grid?

Thanks Giovanni

share|improve this question

marked as duplicate by Sjoerd C. de Vries, Artes, Mr.Wizard May 29 '13 at 21:14

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.

    
Have you tried a search on this very site? –  belisarius May 29 '13 at 13:16
    
Or how about the Mathematica help? To give a short answer, Interpolation works not only on rectangular grids. –  partial81 May 29 '13 at 13:24
    
Please could you be more specific about the meaning of "doesn't work"? Also, see (20372). (This was suggested by the review panel as a possible duplicate. Clearly the question is not a duplicate so I skipped the review, but the answer is highly relevant. I am leaning toward closing this as TL unless clarification comes from the OP.) –  Oleksandr R. May 29 '13 at 19:11

1 Answer 1

Interpolation does not only work on rectangular grids. The grid even need not to be regular.

E.g. let us produce some data (x, y,z) which are not on a regular grid on a disk with radius of 5 in the x-y plane and which have z-values between 4 and 5 with:

radius=5;
maxRandomNumber=1000;
{x,y,z}=({#1*Cos[#2]*radius,#1*Sin[#2]*radius,#3})&[
Sqrt[RandomReal[{0,1},maxRandomNumber]],
2*Pi*RandomReal[{0,1},maxRandomNumber],RandomReal[{4,5},maxRandomNumber]];
data = Transpose[{x, y, z}];

If you plot them with

 ListPlot3D[data]

You get something like

output of plot

You can interpolate the data easily with

f = Interpolation[data, InterpolationOrder -> 1];

Plotting them with

Plot3D[f[x, y], {x, -6, 6}, {y, -6, 6}, 
RegionFunction -> Function[{x, y}, Sqrt[x^2 + y^2] < radius]]

Or

ContourPlot[f[x, y], {x, -6, 6}, {y, -6, 6}, 
RegionFunction -> Function[{x, y}, Sqrt[x^2 + y^2] < radius]]

give you a similar picture as the first one. So you see, interpolation still works for such data.

share|improve this answer

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