function [H2,x2,y2]=xyrecur_max(He,xe,ye,niter) % % Returns the gridded data on a grid of half the size % with the maximum (highest) data moved to the cell-centers. % % e.g. % [H2,x2,y2]=xyrecur_max(He,xe,ye); H2=He; x2=xe; y2=ye; % Recursively iterate for nit=1:niter, disp(sprintf(' Recursion level %i (%i,%i) -> (%i,%i) ... ',nit,nx,ny,nx/2,ny/2)); [nx,ny]=size(H2); ii=1:2:nx-1; jj=1:2:ny-1; H2=max( max(H2(ii,jj),H2(ii+1,jj)) , max(H2(ii,jj+1),H2(ii+1,jj+1)) ); x2=(x2(ii)+x2(ii+1))/2; y2=(y2(jj)+y2(jj+1))/2; disp('done.'); end