How can i solve these ODEs?

2 visualizaciones (últimos 30 días)
Volkan Yangin
Volkan Yangin el 6 de Nov. de 2020
Comentada: Ameer Hamza el 6 de Nov. de 2020
Hi,
I have two ODEs with 2 initial conditions. I have created code for this, but have a problem:
Why do i see X1 and X2 at the results? Results should include only t.
Thx!
clear all
clc
u=5
syms x1 x2
x1_dot=(1936*sin((3*atan((17263*u)/62500 - (10720323*x1)/156250000 + (594*atan((37881*x1)/625000 - (61*u)/250 + 427/6250))/(25*pi) - 120841/1562500))/2))/1025 - (1936*sin((3*atan((594*atan((4819*x1)/625000 - 427/6250))/(25*pi) - (1363777*x1)/156250000 + 120841/1562500))/2))/1025 - 10*x1 - 236/1025
x2_dot=(1077384*sin((3*atan((17263*u)/62500 - (10720323*x1)/156250000 + (594*atan((37881*x1)/625000 - (61*u)/250 + 427/6250))/(25*pi) - 120841/1562500))/2))/333125 - (955416*sin((3*atan((594*atan((4819*x1)/625000 - 427/6250))/(25*pi) - (1363777*x1)/156250000 + 120841/1562500))/2))/333125 - 4956/13325
syms x1_dot_sol(t) x2_dot_sol(t)
ode1=diff(x1_dot_sol)==x1_dot;
ode2=diff(x2_dot_sol)==x2_dot;
odes=[ode1; ode2]
cond1=x1_dot_sol(0)==10;
cond2=x2_dot_sol(0)==10
conds=[cond1; cond2]
[x1_dot_result x2_dot_result]=dsolve(odes,conds)

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 6 de Nov. de 2020
Editada: Ameer Hamza el 6 de Nov. de 2020
This is correct code for your ODEs
clc
syms x1(t) x2(t) u
x1_dot = diff(x1, t);
x2_dot = diff(x2, t);
ode1 = x1_dot == (1936*sin((3*atan((17263*u)/62500 - (10720323*x1)/156250000 + (594*atan((37881*x1)/625000 - (61*u)/250 + 427/6250))/(25*pi) - 120841/1562500))/2))/1025 - (1936*sin((3*atan((594*atan((4819*x1)/625000 - 427/6250))/(25*pi) - (1363777*x1)/156250000 + 120841/1562500))/2))/1025 - 10*x1 - 236/1025;
ode2 = x2_dot ==(1077384*sin((3*atan((17263*u)/62500 - (10720323*x1)/156250000 + (594*atan((37881*x1)/625000 - (61*u)/250 + 427/6250))/(25*pi) - 120841/1562500))/2))/333125 - (955416*sin((3*atan((594*atan((4819*x1)/625000 - 427/6250))/(25*pi) - (1363777*x1)/156250000 + 120841/1562500))/2))/333125 - 4956/13325;
odes=[ode1; ode2];
cond1=x1_dot(0)==10;
cond2=x2_dot(0)==10;
conds=[cond1; cond2];
[x1_dot_result, x2_dot_result] = dsolve(odes,conds)
However, MATLAB is unable to find a symbolic solution. The equation seems quite nonlinear and complex, and it is unlikely at an analytical solution exist. You can find a numerical solution using ode45().
  2 comentarios
Volkan Yangin
Volkan Yangin el 6 de Nov. de 2020
Thanks Ameer. It works!
But,
May we use ode1 and ode2 like i write in my question?
In my question, firstly i defined x1_dot and x2_dot as symbolic and after i used them in second syms group. Can we get your solution with my style?
Addtionally, can we make x1(0) and x2(0) equal to 10. Not x1_dot and x2_dot.
Ameer Hamza
Ameer Hamza el 6 de Nov. de 2020
In your code, you have defined, x1 and x1_dot_sol as two seperate variables and there is no relation between them. MATLAB will not know if one is derivative of the other. So that will not work.
Yes, you can use this initial condition
cond1=x1(0)==10;
cond2=x2(0)==10;
conds=[cond1; cond2];

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by