% A very simple example of a stiff system of ODEs.
%
% The function keeps track of how many times it has been called.
% When the count_readout_reset argument is used (regardless of its
% value), the count is returned and reset to zero.
%
% CCK 2009-Mar-01
function dqdt = stiffeq(q,t, count_readout_reset)

persistent count

if exist('count_readout_reset','var')
   % return the number of times stiffeq has been called
   % since the last time count_readout_reset was set.
   dqdt = count; 
   count = 0;
   return
end

count = count + 1;

dqdt(1) = 1000*q(2) - 1001*q(1);
dqdt(2) = 1000*q(1) - 1001*q(2);
