Solving Complex Coupled Differential Equations

11 ビュー (過去 30 日間)
Shivesh
Shivesh 2014 年 11 月 6 日
コメント済み: Star Strider 2014 年 11 月 6 日
Hello,
My question is as follows. Say we have a set of coupled differential equations, such as
y'' = x' + y' + cos(y) and x'' = y'^2 + tan(y).
How would I go about implementing this with the regular ODE software? I understand how to solve coupled differential equations, and normal ODEs, but I've never had to deal with coupled differential equations with derivatives on both side.
Cheers

採用された回答

Star Strider
Star Strider 2014 年 11 月 6 日
These are relatively straightforward. To use the ODE solvers however, they have to use the same variable, that requires that you keep track of what is x and what is y:
couplode = @(t,y) [y(2); y(4)^2 + tan(y(3)); y(4); cos(y(3)) + y(2) + y(4)];
[t,y] = ode45(couplode, [0 0.49*pi], [1;1;1;1]*1E-8);
figure(1)
plot(t, y)
grid
str = {'$$ \dot{y} $$', '$$ y $$', '$$ \dot{x} $$', '$$ x $$'};
legend(str, 'Interpreter','latex', 'Location','NW')
produces this interesting plot:
  1 件のコメント
Mohammad Abouali
Mohammad Abouali 2014 年 11 月 6 日
why y and \dot{y} graph don't match? Clearly y is decreasing at some point so \dot{y} should be negative but it is always positive?!

サインインしてコメントする。

その他の回答 (1 件)

Torsten
Torsten 2014 年 11 月 6 日
I guess the legend is wrong.
Shouldn't it read
str = {'$$ x $$', '$$ \dot{x} $$', '$$ y $$', '$$ \dot{y} $$'};
?
Best wishes
Torsten.
  1 件のコメント
Star Strider
Star Strider 2014 年 11 月 6 日
Correct. I reversed the legend accidentally after looking through the LaTeX documentation.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by