%problem 8.39
hold off
clear
x=[0 .2 .4 .6 .8 1 ];
y=[0 .2 .4 .6 .8 1];
z=[1 1.22 1.49 1.82 2.22 2.71
   1.78 2.00 2.27 2.60 3.01 3.50
   2.35 2.57 2.84 3.17 3.57 4.06
   2.55 2.77 3.04 3.37 3.77 4.26
   2.38 2.60 2.87 3.20 3.61 4.10
   2.00 2.22 2.49 2.82 3.22 3.71];
xx=0:.1:1;
yy=0:.1:1;
flops(0);
n=length(x);
%MATLAB METHODS
%linear interpolation
z1=interp2(x,y',z',xx,yy')
%cubic interpolation
z2=interp2(x,y',z',xx,yy','cubic')
% make 3d plots 
[xa,ya]=meshgrid(xx,yy);
%contour plots
figure
[C,h]=contour(xa,ya,z1);
title(' Bi-linear Interpolation')
clabel(C,h)
figure
[C,h]=contour(xa,ya,z2);
title(' Bi-cubic Interpolation')
clabel(C,h)
%filled contour plots
figure
contourf(xa,ya,z1)
title(' Bi-linear Interpolation')
figure
contourf(xa,ya,z2)
title(' Bi-cubic Interpolation')
%surface plots
figure
surf(xa,ya,z1)
title(' Bi-linear Interpolation')
figure
surf(xa,ya,z2)
title(' Bi-cubic Interpolation')

