フィルターのクリア

Quiver plot - vector direction

2 ビュー (過去 30 日間)
Vignesh
Vignesh 2024 年 2 月 5 日
コメント済み: Vignesh 2024 年 2 月 7 日
Hi,
I am trying to plot quiver plot of 2d data and the generated quiver plot is not pointing in the direction of second dataset (x2,y2) from first dataset (x1,y1). Please let me the error I am committing in displaying the plot.
Thanks,
Vignesh
x1 = [5 5.5 6 6.5 7 7 7 6.5 6 5.5 5 5 5 ];
y1= [5 5 5 5 5 5.5 6 6 6 6 6 5.5 5];
plot (x1,y1)
hold on
xlim([-20 20])
ylim([-20 20])
x2 = [4.19 5.26 6.00 6.74 7.81 7.96 7.81 6.74 6.00 5.26 4.19 4.04 4.19];
y2 = [4.19 4.05 4.08 4.05 4.19 5.50 6.81 6.95 6.92 6.95 6.81 5.50 4.19];
plot(x2,y2)
hold on
quiver(x1,y1,x2,y2)

採用された回答

Cris LaPierre
Cris LaPierre 2024 年 2 月 5 日
Your U and V values are all positive, so all quivers will point up and to the right.
I think you want U and V to be the difference between 2 and 1, and not the location of 2.
x1 = [5 5.5 6 6.5 7 7 7 6.5 6 5.5 5 5 5 ];
y1= [5 5 5 5 5 5.5 6 6 6 6 6 5.5 5];
plot (x1,y1)
hold on
x2 = [4.19 5.26 6.00 6.74 7.81 7.96 7.81 6.74 6.00 5.26 4.19 4.04 4.19];
y2 = [4.19 4.05 4.08 4.05 4.19 5.50 6.81 6.95 6.92 6.95 6.81 5.50 4.19];
plot(x2,y2)
quiver(x1, y1,x2-x1,y2-y1)
  1 件のコメント
Vignesh
Vignesh 2024 年 2 月 7 日
Thanks for pointing out the reason why the vectors are not directing as expected.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVector Fields についてさらに検索

タグ

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by