How to combine animations, add title and edit limits
Afficher commentaires plus anciens
Hello, how could i animate these 3 motions together as a smooth one? They seem to show up as different figures, once the one finishes animating the next one starts.
animate_pendulum(2*rd,tzd,(1.5*pi)-zd(:,1))
hold on
animate_pendulum(2*rm,tzm-tzm(1),(1.5*pi)-zm(:,1))
hold on
animate_pendulum(2*rc,tzc-tzc(1),(1.5*pi)-zc(:,1))
where
function animate_pendulum(L,t,thet)
% L = 1;
x = L*sin(thet);
y = -L*cos(thet);
figure
hold on
box on
axis square
set(gca,'XTick',[], 'YTick',[], ...
'XLim',[-1,+1]*1.1, 'YLim',[-1,+1]*1.1)
plh_bar = plot([0,x(1)],[0,y(1)],'-k','LineWidth',2); % Pendulum arm
plh_bob = plot(x(1),y(1),'.k','MarkerSize',30); % Pendulum bob
plot(0,-0.045,'^r','MarkerSize',10,'MarkerEdgeColor','red','MarkerFaceColor',[1 .6 .6]) % Pivot
drawnow
tic
while toc < t(end)
[~,idx] = min(abs(t - toc));
set(plh_bar,'XData',[0,x(idx)],'YData',[0,y(idx)])
set(plh_bob,'XData',x(idx),'YData',y(idx))
drawnow
end
set(plh_bar,'XData',[0,x(end)],'YData',[0,y(end)])
set(plh_bob,'XData',x(end),'YData',y(end))
drawnow
Also I want to add the following but dont know where:
ylimits=[-0.3,1.3];
ylim(ylimits)
xlimits=[-1.3,1.3];
xlim(xlimits)
title('ROOF MOTION REPRESENTATION','RETRACTION')
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Animation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!