How to create an animation between 2 points

Hi! I want to make animation of a line between 2 points. Let's say point 1 is (0,0) and point 2 is (5,4). How can I create an animate line between them and plot the final point(b) in the plot as well?

 採用された回答

KSSV
KSSV 2021 年 5 月 10 日

0 投票

A = [0 0] ;
B = [5 4] ;
x = [A(1) B(1)] ;
y = [A(2) B(2)] ;
p = polyfit(x,y,1) ;
xi = linspace(x(1),x(2)) ;
yi = polyval(p,xi) ;
comet(xi,yi)
plot(x,y,'*r',xi,yi,'b')

3 件のコメント

Yu-Wei Tu
Yu-Wei Tu 2021 年 5 月 10 日
Thank you so much for the answer. Another quick question. Is it possible to fix origin point always in the middle so we can see which direction are we heading?
KSSV
KSSV 2021 年 5 月 10 日
Read about axis
Yu-Wei Tu
Yu-Wei Tu 2021 年 5 月 10 日
Solved! Thanks!

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

その他の回答 (0 件)

カテゴリ

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

製品

リリース

R2020b

タグ

質問済み:

2021 年 5 月 10 日

コメント済み:

2021 年 5 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by