echo on

[x,y] = meshgrid(-3:1:3);
z = peaks(x,y);
figure(1); clf
surf(x,y,z);
title('Original Data')

[xi, yi] = meshgrid(-3:0.25:3);
zi1 = interp2(x,y,z,xi,yi,'nearest');
zi2 = interp2(x,y,z,xi,yi,'linear');
zi3 = interp2(x,y,z,xi,yi,'cubic');
zi4 = interp2(x,y,z,xi,yi,'spline');

figure(2)
subplot(2,2,1)
surf(xi,yi,zi1)
title('2-D interpolation - ''nearest''')
subplot(2,2,2)
surf(xi,yi,zi2)
title('2-D interpolation - ''linear''')
subplot(2,2,3)
surf(xi,yi,zi3)
title('2-D interpolation - ''cubic''')
subplot(2,2,4)
surf(xi,yi,zi4)
title('2-D interpolation - ''spline''')

echo off
shg
