Code:
[x,y] = meshgrid(-10:1:10,-10:1:10);
dx = 1;
dy = y*(3-(x*y));
r = ( dx.^2 + dy.^2 ).^0.5;
u = dx./r;
v = dy./r;
figure
quiver(x,y,u,v);
Problem:
My quiver plot is only showing vertical vectors.
I have tried making the x variable dynamic, which just leads to a messed up graph.
I do not know why my code is wrong...

 採用された回答

KSSV
KSSV 2020 年 6 月 24 日

0 投票

[x,y] = meshgrid(-10:1:10,-10:1:10);
dx = 1;
dy = y.*(3-(x.*y)); % Element by element multiplication
r = ( dx.^2 + dy.^2 ).^0.5;
u = dx./r;
v = dy./r;
figure
quiver(x,y,u,v);

2 件のコメント

Dylan Voss
Dylan Voss 2020 年 6 月 24 日
Thanks, that worked!
Basically, ever time I introduce an element into an equation, I should call it with a period?
KSSV
KSSV 2020 年 6 月 24 日
Yes . is used...you have used it for power and divison and forgot in multiplication.

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

その他の回答 (0 件)

カテゴリ

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

質問済み:

2020 年 6 月 24 日

コメント済み:

2020 年 6 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by