using ODE45 with condition

3 次查看(过去 30 天)
February
February 2015-3-3
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.

回答(1 个)

Andrew Newell
Andrew Newell 2015-3-3
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).

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by