function [value, isterminal,direction] = caught(t,y,h) % This function is used by timeToDeath_2 % It tells the ODE solver to stop computing once the % human has been caught by the raptor (this is "the event"). % % This requires an additional input, h(t), which is the human's % path. See timeToDeath_2 for how to deal with this isterminal = 1; % Note: the following line is BAD because we need a double, not a logical: % isterminal = true; % Don't worry about this much: direction = 0; % This is the event. We make it a double, not a logical: value = double( norm(h(t) - [y(1),y(2)] ) < .09);