Question: Create a function that projects population based on static: Birth Rate (BR) Death Rate (DR) Migration will be represented as a pulse function starting at
Create a function that projects population based on static:
Birth Rate (BR)
Death Rate (DR)
Migration will be represented as a pulse function starting at timestartM, ending at timeEndM and having magnitude Mann.
A template for the function has been provided. Please do not change variable names as this will result in an incorrect answer.
FUNCTION
function [P,M]= popDynamics_2_fcn( BR,DR,tinit,tfinal,delt,Pinit,Mann,timeStartM,timeEndM )
% -------------------------------------------------------------------------
% Case 2. M(t) is a rectangular pulse. Find P(t) history.
% SETUP
% tinit,tfinal,delt time initial, final, & timestep
% BR, birth rate
% DR, death rate
% Pinit, initial population level
% Mann, annual rate of migration (+:immigration, -:emigration)
% timeStartM, time at which migration begins
% timeEndM, time at wich migration stops
% RESULTS
% P, population history
% M, migration history
end
CODE TO CALL YOUR FUNCTION
BR=.15;
DR=.09;
tinit=0;
tfinal=100;
delt=.5;
Pinit=400;
Mann=-10;
timeStartM= 20;
timeEndM= 60;
[P,M]= popDynamics_2_fcn( BR,DR,tinit,tfinal,delt,Pinit,Mann,timeStartM,timeEndM );
t=tinit:delt:tfinal;
plot(t,P)
title('Total Population')
xlabel('time (yrs)')
ylabel('People')
figure
title('Migration')
plot(t,M, 'r')
xlabel('time (yrs)')
ylabel('People')
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
