function []=pendplot(t,y)
h=figure(2);
set(2,'Position', [100 450 400 420]) % args 1,2: (x,y) for bottom l.h.corner
                                     % args 3,4: width and height of figure
clf
set(h,'doublebuffer','on');
r=1;
raxis=r*1.2;
[mrows,mcols]=size(y);
spacing=0:.01:1;
jump=floor(mcols/100);         % floor takes integer part
for jj=1:jump:mcols
  time=t(jj);
  theta=y(1,jj);             % the dependent variable is the angle 
  xx=r*sin(theta);             % theta is angle to vertical
  yy=-r*cos(theta);
  xpos=spacing*xx;
  ypos=spacing*yy;
  plot(xpos,ypos,'LineWidth',2)
  hold on
  plot(xx,yy,'o','LineWidth',2)
  hold off
  set(gca,'FontName','Helvetica','FontSize',16)      % large font
  axis([-raxis raxis -raxis raxis])
  axis('square')
  pause(0.01)                  % to ensure each frame is displayed
end
figure(1)
