How to solve simultaneous differential equations?

% Parameters
mumax=0.2;
Ks=1.0;
Yxs=0.5;
Ypx=0.2;
Sf=10;
F=0.02;
Yps=1.0;
% Equaiotns
syms V(t) X(t) P(t) S(t)
Rg=mumax*(S/(S+Ks))*X;
Rp=Ypx*Rg;
% differential equations
ode1 = diff(V) == F;
ode2 = diff(X) == Rg-((X*F)/V);
ode3 = diff(P) == Rp-((P*F)/V);
ode4 = diff(S) == (F*(Sf-S)/V)-(Rg/Yxs)-(Rp/Yps);
cond1 = V(0) == 1;
cond2 = X(0) == 0.05;
cond3= P(0) == 0;
cond4 = S(0) == 10;
% Solution
sol1=dsolve(ode1,cond1);
sol2=dsolve(ode2,cond2);
sol3=dsolve(ode3,cond3);
sol4=dsolve(ode4,cond4)
This is my code, But sol4 is the message like "Warning: Symbolic solution not available." and dsolve 209 line.
What should I do fix the problem?

댓글 수: 1

First: you have to call dsolve with all your coupled ODEs, see the dsolve-documentation for example of that.
Second: Not all differential equations have explicit analytical solutions - since X P and S are nonlinear in the solutions containing one factor of 1/V(t) this doesn't seem unlikely, it might be possible to find some cunning variable-transform that converts this into something with an analytical solution, that might be difficult. Therefore you might need to turn to numerical solutions, see the help and documentation for ode45, ode23, ode15s and their siblings.

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

 채택된 답변

Star Strider
Star Strider 2021년 10월 4일
It is nonlinear, so it does not have a symbolic solution.
Integrate it numerically instead —
% Parameters
mumax=0.2;
Ks=1.0;
Yxs=0.5;
Ypx=0.2;
Sf=10;
F=0.02;
Yps=1.0;
% Equaiotns
syms V(t) X(t) P(t) S(t) Y T
Rg=mumax*(S/(S+Ks))*X;
Rp=Ypx*Rg;
% differential equations
ode1 = diff(V) == F;
ode2 = diff(X) == Rg-((X*F)/V);
ode3 = diff(P) == Rp-((P*F)/V);
ode4 = diff(S) == (F*(Sf-S)/V)-(Rg/Yxs)-(Rp/Yps);
cond1 = V(0) == 1;
cond2 = X(0) == 0.05;
cond3= P(0) == 0;
cond4 = S(0) == 10;
% Solution
[VF,Subs] = odeToVectorField([ode1, ode2,ode3,ode4])
VF = 
Subs = 
odefcn = matlabFunction(VF, 'Vars',{T,Y})
odefcn = function_handle with value:
@(T,Y)[(Y(1).*(-1.0./5.0e+1))./Y(2)+(Y(1).*Y(4))./(Y(4).*5.0+5.0);1.0./5.0e+1;(Y(3).*(-1.0./5.0e+1))./Y(2)+(Y(1).*Y(4))./(Y(4).*2.5e+1+2.5e+1);-(Y(4)./5.0e+1-1.0./5.0)./Y(2)-(Y(1).*Y(4).*(1.1e+1./2.5e+1))./(Y(4)+1.0)]
[t,y] = ode89(odefcn, [0 100], [0.05 1 0 10]);
figure
plot(t, y)
legend(string(Subs))
grid
The ode89 function is new to R2021b. Use ode45 with earlier versions.
.

댓글 수: 2

Thx to perfect answer! :D
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 10월 4일

댓글:

2021년 10월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by