Here is an example using scatteredInterpolant
:
%# get some 2D matrix, and plot as surface
A = peaks(15);
subplot(121), surf(A)
%# create interpolant
[X,Y] = meshgrid(1:size(A,2), 1:size(A,1));
F = scatteredInterpolant(X(:), Y(:), A(:), 'linear');
%# interpolate over a finer grid
[U,V] = meshgrid(linspace(1,size(A,2),50), linspace(1,size(A,1),50));
subplot(122), surf(U,V, F(U,V))
Note that you can evaluate the interpolant object at any point:
>> F(3.14,3.41)
ans =
0.036288
the above example uses a vectorized call to interpolate at all points of the grid