| 1 |
mlosch |
1.1 |
function [H2,x2,y2]=xyrecur_max(He,xe,ye,niter) |
| 2 |
|
|
% |
| 3 |
|
|
% Returns the gridded data on a grid of half the size |
| 4 |
|
|
% with the maximum (highest) data moved to the cell-centers. |
| 5 |
|
|
% |
| 6 |
|
|
% e.g. |
| 7 |
|
|
% [H2,x2,y2]=xyrecur_max(He,xe,ye); |
| 8 |
|
|
|
| 9 |
|
|
H2=He; |
| 10 |
|
|
x2=xe; |
| 11 |
|
|
y2=ye; |
| 12 |
|
|
|
| 13 |
|
|
% Recursively iterate |
| 14 |
|
|
for nit=1:niter, |
| 15 |
|
|
disp(sprintf(' Recursion level %i (%i,%i) -> (%i,%i) ... ',nit,nx,ny,nx/2,ny/2)); |
| 16 |
|
|
|
| 17 |
|
|
[nx,ny]=size(H2); |
| 18 |
|
|
|
| 19 |
|
|
ii=1:2:nx-1; |
| 20 |
|
|
jj=1:2:ny-1; |
| 21 |
|
|
|
| 22 |
|
|
H2=max( max(H2(ii,jj),H2(ii+1,jj)) , max(H2(ii,jj+1),H2(ii+1,jj+1)) ); |
| 23 |
|
|
x2=(x2(ii)+x2(ii+1))/2; |
| 24 |
|
|
y2=(y2(jj)+y2(jj+1))/2; |
| 25 |
|
|
|
| 26 |
|
|
disp('done.'); |
| 27 |
|
|
|
| 28 |
|
|
end |