Using quiver function to plot vectors

6 ビュー (過去 30 日間)
Sarah  Brehm
Sarah Brehm 2015 年 10 月 26 日
回答済み: Star Strider 2015 年 10 月 26 日
I'm sure this is an extremely basic question so I'm sorry in advance. I plotted a unit square and now I'm trying to plot the associated vectors from the origin using quiver. My code looks like this.
square = [0,0;
0,1;
1,1;
1,0;
0,0]
figure(1)
plot(square(:,1),square(:,2));
xlim([0 2])
ylim([0 2])
quiver(0,0,1.0,0)
quiver(0,0,0,1.0)
quiver(0,0,1.0,1.0)
However, all three vectors are shorter than they should be. The arrows on each vector are not plotting at the proper points. Is there some quiver bug that I'm not aware of?

回答 (1 件)

Star Strider
Star Strider 2015 年 10 月 26 日
It’s not a bug! The quiver function has an optional fifth argument, called the scaling parameter. If you set it to zero, you turn the scaling off.
From the documentation:
  • quiver(...,scale) automatically scales the arrows to fit within the grid and then stretches them by the factor scale. scale = 2 doubles their relative length, and scale = 0.5 halves the length. Use scale = 0 to plot the velocity vectors without automatic scaling.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by