Animating crank mechanism for loop troubles

1 回表示 (過去 30 日間)
Parker Stevens
Parker Stevens 2020 年 1 月 23 日
回答済み: darova 2020 年 1 月 23 日
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

回答 (1 件)

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by