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).
using ODE45 with condition
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!