hello I want to plot some vectors heads to tails in matlab.what should I do?I have found the compass command but it plots all of the vectors from the origin.

1 件のコメント

thiago rech
thiago rech 2020 年 11 月 16 日
Did you find another alternative? I am looking for something that could be used in simulink?

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

 採用された回答

Matt Fig
Matt Fig 2012 年 10 月 20 日
編集済み: Matt Fig 2012 年 10 月 20 日

4 投票

I show you two methods. Both have their uses, so I'll let you decide which fits your needs:
% Make a vector from (2,3) to (7,8)
axes('pos',[0 0 1 1]);
axis([0 10 0 10])
H = annotation('arrow',[.2 .7],[.3 .8])
Notice, the annotation position is in terms of normalized figure units, not axes units. So if you don't want your axes to fill the figure, or if you want to not have "nice" limits (0-10), you have to do some math. It is not too hard, you just have to do some tweaking.
Another approach is to use the QUIVER function:
% Make a vector from (2,3) to (7,8)
cla
quiver(2,3,5,5)
axis([0 10 0 10])

4 件のコメント

jorjijon
jorjijon 2012 年 10 月 21 日
編集済み: jorjijon 2012 年 10 月 21 日
thank you.but by using quiver function the vector will be plotted from x=2 to x=6.5 and from y=3 to y=7.5 instead of x=7 and y=8.why? another question is that with the first method how can I plot a vector from (-2,-3) to (7,8)?
Matt Fig
Matt Fig 2012 年 10 月 22 日
If you read the help for QUIVER (never a bad idea when you encounter a function and have a question about it!!), you will see that you need to tell it to scale to 0 to get what you want...
cla
quiver(2,3,5,5,0)
axis tight
Please read this:
doc quiver
Gennaro Arguzzi
Gennaro Arguzzi 2017 年 11 月 12 日
Hello @Loginatorist, can you explain me your code please? I read the documentation, but it's difficult to pick up the right information.
I tried to plot the array [x1=3,y1=0]-->[x2=-1,y2=7]. Do to it I wrote the code:
%X=x2-x1=-1-3=-4
%Y=y2-y1=7-0=7
quiver(3,0,-4,7)
but I got the array [x1=3,y1=0]-->[x2=-0.6,y2=6.3]. How come?
Jan
Jan 2017 年 11 月 12 日
Disable the scaling:
quiver(3,0,-4,7, 0)

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

その他の回答 (0 件)

カテゴリ

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

タグ

質問済み:

2012 年 10 月 20 日

コメント済み:

2020 年 11 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by