MATLAB中的ode求解器事件位置索引 [英] ode solver event location index in MATLAB

查看:763
本文介绍了MATLAB中的ode求解器事件位置索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我试图在MATLAB中使用 ode 求解器来求解微分方程组。

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.

我注意到在某些情况下 ie 在其中一个事件的位置返回的数量( ie 是停止求解器的事件的索引,在我的情况下它可能是1 ,2或3)并不总是单个数字,而是具有两个元素的向量(通常这些元素是相同的)

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)

在那些的情况下,即不是标量,是即(1)即(2)停止了求解器?

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

推荐答案

实际上,我注意到当模拟由于终端事件而停止然后再从停止的相同点(初始时间和条件)。

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.

从技术上讲,由于算术运算初始条件下的准确性MATLAB重新检测到之前停止的相同事件。 MATLAB无法区分这一点,但它被编程为不停止在第一个成功步骤之后发生的终端事件中(参见 odezero 函数参考)。但它确实记录了这个事件。

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.

这篇关于MATLAB中的ode求解器事件位置索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆