How to create animation ?

1 visualizzazione (ultimi 30 giorni)
Kiran HR
Kiran HR il 22 Dic 2018
Risposto: Image Analyst il 22 Dic 2018
I have written a code to solve differential equation of a simple pendulum. I tried creating animation of the same. But I am not getting properly. Please correct me.
clear all
close all
clc
%let theeta=y
L=1;
t=[0 20];
yo=[0 3];
[t,y]=ode45('simplependulum',t,yo)
figure(1)
plot(t,y(:,1))
xlabel('time')
ylabel('displacement')
figure(2)
plot(t,y(:,2))
xlabel('time')
ylabel('angular velocity')
O=[0 0];
axis(gca,'equal');
axis([-0.7 0.7 -0.7 0.2]);
grid on;
figure(3)
for i=1:length(t)
P=L*[sin(y(i,1)) -cos(y(i,1))]
O_circle=viscircles(O,0.01);
pend=line([O(1) P(1)],[O(2) P(2)]);
ball=viscircles(P,0.05);
pause(0.001);
if i<length(t)
delete(pend);
delete(ball);
delete(O_circle);
end
end

Risposte (1)

Image Analyst
Image Analyst il 22 Dic 2018
See attached demo where I make a movie from different frames of surf() - the surface is changing in time.

Categorie

Scopri di più su Animation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by