How can i solve these ODEs?

조회 수: 2 (최근 30일)
Volkan Yangin
Volkan Yangin 2020년 11월 6일
댓글: Ameer Hamza 2020년 11월 6일
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에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by