Solving 3 simultaneous first order differential equations

I need to solve the following set of differential equations in Matlab.
Here, um,Ks,Kp,a,sm,yxs,K1,K2-constant values s,p,x- variables
I need to solve the last three differential equations. As much as I understand, these are 3 first order simultaneous differential equations.
I can't figure out how to acknowledge the variation of u (first equation) in the rest of the equations.
Can anyone help with this?

 Accepted Answer

Mischa Kim
Mischa Kim on 28 Dec 2013
Edited: Mischa Kim on 28 Dec 2013
If none of the variables s, p, x depend on µ you can simply go ahead and solve the three differential equations. Once solved you can get µ as a function of time by plugging in s(t) and p(t) in the first equation.

5 Comments

I tried using ode45 solver for this.
This is what i did :
function dy=sean(t,y) y=zeros(3,1); x=y(1); s=y(2); p=y(3);
%define constants
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;
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;
dy=[dx;ds;dp];
%define range of t
u=15; trange=[0,15];
init=[0.2 100 0.2];
[T,Y]=ode45(@sean,trange,init);
I get the following error :
??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer.
Error in ==> ode45
How to resolve this ?
Hey
I have resolved the recursion error. The problem is, that my program doesn't seem to work.
This is what I have used :
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];
I give the following 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]);
In the output Y, I am just getting the initial values of the three variables i.e x,s &p, for each corresponding value of time.
i.e
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
What am i doing wrong here?
You are really close. Remove the y=zeros(3,1); statement. With this statement you are basically setting the derivatives equal to zero at each time step.
If you remove that you will get an error as to y is not defined. You cannot have an expression called y(1)
y is one of the inputs for function "react". Thus there will be no error removing "y=zeros(3,1)".

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 26 Dec 2013

Edited:

on 5 Jun 2019

Community Treasure Hunt

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

Start Hunting!