%% 2-D Interpolation Over Finer Grid
% Interpolate coarsely sampled data using a full grid with spacing of 0.5.
% Define the sample points as a full grid with range [1, 10] in both dimensions.

[X,Y] = ndgrid(1:10,1:10);

%
% Sample f(x,y) = x^{2}+y^{2} at the grid points.

V = X.^2 + Y.^2;

%
% Create the interpolant, specifying cubic interpolation.

F = griddedInterpolant(X,Y,V,'cubic');

%
% Define a full grid of query points with 0.5 spacing and evaluate the interpolant at those points. Then plot the result.

[Xq,Yq] = ndgrid(1:0.5:10,1:0.5:10);
Vq = F(Xq,Yq);
mesh(Xq,Yq,Vq);

% Copyright 2015 The MathWorks, Inc.