How do i make two dots, that are going in different direction in a vertical line, crash and then go to different directions?

2 ビュー (過去 30 日間)
N/A
N/A 2016 年 4 月 20 日
回答済み: Arnab Sen 2016 年 4 月 27 日
This is my code for dot going 1 unit in a vertical line, but how do i make o dots crash?
dt = .01; v=1 t = 0:dt:1; x = v*t
plot([0 1], [0 0], 'r'); hold on h1 = plot(x(1), 'k*'); %handle for i = 1:length(t) set(h1, 'xdata', x(i)) drawnow pause(0.01) end

回答 (1 件)

Arnab Sen
Arnab Sen 2016 年 4 月 27 日
Hi Sebastian,
The following script might address you requirement where a horizontal and vertical moving points crossing each other.
dt = .01; v=1 ;t = 0:dt:1; x = v*t;
plot([1 0], [0 0], 'r');
hold on ;
h1 = plot(x(1), 'k*');
h2= plot(x(1), 'k*');
for i = 1:length(t)
set(h1,'xdata',x(i));
set(h1,'ydata',0.5);
set(h2,'xdata',0.5);
set(h2,'ydata',x(i));
drawnow;
pause(0.01);
end
Maximize the figure window full screen to view the full effect.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by