%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%Locate the time when cdot and/or kdot <= zero                     %
%                                                                  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function [value,isterminal,direction] = events(t,y)

global sigma rho delta alpha

    dct=1/sigma*y(1)*(alpha*y(2)^(alpha-1)-rho-delta); %cdot
    dkt=y(2)^alpha-delta*y(2)-y(1);                    %kdot

value = [dct,dkt];     
isterminal = [1,1];   
direction = [0,0];  
