Animate the motion plot

5 ビュー (過去 30 日間)
Abhishek Tyagi
Abhishek Tyagi 2021 年 4 月 15 日
編集済み: Abhishek Tyagi 2021 年 4 月 16 日
Help me to solve this problem? i am trying using plot function but did'nt get required result.
1.1. Write MATLAB Script to animate the motion of the rolling disk for two
complete rotations, showing (as a trace) the trajectory of the point on the rim.
Take: radius of the disk equal to 10 units, radius of the point is also equal to 10
units. An example is presented below.
1.2 Produce a static plot for your system, showing the rim point's speed
using the "quiver" command. An example is presented below.
enter code here r=10;y=10;
figure
t=0:pi/64/pi;
th = 0:pi/50:2*pi;
yline(0)
hold on
for x=-128:4:0
xp=r*cos(th)+x;
yp=r*sin(th)+y;
plot(xp,yp)
end
axis([-140 10 -40 60])
set(gca,'xtick',[-120:20:0])
set(gca,'ytick',[-50:10:70])
hold off`
i have done till here but i am not getting how to plot points to show trace.
[Look at the image for better understanding of question]
  1 件のコメント
Abhishek Tyagi
Abhishek Tyagi 2021 年 4 月 16 日
Please help me to solve this problem its really important

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

回答 (1 件)

Ahmed Redissi
Ahmed Redissi 2021 年 4 月 15 日
Here's an example that can help you create an animation:
% Create the trajectory
xtrajectory = linspace(-5,5);
ytrajectory = -(xtrajectory.^2)+25;
% Plot the trajectory
plot(xtrajectory,ytrajectory);
axis([-8 8 -2 28]);
grid;
hold on
% Create the disk
anglesdeg = 0:2.5:360;
angles = deg2rad(anglesdeg);
R = 1;
xdisk = R*cos(angles);
ydisk = R*sin(angles);
for i = 1:numel(ytrajectory)
% Plot the disk
x = xdisk+xtrajectory(i);
y = ydisk+ytrajectory(i);
p = plot(x,y,'b');
% Pause to create the animation effect
pause(0.1);
% Delete the disk after it was plotted
if i~=numel(ytrajectory)
delete(p);
end
end
hold off
Try to use this concept to create your animation.
  1 件のコメント
Abhishek Tyagi
Abhishek Tyagi 2021 年 4 月 16 日
I think this concept is different.

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

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by