Solving 3 simultaneous first order differential equations

8 views (last 30 days)
I need to solve the following set of differential equations using MATLAB.
Here, um,Ks,Kp,a,sm,yxs,K1,K2-constant values s,p,x- variables
I am using the function ode45 for this. This is my program :
function dydt=react(t,y)
dydt=zeros(3,1);
um=0.71;
ks=37.72;
sm=510;
kp=160.83;
a=0.81;
yxs=0.03;
ms=0.0011;
k1=33.04;
k2=0.0001;
y=zeros(3,1);
x=y(1);
s=y(2);
p=y(3);
dx=(um*(s/(s+ks))*((1-(s/sm))^a)*(kp/(kp+p)))*x;
ds=-1*((um/yxs)*(s/(s+ks))*((1-(s/sm))^a)*(kp/(kp+p)) + ms)*x;
dp=(k1*(um*(s/(s+ks))*((1-(s/sm))^a)*(kp/(kp+p)))+k2)*x;
dydt=[dx;ds;dp];
On giving this command :
[T,Y]=ode45('react',[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],[0.2 100 0.2]);
or this command :
[T,Y]=ode45('react',[0 15],[0.2 100 0.2]);
All I get is this :
Y =
0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000 0.200000000000000 100 0.200000000000000
i.e the equations are not being solved. I am just getting the initial values of my inputs (i.e x,s,p) as the output.
Any help is appreciated.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 29 Dec 2013
Because in react function you added
y=zeros(3,1);
Remove this line
  2 Comments
Abhivyakti
Abhivyakti on 29 Dec 2013
Thankyou soo much! That worked.
Another doubt I have. I need to plot the graphs of 'dx/dt vs t', 'ds/dt vs t' and 'dp/dt vs t'.
I cannot figure out how to get an equation between 'dx/dt and t' , i.e how to consider the variation of 'dx/dt' with 't' in one equation as 'dx/dt varies as the variation of 's' & 'p' wrt 't'.
Abhivyakti
Abhivyakti on 29 Dec 2013
Basically , I think if I have the equation of each 'x' with respect to 't', I can differentiate that & obtain 'dx/dt'. So, can I get the equation of 'x' wrt 't' ( as its obtained using function dsolve) by using 'ode23 or ode45' ????

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!