The growth in population of a certain colony of individuals is modeled by the eq
ID: 3799409 • Letter: T
Question
The growth in population of a certain colony of individuals is modeled by the equation P_t=P_0e^(rt), where Pt is the population at time t, P_0 is the population at t = 0, and r is the yearly growth rate. Write a user-defined function that uses this model to predict the population at any time t, from knowing P0 and Pt1 at some other time t1. For function name and arguments use:
Pt = calculatePop(P0, Pt1, t1, t)
where the output argument Pt corresponds to Pt, and the input arguments P_0, P_t1, t1, t corresponds to P0, Pt1, t1, t, respectively.
Use the function for the following two cases:
(a) The initial population of a certain species is 50 million and it doubles in 20 years. Calculate the population 10 and 15 years from the initial time.
(b) The half-life of a radioactive material is 5.8 years. How much of a 7-gram sample will be left after 30 years.
The output should be displayed with meaningful messages.
Please answer in MATLAB! thank you.
Explanation / Answer
Function :
function Pt = calculatePop(P0, Pt1, t1, t)
r = log (Pt1 / P0) / t1;
Pt = P0 * exp(r*t);
end
==========================
Pt = calculatePop(50, 100, 20, 10);
X = sprintf('Population after 10 years = %.2f million',Pt);
disp(X);
Pt = calculatePop(50, 100, 20, 15);
X = sprintf('Population after 15 years = %.2f million',Pt);
disp(X);
Pt = calculatePop(7, 3.5, 5.8, 30);
X = sprintf('Sample left after 30 years = %.2f grams',Pt);
disp(X);
================================
output
================================
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.