Arrow between several points

72 ビュー (過去 30 日間)
ABCDEFG HIJKLMN 2022 年 2 月 14 日
回答済み: Matt J 2022 年 2 月 14 日
I want to plot the evolution of a solution on a graph.
I have constructed a vector of x and y coordinates as rows, changing every column (at every iteration).
I would like to plot all the points but add arrows in the midpoint between each solution. Something like this:
Is this possible? Thanks in advance!


Matt J
Matt J 2022 年 2 月 14 日
You can use the annotation() command.
  4 件のコメント
Matt J
Matt J 2022 年 2 月 14 日
編集済み: Matt J 2022 年 2 月 14 日
The annotation command will let you draw an arrow between any two specified points. You can use the attached file data2units to convert the data coordinates to the units required by the annotation command, e.g.,
h=plot(2:6,'o'); axis equal
Xmid=X(1:end-1)/2 + X(2:end)/2;
Ymid=Y(1:end-1)/2 + Y(2:end)/2;
annotation('arrow', [X(1), Xmid(1)],[Y(1), Ymid(1)])
annotation('arrow', [Xmid(1), X(2)],[Ymid(1), Y(2)])


その他の回答 (1 件)

Matt J
Matt J 2022 年 2 月 14 日
It might be easier just to use quiver().
h=plot(2:6,'o'); axis equal
[X,Y]=deal(h.XData, h.YData);
X=interp1(X(:),q); Y=interp1(Y(:),q);
hold on
quiver(X(1:end-1),Y(1:end-1), diff(X), diff(Y),'off')
hold off


Help Center および File Exchange2-D and 3-D Plots についてさらに検索




Community Treasure Hunt

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

Start Hunting!

Translated by