Plotting bacterial growth using odes

조회 수: 22 (최근 30일)
Billy Bob
Billy Bob 2019년 10월 16일
댓글: Emmanuel Ayodeji-Ogunsanya 2022년 4월 16일
Hi,
I would like to plot the following functions using Matlab:
dx/dt v. time and ds/dt v. time (with dx/dt on the y axis and time on the x axis)
The expression for dx/dt is given as the following:
---- where S and X are unknown
there is an expression for S in this case:
--- where S and X are unknown.
I know how to plot the above system by converting the differentials to first order and then solving them using 'ode45'. However, this gives me the plots for X v. t and S v. t.
What I would like instead are plot of the differential equations themselves against time. Any help in this regard would be much appreciated!
  댓글 수: 2
darova
darova 2019년 10월 16일
Show the code you tried
Emmanuel Ayodeji-Ogunsanya
Emmanuel Ayodeji-Ogunsanya 2022년 4월 16일
how did you plot that system using ode45?

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

채택된 답변

Star Strider
Star Strider 2019년 10월 16일
편집: Star Strider 2019년 10월 16일
I believe Monod kinetics and curve fitting can help. You are not fitting data, so just use the ODE and ode45 call syntax.
EDIT — (16 Oct 2019 at 17:30)
If you want to plot the differential equations themselves, substitute ‘t’ and ‘y’ back into ‘M’ to get the derivatives:
% Change to First Order%
[V,Sbs] = odeToVectorField([ode1,ode2,ode3])
M = matlabFunction(V,'vars',{'t','Y'})
% Setting Intervals%
interval = [0 1000];
% Initial Conditions%
y0 = [X0 S0 P0];
ysol = ode45(M,interval,y0)
% Graph Plots%
fplot(@(x)deval(ysol,x,1), [0, 35]);
hold on
fplot(@(x)deval(ysol,x,2), [0, 35]);
fplot(@(x)deval(ysol,x,3), [0, 35]);
hold off
legend(string(Sbs))
t = ysol.x;
ys = ysol.y;
for k = 1:numel(t)
dy(:,k) = M(t(k),ys(:,k));
end
figure
plot(t, dy)
grid
legend(string(Sbs))
xlim([0 35])
title('Derivatives')
Alternatively, you can use the gradient function on the solved values of ‘y’, although you would need to specify ‘interval’ as a vector of more than two elements using the linspace function for best results, since gradient prefers regularly-sampled vectors. It all depends on what you want to do.
EDIT — (16 Oct 2019 at 17:59)
#Plotting bacterial growth using odes.png
The plot image is not appearing when I paste it in, so I attached it as well.
  댓글 수: 2
Billy Bob
Billy Bob 2019년 10월 21일
Hi! Thank you for the help, it was much appreciated. I tried it and the code worked! I only have one question in that when I do run the code, in the derivative chart, all of the graph should be above thex-axis. Yet, by using the code you provided, the graph for the S-derivative is below the x-axis. Is there a way I can plot the 3 derivatove graphs separately and then reflect the S graph?
Star Strider
Star Strider 2019년 10월 21일
As always, my pleasure.
You can take the absolute value of if you like (or the absolute values of all of the derivatives), however I strongly advise against that. The integrated value of decreases for the entire time, then evenutally levels off at 0. The derivative reflects that.
I would not change anything.

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

추가 답변 (2개)

darova
darova 2019년 10월 16일
How do you know that it is the correct order (why not S,X,P ?)
y0 = [X0 S0 P0];
Try this to plot X vs S
[t,ysol] = ode45(M,interval,y0)
% Graph Plots%
plot(ysol(:,1),ysol(:,2))

Shivya Shrivastava
Shivya Shrivastava 2020년 10월 29일
An investigator has reported the data tabulated below for an experiment to determine the growth rate of bacteria k (per d), as a function of oxygen concentration c (mg/L). Find which degree of polynomial is the best fit for given data using MATLAB.
c (mg/L)
0.5
0.8
1.5
2.5
4
k (per d)
1.1
2.4
5.3
7.6
8.9
Plot the best fit curve by continuous line along with the given data points by ‘o’ on the same graph. Print the equation on command prompt after getting the coefficient.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by