Reputation: 261
I am using ode45 and want to stop integration by event function when the solution hits zero. What I need is event function to return ME a "flag" . That means whenever event sends a stop sign to ode45 to stop, this stop sign (whatever it is) is sent to me as well.
thanks
Upvotes: 0
Views: 652
Reputation: 13876
From the ode45
documentation:
[T,Y,TE,YE,IE] = solver(odefun,tspan,y0,options)
solves as above while also finding where functions of(t,y)
, called event functions, are zero. For each event function, you specify whether the integration is to terminate at a zero and whether the direction of the zero crossing matters. Do this by setting the'Events'
property to a function, e.g.,events
or@events
, and creating a function[value,isterminal,direction] = events(t,y)
. For the ith event function inevents
,
value(i)
is the value of the function.isterminal(i) = 1
, if the integration is to terminate at a zero of this event >function and 0 otherwise.direction(i) = 0
if all zeros are to be computed (the default),+1
if only the zeros where the event function increases, and-1
if only the zeros where the event function decreases.Corresponding entries in
TE
,YE
, andIE
return, respectively, the time at which an event occurs, the solution at the time of the event, and the indexi
of the event function that vanishes.
The event function is set through the options
argument, with the odeset
function
Upvotes: 1