% invpend.m - ODEs for a simple inverted pendulum
% RMM, 11 Oct 03
%
% This function gives the dynamics for a (nominally undamped) pendulum
% of the system are
%
%   x(1)	angle
%   x(2)	velocity
%
% The default parameters for the system are given by
%
%   m = 1	mass, kg
%   l = 1	length of pendulum, m
%   b = 0	damping coefficient, kg/sec
%   g = 9.8	gravitational constant
%

function dx=pendulum(t, x, flags, m, l, b, g)
if (nargin < 4) m = 1; end;
if (nargin < 5) l = 1; end;
if (nargin < 6) b = 0; end;
if (nargin < 7) g = 9.8; end;

dx=[x(2); -b/m*x(2) + g*l/m*sin(x(1))];

