How do I solve a system of nonlinear differential equations like the one below?

조회 수: 1 (최근 30일)
As seen below (ode1 ode2 ode3) are my equations and c_1 to c_9 are just some constants which will be later determined. Is there any way to solve this without numerical methods? Thank you!
syms x(t) y(t) z(t);
c_1 = 1
c_2 = 2
c_3 = 1
c_4 = 1
c_5 = 1
c_6 = 1
c_7 = 1
c_8 = 1
c_9 = 1
ode1 = diff(x,t) == c_1*(c_3-x) + c_2*(x-y);
ode2 = diff(y,t) == c_4*(x-y) - c_5*c_6*y*(1-z) + c_7*c_6*exp(c_8 - c_9*z);
ode3 = diff(z,t) == c_5*y*(1-z) - exp(c_8 - c_9*z);
odes = [ode1; ode2; ode3]
cond1 = y(0) == 0;
cond2 = x(0) == 0;
cond3 = z(0) == 0;
conds = [cond1 cond2 cond3];

채택된 답변

Star Strider
Star Strider 2021년 3월 18일
Add t and Y to the syms declaration, and add these to the end of the posted code:
[VF,Subs] = odeToVectorField(odes);
odefcn = matlabFunction(VF, 'Vars',{t,Y});
Then use ‘odefcn’ with the numerical ODE integrator of your choise (such as ode45) to integrate them numerically.
Use the ‘Subs’ variable to determine the variable assignment order in the function and in the outputs of the integration.
  댓글 수: 2
Andrian Mirza
Andrian Mirza 2021년 5월 2일
It worked very well, thanks, how to plot the results though?
Star Strider
Star Strider 2021년 5월 2일
As always, my pleasure!
Try this —
syms x(t) y(t) z(t) t Y
c_1 = 1
c_1 = 1
c_2 = 2
c_2 = 2
c_3 = 1
c_3 = 1
c_4 = 1
c_4 = 1
c_5 = 1
c_5 = 1
c_6 = 1
c_6 = 1
c_7 = 1
c_7 = 1
c_8 = 1
c_8 = 1
c_9 = 1
c_9 = 1
ode1 = diff(x,t) == c_1*(c_3-x) + c_2*(x-y);
ode2 = diff(y,t) == c_4*(x-y) - c_5*c_6*y*(1-z) + c_7*c_6*exp(c_8 - c_9*z);
ode3 = diff(z,t) == c_5*y*(1-z) - exp(c_8 - c_9*z);
odes = [ode1; ode2; ode3]
odes(t) = 
[VF,Subs] = odeToVectorField(odes)
VF = 
Subs = 
odefcn = matlabFunction(VF, 'Vars',{t,Y});
[t,y] = ode45(odefcn, [0 50], zeros(1,3)+1E-8);
figure
plot(t, y)
grid
legend(string(Subs), 'Location','best')
ylim([-1 1]*5)
.

댓글을 달려면 로그인하십시오.

추가 답변 (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