%% Interpolate Data
% Create a 2-D grid and calculate some function values on the grid. Interpolate between the assigned values to refine the grid.
% Create a coarse grid for (x,y) in the range [-5,5].

[X,Y] = ndgrid(-5:0.5:5);

%
% Calculate some function values on the grid and plot the function.

f = sin(X.^2) * cos(Y.^2);
surf(X,Y,f)

%
% Interpolate between the points using a more refined grid and plot the result.

[X1,Y1] = ndgrid(-5:0.125:5);
F = interpn(X,Y,f,X1,Y1,'spline');

%

surf(X1,Y1,F)

% Copyright 2012 The MathWorks, Inc.