I'm having trouble with an ODE45 model I am building and the event function used to terminate the integration. The event function I am using detects a zero crossing (positive direction) to terminate the solver then another function modifies the ode and I'm feeding the end state from the first run into another ode45 call as the initial conditions (similar to ballode example except instead of modifying the initial conditions I am modifying ode).
The first termination occurs correctly but then I am getting a second termination during the subsequent run. The output reports the same event index (ie) as the first run. When I manually run the event function with the terminated state I am finding that the value of the flagged event is not zero.
How can the solver stop and report an event with an event value that is much less than zero?
Any thoughts?
Best Answer