Using a quiver function draw a plot

I am trying to use a quiver function to draw a plot from -1 <= x,y <= 1
So far, for my code, I have...
syms x y z
u = @(x,y) y / (x.^2 + y.^2);
v = @(x,y) -x / (x.^2 + y.^2);
[x,y] = meshgrid(-1:1, -1:1);
quiver(x,y,u,v,0)
But I am getting an error saying, "Error using quiver, Input arguments must be numeric or objects which can be converted to double"
u and v are the i and j component of a vector I need to plot from -1 to 1. How do I plot this graph?
Please help and thank you

 採用された回答

Voss
Voss 2022 年 11 月 21 日

0 投票

u = @(x,y) y ./ (x.^2 + y.^2); % use ./ instead of /
v = @(x,y) -x ./ (x.^2 + y.^2);
[x,y] = meshgrid(-1:1, -1:1);
quiver(x, y, u(x,y), v(x,y), 0) % evaluate u and v at (x,y)

2 件のコメント

Hyo Yun
Hyo Yun 2022 年 11 月 21 日
Thank you very much!
Voss
Voss 2022 年 11 月 21 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

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

製品

リリース

R2022a

質問済み:

2022 年 11 月 21 日

コメント済み:

2022 年 11 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by