ode solver event location index in MATLAB

瘦欲@ 提交于 2019-12-24 01:53:41

问题


Suppose I am trying to solve a system of differential equations using an ode solver in MATLAB.

Suppose also that I have defined an events functions to locate three different events which are all terminal.

I have noticed that on some occasions the ie quantity that is returned upon the location of one of the events (ie is the index of the event that stopped the solver, in my case it could be 1, 2 or 3) is not always a single number but a vector with two elements (usually these elements are identical)

In those cases that ie is NOT scalar, is it ie(1) or ie(2) that stopped the solver?


回答1:


Actually, I noticed that this happens when the simulation stops due to a terminal event and then starts again from the same point (initial time and conditions) that stopped.

Technically, due to arithmetic inaccuracies in the initial conditions MATLAB re-detects the same event that made it previously stop. MATLAB is incapable of distinguishing this, BUT it is programmed NOT to stop in terminal events that occur just after the first successful step (see odezero function for reference). It does record the event, though.

Consequently, the next time that the ode stops due to a terminal event, the ie is appended with the new index and that's when (and why) ie is a vector with two elements.



来源:https://stackoverflow.com/questions/7621664/ode-solver-event-location-index-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!