How to use matlab to solve ordinary differential equations with coupled intermediate variables inside?

2 次查看(过去 30 天)
Dear all:
I have a problem which can be simplified to the statement below (the real equations and functions are much more complicated):
System: dot_X1 = -A*X1; dot_X2 = B*(X2-5) + u;
dot_ means differentiate with time t, X1 and X2 are system states respectively, A and B are both intermediate variables, u is the system control input which can be a ramp or step input defined by myself.
I know how to use ode to solve normal similar problems when A and B and not coupled, for example, when A and B are only functions of X1, X2 and u respectively. But now in my problem, A and B are coupled, like:
A = f(X1, X2, u, B), B = g(X1, X2, u, A), f and g are very complicated functions.
Now in every time interval when solving the ode problem, for example, [0s, 0.01s], I have to calculate both A and B in order to use ode function in matlab. But since A and B are coupled and f and g are very complicated, I don't know how to deal with this.
Could you give me some help? Thanks a lot!

回答(1 个)

Torsten
Torsten 2015-3-21
Add A and B as algebraic variables to your ODE system.
To determine A and B, add the equations
A-f(X1,X2,u,B)=0
B-g(X1,X2,u,A)=0
to your system.
Then you solve for four unknowns: A,B,X1,X2.
Before calling the ODE integrator, define the mass matrix M as
M=[1 0 0 0
0 1 0 0
0 0 0 0
0 0 0 0].
Best wishes
Torsten.
  2 个评论
Tao
Tao 2015-3-21
Hi, Torsten:
Actually my A and B are twisted together and the function f and function g are implicit, which means I cannot write the equations A-f(X1,X2,u,B)=0 B-g(X1,X2,u,A)=0.
Torsten
Torsten 2015-3-23
But that's exactly the way you wrote your equations in your previous request...
I doesn't matter that it can not be explicitly solved for A and B - the ODE solvers are capable to solve for implicitly defined variables.
Best wishes
Torsten.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by