function out = ex14ode(t,y,flag)

% Copyright 1999, The MathWorks, Inc.

global INDEX

if nargin < 3 | isempty(flag)
  yp = zeros(5,1);
  yp(1) =   y(3);
  yp(2) =   y(4);
  yp(3) = - y(1)*y(5);
  yp(4) = - y(2)*y(5) - 1;
  if INDEX == 2
    yp(5) = y(1)*y(3) + y(2)*y(4);
  else
    yp(5) = y(1)^2 + y(2)^2 - 1;
  end
  out = yp;
else
  switch(flag)           
  case 'mass'
    out = diag([1 1 1 1 0]);
  otherwise
    error(['Unknown flag ''' flag '''.']);
  end
end
