% oscillator.m - ODEs for a 2D oscillator
% RMM, 11 Oct 03
%
% This function gives the dynamics for a damped oscillator.  The states
% of the system are
%
%   x(1)	position
%   x(2)	velocity
%
% The default parameters for the system are given by
%
%   m = 1	mass, kg
%   k = 1	spring constant, N/m
%   b = 1	damping constant, N-sec/m
%
% This corresponds to a fairly heavily damped oscillator.

function dx=oscillator(t, x, flags, m, b, k)
if (nargin < 4) m = 1; end;
if (nargin < 5) b = 1; end;
if (nargin < 6) k = 1; end;

dx=[x(2); -k/m*x(1) - b/m*x(2)];

