How to Solve Second Order ODE with 2 dependent variables
조회 수: 8 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (2개)
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
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
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;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!