function pendsets(time,ud,u)
%PENDSETS Animation for the inverted pendulum demo.
%       PENDSETS(TIME,UD,U) uses set to position the graphic objects 
%       for the inverted pendulum demo. UD contains a vector
%       of handles [Cart Pend TimeField SlideControl RefMark].
%
%       See also: PENDAN (.M and .C), PENDDEMO, and PEND0.

%	Copyright (c) 1990-94 by The MathWorks, Inc.

XDelta = 2;
PDelta = 0.2;
XPendTop = u(2) + 10*sin(u(3));
YPendTop = 10*cos(u(3));
PDcosT = PDelta*cos(u(3));
PDsinT = -PDelta*sin(u(3));
set(ud(1),'XData',ones(2,1)*[u(2)-XDelta u(2)+XDelta]);
set(ud(2),'XData', ...
    [XPendTop-PDcosT XPendTop+PDcosT; u(2)-PDcosT u(2)+PDcosT], ...
    'YData',[YPendTop-PDsinT YPendTop+PDsinT; -PDsinT PDsinT]);
set(ud(3),'String',num2str(time));
set(ud(5),'XData',u(1)+[-XDelta 0 XDelta]);

% Force plot to be drawn
pause(0)
drawnow

% end pendsets
