How to Solve Second Order ODE with 2 dependent variables

34 ビュー (過去 30 日間)
Yanuar Rizki Pahlevi
Yanuar Rizki Pahlevi 2021 年 1 月 14 日
回答済み: Ariadna 2022 年 5 月 5 日
Hi guys, I am trying to solve this second order ODE, I followed this step
diff(x,2)== diff(x)-y
Vx=odeToVectorField(diff(x,2)== diff(x)-y)
[Y[2]; Y[2] - y(t)] %result from odeToVectorField
diff(y,2)== diff(y)-x
Vy=odeToVectorField(diff(x,2)== diff(x)-y)
[[Y[2]; Y[2] - x(t)]] %result from odeToVectorField
i tried using odeToVectorField to make it in first order and got 2 vectors. but then I dont understand how to make this to work since on the vector from first DE, there is variable y(t) which always updated during calculation.. it also happened for vector from second DE..
I tried using this step
by creating
ode1=diff(x1)==x2;
ode2=diff(x2)==diff(x1)-y1
ode3=diff(y1)==y2
ode4=diff(y2)==diff(y1)-x1
odes1=[ode1;ode2]
odes2=[ode3;ode4]
but dsolve did not work for this.

回答 (2 件)

Divija Aleti
Divija Aleti 2021 年 1 月 20 日
Hi Yanuar,
Two second order ODE's can directly be solved by using 'dsolve'. Have a look at the following code:
syms x(t) y(t)
ode1 = diff(x,2)==diff(x)-y;
ode2 = diff(y,2)==diff(y)-x;
odes = [ode1;ode2];
S = dsolve(odes)
S.x
S.y
Another method would be to convert the two second order ODEs into four first order ODEs and then solve using dsolve.
Let x1 = x, y1 = y
dx1/dt = x2, dy1/dt = y2
dx2/dt = x2 - y1, dy2/dt = y2 - x1
syms x1(t) x2(t) y1(t) y2(t)
ode1=diff(x1)==x2;
ode2=diff(x2)==x2-y1;
ode3=diff(y1)==y2;
ode4=diff(y2)==y2-x1;
odes=[ode1;ode2;ode3;ode4];
S = dsolve(odes);
S.x1 % As x1 = x
S.y1 % As y1 = y
Output:
  1 件のコメント
Zein alabdeen shreify
Zein alabdeen shreify 2021 年 7 月 9 日
1) how can I extract the results from this?
2) if I have functions, how can I input the? they are differential functions

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


Ariadna
Ariadna 2022 年 5 月 5 日
It tried to solve this equation using this method and I didn't obtain results.
Does someone knows how to solve this system?
e=0.01
n=0.7
syms x1(t) x2(t)
dx1 = diff(x1) == x1*x2*(1-(x1+x2))-e*x1;
dx2 = diff(x2) == n*x1*x2*(1-(x1+x2))-e*x1;

カテゴリ

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

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by