function [gstop,isterminal,direction]=g(t,y,a)
gstop=y(1)-a(2);     %Measures when y(1)=Initial population
isterminal=0;   %Should the solver stop? 0 means no
direction=-1;   %What direction should the function be going for event finder to look for y(1)=0?
