Animate the motion plot

1 次查看(过去 30 天)
Abhishek Tyagi
Abhishek Tyagi 2021-4-15
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.

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by