フィルターのクリア

Make a point move to a destination coordinate

3 ビュー (過去 30 日間)
aasha verghese
aasha verghese 2022 年 4 月 20 日
編集済み: Davide Masiello 2022 年 4 月 21 日
Hi,
I have the source coordinates (x,y) and destination coordinates (DX,DY). I want to animate a point move from source to destination. There is no graph used. Can anyone please help.

採用された回答

Davide Masiello
Davide Masiello 2022 年 4 月 20 日
編集済み: Davide Masiello 2022 年 4 月 21 日
I am not sure what you mean when you say "there is no graph used", but maybe something like the exa,ple below might help.
clear,clc
x0 = [20 150]; % x coordinates of source and destination
y0 = [30 100]; % y coordinates of source and destination
slope = diff(y0)/diff(x0);
x = linspace(20,150,500);
y = slope*(x-x0(1))+y0(1);
figure(1)
for i = 1:length(x)
plot(x(i),y(i),'ok','MarkerFaceColor','r')
axis([10 160 20 110])
drawnow
end
  2 件のコメント
Aasha M V
Aasha M V 2022 年 4 月 20 日
Thank you. I have only 2 points coordinates (20,30) which is to be moved to (150,100). These coordinates are predefined. Can you help a bit more with this?
Davide Masiello
Davide Masiello 2022 年 4 月 21 日
HI @Aasha M V, I have edited the code above according to your specific case. Note that it'd be difficult to clearly see the animation, since it's only 2 points and it happens quite fast. Therefore, I made the point move more smoothly by defining more points lying on the straight line between your source and your destination.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by