Animate the motion plot

조회 수: 22(최근 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.

댓글을 달려면 로그인하십시오.

범주

Find more on Animation in Help Center and File Exchange

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by