function [H]=drop_thinwalls(h,hx,hy,periodic) % % Returns the depths at T points based on T, U and V points. % % e.g. % H=drop_thinwalls(H2,Hx2,Hy2); if size(h)~=size(hx) | size(h)~=size(hy) error('Arguments must all be the same size!\n'); end [nx,ny]=size(h); % Fill-up cell-centers where all sides are higher Hsides=min( hx, hx([2:end 1],:,:) ); Hsides=min( Hsides, hy ); Hsides=min( Hsides, hy(:,[2:end end],:) ); H=max( h, Hsides ); %H=h; for jj=1:ny; jp=min(ny,jj+1); jm=max(1,jj-1); for ii=1:nx; if periodic==1 ip=mod(ii,nx)+1; im=mod(ii-2+nx,nx)+1; else ip=min(nx,ii+1); im=max(1,ii-1); end hp=H(ii,jj); hm=H(im,jj); ho=hx(ii,jj); if ho>max(hm,hp) if hmmax(hm,hp) if hm