(MATLAB) In this problem you will be plotting the bacteria growth as a function
ID: 3572890 • Letter: #
Question
(MATLAB) In this problem you will be plotting the bacteria growth as a function of time. The growth of a specific strain of bacteria has been determined to follow the relationship
y = yiekt
where y is the number of bacteria at a given time, yi is the initial number of bacteria (assume yi is 1), k is a constant (1.386/hr), and t is the elapsed time in hours. Using the linspace function create an array for time from 0 to 7 hours in steps of 0.1 hours. Store the appropriate information in variables for yi, and k. Calculate the number of bacteria for each time period. Scientists and engineers often prefer to plot data using log scales or inverse of one of the parameters so that the data is displayed as a straight line so that information at other points may be easily extracted. Using the subplot command, plot the number of bacterial as a function of time using linear scales for both axes; a log scale for the y axis and a linear scale for the x axis; a log scale for the x axis and a linear scale for the y axis; and a log scale for both axes. Label the axes and add titles for all four plots. In comments indicate which of these plots if any produce a straight line.
Explanation / Answer
yi = 1;
k = 1.386;
%y = @(t) yi*exp(k*t);
t = linspace(0, 7, 71);
y = yi*exp(k*ts);
figure
subplot(2,2,1)
plot(t, y)
title('t vs y')
xlabel('t')
ylabel('y')
subplot(2,2,2)
plot(t, log(y))
title('t vs log(y)')
xlabel('t')
ylabel('log(y)')
subplot(2,2,3)
plot(log(t), y)
title('log(t) vs y')
xlabel('log(t)')
ylabel('y')
subplot(2,2,4)
plot(log(t), log(y))
title('log(t) vs log(y)')
xlabel('log(t)')
ylabel('log(y)')
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.