Plotting differential equations

I would like to plot three differential equations in a graph and I don't know how to do it.
The equations are:
dCxdt=0.4*Cx*Cy/(2.5+Cx)
dCydt=-2.22*0.4*Cy*Cx/(2.5+Cy)-0.03*Cx
dCzdt=0.85*0.4*Cx*Cy/(2.5+Cy)
with initial values of: Cx=0.2, Cs=60, Cp=0
if any more information is needed please ask for it.
Thank you for your help

 Respuesta aceptada

Walter Roberson
Walter Roberson el 27 de Jun. de 2011

2 votos

Please clarify your boundary conditions.
If they are Cx(0)=0.2, Cy(0)=0, Cz(0)=60, and if the equations are
diff(Cx(t), t) = .4*Cx(t)*Cy(t)/(2.5+Cx(t))
diff(Cy(t), t) = -.888*Cy(t)*Cx(t)/(2.5+Cy(t))-.3*Cy(t)
diff(Cz(t), t) = .340*Cy(t)*Cx(t)/(2.5+Cy(t))
then the overall solution is Cx(t)=0.2, Cy(t)=0, Cz(t)=60

5 comentarios

Adrian Hurtado
Adrian Hurtado el 27 de Jun. de 2011
Thank you but I'm looking for a script to plot all the equations,not to solve them.The boundary conditions are the ones you said.
Thank you anyway
Walter Roberson
Walter Roberson el 27 de Jun. de 2011
If those are the boundary conditions, then the plots of the functions are simply horizontal lines. The differentials of the first two equations are self-consistent when the differentials are both 0 -- that is, when the functions are both constants. That in turn leads to the differential of Cz being 0, again a constant function. The boundary points tell you _which_ constants.
I notice that none of the three equations involve Cz on the right hand side. Is that what was desired?
If the boundary conditions are instead Cx(0)=0.2, Cy(0)=60, Cz(0)=0, then the solution to the equations is slightly more interesting, Cx(t) = 0, Cy(t) = 60*exp(-(3/10)*t), Cz(t) = 0
Adrian Hurtado
Adrian Hurtado el 27 de Jun. de 2011
This an exercise for my informatic lessons (sorry about my English) and the problem is a bioreactor (I study Chemistry Engineering):
S + R---->P
(using x,y,z X+S--->Z)
and the mass of each component is known by the differential equations above.
The point is that I don't need the answer,only a script (or more than one) that plots the variation of the three components.I don't know how to plot differential equations (I just know that I should use some function called ode or something like that but I don't know how to use it)
Thanks a lot for your interest.
Walter Roberson
Walter Roberson el 27 de Jun. de 2011
You will probably want to use something like ode45(), and you will want to supply the initial and final time in the tspan argument.
The first output of ode45() will be the column vector of times evaluated at; the second output will be the corresponding function values. For the odefun, use
odefun = @(t,y) [.4*y(1)*y(2)/(2.5+y(1));
-.888*y(2)*y(1)/(2.5+y(2))-.3*y(2);
.340*y(2)*y(1)/(2.5+y(2))];
After you run ode45(), generating T and Y,
plot(T,Y(:,1),'r',T,Y(:,2),'g',T(:,3),'b')
Adrian Hurtado
Adrian Hurtado el 27 de Jun. de 2011
I finally got it!!!Thank you so much!!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by