% how to show an animation for the pendulum 
f =                                 % ENTER FUNCTION f HERE !!! 
a = 4;                              % enter value of a here!
[ts,ys] = ode45(f,0:.01:150,[0;a]); % use ts = [0 .01 .02 ... 150]
                                    % (need fixed step size for animation)
figure(1)
set(gcf,'DoubleBuffer','on');
h1 = plot([0 0],[0,-1],'o-','MarkerSize',20);
axis equal;  axis(1.1*[-1 1 -1 1]); 

for i=1:length(ts)
  theta = ys(i,1);
  set(h1,'Xdata',[0,sin(theta)],'Ydata',[0,-cos(theta)]);
  drawnow;
  pause(.001);
end
