[X,Y] = meshgrid(-2:0.2:2);
Z = X.*exp(-X.^2-Y.^2);
[Gx,Gy]=gradient(Z);
C=sqrt(Gx.^2+Gy.^2);
figure(1)
colormap(flipud(gray));
surf(X,Y,Z,C)
colorbar


N=30; D=1; H=0.3; 
krok1=1/(N-1); 
krok2=(H-D)/(N-1);
[X,Y] = meshgrid(-2:4*krok1:2);
Z = X.*exp(-X.^2-Y.^2);
C2(:,:,1) = meshgrid(D:krok2:H);
C2(:,:,2) = meshgrid(D:krok2:H);
C2(:,:,3) = meshgrid(D:krok2:H);

figure(2)
surf(X,Y,Z,C2)









