How to solve simultaneous differential equations?

6 views (last 30 days)
% 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 Comment
Bjorn Gustavsson
Bjorn Gustavsson on 4 Oct 2021
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.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 4 Oct 2021
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 Comments
Star Strider
Star Strider on 4 Oct 2021
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!