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