MATLAB: Gradient of a vector

vector gradient

I have 3 vectors X(i,j);Y(i,j) and Z(i,j).Z is a function of x and y numerically. I want to plot the gradient of z with respect to x and y. Can anyone suggest me how to find the gradient in the above case? Thanks, -Bhaskar

Best Answer

Is it a rectangular grid? [X, Y] = ndgrid(Xv, Yv) for some vector Xv, Yv ?
If so, then
gradient(Z, xv, yv)