function [out1, out2, out3] = threeDmodelunstmfdsearch(t,x,flag,param)
%
% 

a=param(1);
eps=param(2);
gamma=param(3);
c=param(4);

v=x(1);u=x(2);w=x(3);

f=v.*(v-a).*(1-v);
scl=1;
if nargin < 3 || isempty(flag)
out1 = [u; 
        c*u/scl-f+w;
        scl*eps*(v-gamma*w)/c];
else
   switch(flag)
   case 'init'
     out1 = [0; 50];
     out2 = [0 0 0];
     out3 = []; %odeset('Vectorized', 1);
     case 'events' 
     sec1 = u+.25; 
     sec2 = u-.25;
     %sec3 = w-.015;
     out1 = [sec1, sec2];
     out2 = [1,1];
     out3 = [-1,1];
   otherwise
      error(['Unknown flag ''' flag ''.']);
   end
end; 
