Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: ODEs taking variables below 0
Posted:
Mar 28, 2013 4:10 PM


"Matthew" wrote in message <kj1sea$ab6$1@newscl01ah.mathworks.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)



