"Matthew" wrote in message <email@example.com>... > I have my event stopping at the right place but it wont just cap the variable and continue. > > Heres what I have: > > function [value,isterminal,direction] = events(t, z,design) > value = [xend - z(3); (xend + z(3)]; > isterminal = [0; 1]; > direction = [0; 0]; > end > > I don't understand what direction does? Terminal simply stops the integration if its a 1 and lets its keep on running if its a 0. I want it to stop integrating if its going past that.
The direction lets you specify whether the function was increasing when it crossed the threshold or decreasing, or if it doesn't matter.
if direction is zero it will always raise an event when crossing the threshold
if direction is +1 it will only create an event if the threshold is crossed from below (i.e. the function is increasing)
if direction is -1 it will only create an event if the threshold is crossed from above (i.e. the function is decreasing)