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];
댓글 수: 0
채택된 답변
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
Star Strider
2021년 5월 2일
As always, my pleasure!
Try this —
syms x(t) y(t) z(t) t Y
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]
[VF,Subs] = odeToVectorField(odes)
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 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!