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 Exchange에서 Vector 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