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