I would call the ODE solver three times.
First, solve over the time span [0, 20].
Next, use the final value from that first ODE solver call as the initial condition for the second call that solves over the time span [20, 40].
Third, do the same as the second call but for the time span [40, your_end_time].
If you don't know when the changes will occur but have some way to detect when they should occur, use an events function. See the ballode example for an illustration of this technique.
0 Comments
Sign in to comment.