Gradient of a 2D plot
85 ビュー (過去 30 日間)
古いコメントを表示
I have a 2D plot of potential (V) (circular contour plot). I have to find the electric field (E) by taking the gradient. How is it possible to see the gradient of V. [U,W]=gradient(V) returns the gradient in X and Y direction and quiver(X,Y,U,W) helps to visualize the vector field. How is it possible to view effective gradient. Contour (X,Y,U) will only help me to see gradient in x direction. How can I see the effect of gradient which is a vector sum of both gradient in X and Y.?
2 件のコメント
Ameer Hamza
2020 年 9 月 30 日
What is wrong with quiver. It generates arrows in the gradient direction.
採用された回答
Star Strider
2020 年 9 月 30 日
See the gradient documentation section on Contour Plot of Vector Field . It demonstrates exactly what you are describing.
4 件のコメント
Star Strider
2020 年 9 月 30 日
My pleasure!
It should not be showing any error. It is an example from the documentation (that I linked to in my oridginal Answer), and ran for me without error in R2020b. The ‘px’ and ‘py’ matrices are both (21x21), so the addition should work. If it is not working with your code, please post it.
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Vector Fields についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!