You are on page 1of 1

L=1;

g=9.81;
f=@(t,x) [x(2);-(g/L)*sin(x(1))];
[t,u]=ode45(f,[0,10],[pi/4,0]);

O=[0 0];
axis(gca,'equal');
axis([-1 1 -1.2 0]);
grid on;

n=length(t);

for i=1:n

P=L*[sin(u(i,1)) -cos(u(i,1))];

X = viscircles(O,0.01);

Y = line([O(1) P(1)],[O(2) P(2)]);

Z = viscircles(P,0.05);

pause(0.09)

if i<n
delete(X)
delete(Y)
delete(Z)
end
end

You might also like