フィルターのクリア

plotting a moving object

8 ビュー (過去 30 日間)
Shamsuddeen Abdullahi
Shamsuddeen Abdullahi 2019 年 9 月 28 日
I want to plot the movement or path of a car moving with a velocity,v, from a point (x0,y0) to (x1,y1).
I used the following codes but not getting what I want.
(x0,y0)=(0,0)
(x1,y1).=(15,8)
v=1;
px=0;
py=0
t=0.1; % time increament to indicates when the locatio of the car should change
dist=0
for i=1:1:x1
dist(i)= sqrt( (x0-(t.*v)).^2 + (y0-(t.*v)).^2)
figure (1)
plot(t, dist(i), px, py)
pause (0.5)
px=px+i
py=py+i
end
pls help.
  2 件のコメント
darova
darova 2019 年 9 月 28 日
I think something os wrong with your code
12Untitled.png
darova
darova 2019 年 9 月 28 日
I think t variable should changes in while loop. Time flies you know

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

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 9 月 28 日
編集済み: KALYAN ACHARJYA 2019 年 9 月 28 日
Is this?
x0=0;y0=0;
x1=15;y1=8;
v=1;
px=0;
py=0;
t=0.1;
dist=0;
for i=1:1:x1
dist(i)=sqrt((x0-(t.*v)).^2 +(y0-(t.*v)).^2)
figure (1), plot(t,dist(i), px, py);
pause(0.5);
px=px+i;
py=py+i;
end
  1 件のコメント
Shamsuddeen Abdullahi
Shamsuddeen Abdullahi 2019 年 9 月 28 日
yes

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

カテゴリ

Help Center および File ExchangeTwo y-axis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by