简体   繁体   English

使用 Octave/Matlab 求解带有嵌入式非微分方程的微分方程组(见图)

[英]Solve system of differential equation with embedded non diferential equations, using Octave/Matlab (see picture)

I have the following equation system (click to see picture) , and would like to solve for X(t), Y(t), Z(t), hopefully using Octave/Matlab, which I'm familiar with, but I would not mind solving it by any other means necessary.我有以下方程组(点击查看图片) ,并想求解 X(t)、Y(t)、Z(t),希望使用我熟悉的 Octave/Matlab,但我会不介意通过任何其他必要的方式解决它。

Now, Fsolve is useful for regular equation systems, and Ode45, Lsode are useful for differential equations.现在,Fsolve 可用于正则方程系统,而 Ode45、Lsode 可用于微分方程。 But, what about this particular system?但是,这个特定的系统呢? Note that the differential equation at the bottom contains not only Y, but, also, both X and Z, and those are dependent on the two non-differential equations above.请注意,底部的微分方程不仅包含 Y,而且还包含 X 和 Z,它们依赖于上面的两个非微分方程。

To be honest, I'm not quite sure how to approach a basic code to solve this system, and after spending some time thinking, I decided to ask for help.老实说,我不太确定如何接近解决这个系统的基本代码,经过一段时间的思考,我决定寻求帮助。 I really appreciate any guidance to solve this problem somewhat efficiently, if it is even possible.如果有可能的话,我真的很感谢任何能稍微有效地解决这个问题的指导。 Almost any reply would be of some use to me right now.现在,几乎任何回复都会对我有用。

If you know y , you can solve for x , and this even unconditionally as the second equation in monotonous in x如果你知道y ,你可以解出x ,这甚至可以无条件地作为x中单调的第二个方程

x = fsolve(@(x) y^2-1413.7*x-1095.2*cos(x)+2169, 0)

Then once you know x , you can solve for z using the known inverse cosine然后一旦你知道x ,你就可以使用已知的反余弦求解z

z = acos(0.20978-cos(x))

This may actually fail to give a result if cos(x) comes close to -1 .如果cos(x)接近-1这实际上可能无法给出结果。 One can artificially cut out that error, introducing a possibly wrong solution可以人为地消除该错误,引入可能错误的解决方案

z = acos(min(1,0.20978-cos(x)))

For simplicity, assemble these operations in a helper function为简单起见,将这些操作组合在一个辅助函数中

function [x,z] = solve_xz(y)
    x = fsolve(@(x) y^2-1413.7*x-1095.2*cos(x)+2169, 0);
    z = acos(min(1,0.20978-cos(x)));
end

Now use that to get the ODE for y现在使用它来获取y的 ODE

function dy = ode_y(t,y)
    [x,z] = solve_xz(y(1));
    dy = [ y(2); y(3); 6666.6667*(z-x)-333.3333*y(1)-33.3333*y(2)-5*y(3) ];
end

and apply the ODE solver of your choice.并应用您选择的 ODE 求解器。 It is quite likely that the system is stiff, so ode45 might not be the best solver.系统很可能是刚性的,因此ode45可能不是最好的求解器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM