How to plot a line given a point and a direction

If you are given the vector equation of a line with point P0 = [0:0] and direction vector v = [0:1] how do you plot this line in Matlab?

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 1 月 25 日

1 投票

P1 = P0 + v;
Then if you do not need an arrowhead,
plot([P0(1), P1(1)], [P0(2), P1(2)])
If you do need an arrowhead then see https://www.mathworks.com/matlabcentral/fileexchange/278-arrow. You could also use annotation('arrow') but annotations use figure coordinates rather than being relative to the plot.

カテゴリ

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

タグ

質問済み:

2018 年 1 月 25 日

回答済み:

2018 年 1 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by