Solving 3 simultaneous first order differential equations

조회 수: 7 (최근 30일)
Abhivyakti
Abhivyakti 2013년 12월 29일
댓글: Walter Roberson 2013년 12월 29일
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.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 12월 29일
Because in react function you added
y=zeros(3,1);
Remove this line
  댓글 수: 2
Abhivyakti
Abhivyakti 2013년 12월 29일
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 2013년 12월 29일
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' ????

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

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