MATLAB 中的 ode 求解器事件位置索引
假设我尝试使用 MATLAB 中的ode
求解器求解微分方程组。
还假设我定义了一个事件函数来定位三个不同的事件,这些事件都是终端事件。
我注意到,在某些情况下,在某个事件的位置返回的 ie 数量(ie 是停止求解器的事件的索引,在我的例如,它可能是 1、2 或 3)并不总是单个数字,而是具有两个元素的向量(通常这些元素是相同的)
在 ie
不是标量的情况下,它是 即(1)
或ie(2)
停止了求解器?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,我注意到,当模拟因终端事件而停止,然后从停止的同一点(初始时间和条件)再次开始时,就会发生这种情况。
从技术上讲,由于初始条件中的算术不准确,MATLAB 会重新检测导致其先前停止的同一事件。 MATLAB 无法区分这一点,但它被编程为不会在第一个成功步骤之后发生的终端事件中停止(请参阅
odezero
函数以供参考)。但它确实记录了该事件。因此,下次颂歌因终端事件而停止时,
ie
会附加新索引,这就是ie
的时间(以及原因) code> 是一个具有两个元素的向量。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.