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)
댓글 수: 0
채택된 답변
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
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 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!