% linpend.m - ODEs for a linearized (damped) pendulum
% RMM, 17 Jul 06
%
% This function gives the dynamics for a (nominally undamped),
% linearized pendulum.  The states 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
%
% The dynamics should match the dynamics of the inverted pendulum, 
% linearized around the inverted position.

function dx=linpend(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*x(1)];
