using ODE45 with condition
조회 수: 4 (최근 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개)
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).
댓글 수: 0
참고 항목
카테고리
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!