Animate the motion plot

3 views (last 30 days)
Abhishek Tyagi
Abhishek Tyagi on 15 Apr 2021
Edited: Abhishek Tyagi on 16 Apr 2021
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 Comment
Abhishek Tyagi
Abhishek Tyagi on 16 Apr 2021
Please help me to solve this problem its really important

Sign in to comment.

Answers (1)

Ahmed Redissi
Ahmed Redissi on 15 Apr 2021
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.

Categories

Find more on Animation in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!