function dpanim(th1,th2)
% dpanim(th1,th2)
%   animate double pendulum
% th1 is vector with values of theta1
% th2 is vector with values of theta2

figure(2)
set(gcf,'DoubleBuffer','on');
  
h1=plot([0 0 0],[0 1 2],'o-');
axis equal; axis(2.1*[-1 1 -1 1]); 

for i=1:length(th1)
  x1 =  sin(th1(i));  x2 =  sin(th2(i));
  y1 = -cos(th1(i));  y2 = -cos(th2(i));
  set(h1,'Xdata',[0 x1 x1+x2],'Ydata',[0 y1 y1+y2]);
  drawnow;
  % pause(.0001);
end
