How to Solve Second Order ODE with 2 dependent variables
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Divija Aleti
le 20 Jan 2021
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 commentaire
Zein alabdeen shreify
le 9 Juil 2021
1) how can I extract the results from this?
2) if I have functions, how can I input the? they are differential functions
Ariadna
le 5 Mai 2022
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 commentaires
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!