using ODE45 with condition
3 views (last 30 days)
Show older comments
The problem I am dealing with is a circuit with diode. so I have two different differential equations to solve based on a variable value measured at each time step. what I want to achieve is to run first ode45 and calculate a variable value (different from output) and if that value < threshold, continue running first ode45. Otherwise, run 2nd ode45. same with 2nd ode45.
so I guess what I want to do is having two different "states" (1st ode45 and 2nd ode45) and which to run is determined by the current variable value. how can I achieve this? how can I make ode45 evaluate a value at each time step other than output?
thank you.
0 Comments
Answers (1)
Andrew Newell
on 3 Mar 2015
You can use event location to run ode45 on one equation until you reach the threshold, at which point the solver stops. Then you'd call ode45 again to solve the other equation, starting where you left off (see the link for examples).
0 Comments
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!