function [out1, out2, out3] = test(t,y,flag,gamma,q,Q,c,s,d,m,D,P0,tauC,dosage,frequency,r)
%
%y=z.*(z>0);
%
H=y(1)*(y(1)>0);
T=y(2)*(y(2)>0);
V=y(3)*(y(3)>0);
E=y(4)*(y(4)>0);
P=y(5)*(y(5)>0);
%
dE=d(4);
%
brateT=1*T*(1-T);
drateT=Holling2(T,1,.5)*E;
%
brateE=Holling2(T,1,.5)*E;
drateE=.6*E;
if nargin < 3 | isempty(flag)
   out1 = [0;
      (brateT-drateT)/.5;
      0;
      (brateE-drateE);
      0];
else
   switch(flag)
   case 'init'
     out1 = [0; 50];
     out2 = [.5,.5,.5,.5,.5];
     out3 = []; %odeset('Vectorized', 1);
     case 'events' 
     sec1 = P-P0/2;
     %sec2 = y(2)-.5;   
     out1 = [sec1];
     out2 = [0];
     out3 = [1];
   otherwise
      error(['Unknown flag ''' flag ''.']);
   end
end; 
