How can i solve these ODEs?

1 次查看(过去 30 天)
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)

采纳的回答

Ameer Hamza
Ameer Hamza 2020-11-6
编辑:Ameer Hamza 2020-11-6
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 个评论
Volkan Yangin
Volkan Yangin 2020-11-6
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 2020-11-6
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];

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by