MATLAB 中的 ode 求解器事件位置索引

发布于 2024-12-07 17:15:28 字数 286 浏览 6 评论 0原文

假设我尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酸甜透明夹心 2024-12-14 17:15:29

实际上,我注意到,当模拟因终端事件而停止,然后从停止的同一点(初始时间和条件)再次开始时,就会发生这种情况。

从技术上讲,由于初始条件中的算术不准确,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文