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

 採用された回答

Walter Roberson
Walter Roberson 2013 年 8 月 28 日

1 投票

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

2 件のコメント

Bhaskarjyoti
Bhaskarjyoti 2013 年 8 月 30 日
yeah it is a rectangular grid. And it works. Thanks a lot.
Muthu Annamalai
Muthu Annamalai 2013 年 8 月 30 日
@walter I love the gradient + quiver plots. Reminds me of the swirling fields.. http://www.mathworks.com/help/matlab/ref/gradient.html?searchHighlight=gradient

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2013 年 8 月 28 日

0 投票

Wouldn't it be diff(Z) ./ sqrt(diff(X).^2 + diff(Y).^2) or something pretty similar to that?

1 件のコメント

Bhaskarjyoti
Bhaskarjyoti 2013 年 8 月 30 日
Thanks. I could do it by gradient(z,x,y).

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Vector Fields についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by