[X,Y] = meshgrid(-2:.2:2);
Z = X.*exp(-X.^2 - Y.^2);
[DX,DY] = gradient(Z,.2,.2);

% Curl of gradient


figure
contour(X,Y,Z)
hold on
quiver(X,Y,DX,DY)
hold off

surf(X,Y,Z)