Animating crank mechanism for loop troubles

When animating my slider crank, it plots an abundance of lines every increment through the loop. Is there a simple way to solve this? Thanks
%Create lengths for the slider crank
b = 3;
14 == 6;
15 == 26;
%Create for loop for the animation
for k = 0:0.1:4*pi
%Use input equations to get angles theta 11 and 12
th1 = +(acos((1/15)*sqrt((15)^2-(b+14*sin(k))^2)));
hold on
%Plot the crank arm
plot([0 14*cos(k)],[0 14*sin(k)],'o-','linewidth',3);
%Plot the second arm
plot([-35 35],[-5 5],'-','linewidth',3);
%Plot third arm
plot([14*cos(k) 14*cos(k)+15*cos(th1)],[14*sin(k) -b],'o-','linewidth',3);
hold off
%Create axis and pause for animation
axis([-35 35 -8 8]);
pause(0.1)
end

Réponses (1)

darova
darova le 23 Jan 2020
Use this algorithm
hold on
for i = 1:n
h(1) = plot();
h(2) = plot();
pause(0.1)
delete(h)
end
hold off

Catégories

En savoir plus sur Animation dans Centre d'aide et File Exchange

Produits

Version

R2019b

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by