1 function g=grad3z(f,h,b)
3 % compute gradient in 3d assuming zero boundary conditions
5 % in 3rd coordinate use reflection at bottom instead of zero
9 % b use zero boundary condition on output at the bottom
18 fz(2:n(1)+1,2:n(2)+1,2:n(3)+1)=f;
20 fz(:,:,1) = fz(:,:,2);
24 g{1}=(fz(2:end,2:end-1,2:end-1)-fz(1:end-1,2:end-1,2:end-1))/h(1);
25 g{2}=(fz(2:end-1,2:end,2:end-1)-fz(2:end-1,1:end-1,2:end-1))/h(2);
26 g{3}=(fz(2:end-1,2:end-1,2:end)-fz(2:end-1,2:end-1,1:end-1))/h(3);