% Trend surface using low pass filtering and residual (original - low
% pass).
% Filtering performed using 2-D convolution.
% L Braile 11/11/02
% define filter
F = ones(3,3)/9;
ZZ = extendZ(Z,20,20,1);
Z1 = conv2(ZZ,F,'valid');
% use interp2 to regrid for increased resolution and smoothness
[XI,YI] = meshgrid(0:dx/4:6);
ZI = interp2(X,Y,Z1,XI,YI,'cubic');
% replot color display and contour map for interpolated data
pcolor(XI,YI,ZI)
shading interp
colorbar
hold on
% Contour the gridded data
v = [-200:100:800];
[c,h] = contour(XI,YI,ZI,v,'w-');
clabel(c,h,'color','w','fontweight','bold','fontsize',15)
axis square
hold off
pause
% calculate residual
Z2 = Z - Z1;
% use interp2 to regrid for increased resolution and smoothness
[XI,YI] = meshgrid(0:dx/4:6);
ZI = interp2(X,Y,Z2,XI,YI,'cubic');
% replot color display and contour map for interpolated data
pcolor(XI,YI,ZI)
shading interp
colorbar
hold on
% Contour the gridded data
v = [-100:50:200];
[c,h] = contour(XI,YI,ZI,v,'w-');
clabel(c,h,'color','w','fontweight','bold','fontsize',15)
axis square
hold off