% balpend.m - ODEs for a balanced inverted pendulum
% RMM, 11 Oct 03
%
% This function gives the dynamics for a balanced inverted pendulum in
% normalized coordinates
%
%   x(1)	scaled angle
%   x(2)	scaled velocity
%

function dx=balpend(t, x, flags, a)

% Control law
u = -2 * a * sin(x(1)) - x(2) * cos(x(1));

dx=[x(2); sin(x(1)) + u*cos(x(1))];

