NDSolve 函数中的常数值是否可以有两个取决于 NDSolve 函数输出的值?
我有一个 ODE 系统。其中一个 ODE 有一个常量参数,我想根据 ODE 解决方案之一在两个不同值之间进行更改。
例如,假设我有以下方程:
{
A'[x] == -q A[x]B[x],
B'[x] == q A[x]B[x] - g B[x],
C'[x] == g B[x]
}
现在,当 q
和 g
为常量值时,我可以使用 NDSolve 函数轻松求解它们。我想做的是改变 q
的值,以便当 B[x]
低于某一阈值时它有一个值,但当 B[x]
低于某一阈值时它的值会发生变化>B[x] 上升到该阈值以上。
我尝试过在 NDSolve
之外使用 If
语句和 Piecewise
函数,但我还没有设法让它工作。
I have a system of ODE's. One of the ODE's has a constant parameter which I want to alter between two different values depending on one of the ODE solutions.
So for example let's say that I have the following equations:
{
A'[x] == -q A[x]B[x],
B'[x] == q A[x]B[x] - g B[x],
C'[x] == g B[x]
}
Now I can solve them easily using the NDSolve function when q
and g
are constant values. What I want to do though is vary the value of q
so that it has one value when B[x]
is below a certain threshold but then changes in value when B[x]
rises above this threshold value.
I've tried using If
statements and Piecewise
functions outside of the NDSolve
but I haven't managed to get it working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能会做你想要的事情。我省略了第三个方程,它看起来是多余的。
This might do something like what you want. I left out the third equation, which seems superfluous.