Question: This is the code I have so far, how would I adjust this code in MatLab to account for the migration conditions in the picture?

This is the code I have so far, how would I adjust this code in MatLab to account for the migration conditions in the picture?This is the code I have so far, how would I adjust

function[P1,P2,P3,P4,M2]=Demographics_2_fcn(parameters,M2effect,initconds,timedata) % Case 02: Migration effect in group 2. Find group histories.

% parameters=[b2,d1,d2,d3,d4,t12,t23,t34] where; % b2 = birth rate in group2 % di = death rates in group Pi % tij = transition from group Pi to group Pj due to ageing % M2effect = rectangular pulse defined by [Mann2,tstartM2,tEndM2] % initconds = [Pinit1,Pinit2,Pinit3,Pinit4] % timedata = [tinit,tfinal,delt] % results: % P1,P2,P3,P4 are group time histories % M2 is time history

%

% birth rate for group 2 b2 = parameter(1);

% death rate from group to group d1 = parameters(2); d2 = parameters(3); d3 = parameters(4); d4 = parameters(5);

% initial pop in groups t12 = parameters(6); t23 = parameters(7); t34 = parameters(8);

% initial pop in groups Pinit1 = initconds(1); Pinit2 = initconds(2); Pinit3 = initconds(3); Pinit4 = initconds(4);

% initial and final time and delta tinit = timedata(1); tfinal = timedata(2); delt = timedata(3);

tvec = tinit:delt:tfinal;

P1 = zeros(1,length(tvec)); P2 = zeros(1,length(tvec)); P3 = zeros(1,length(tvec)); P4 = zeros(1,length(tvec));

P1(1) = Pinit1; P2(1) = Pinit2; P3(1) = Pinit3; P4(1) = Pinit4;

for i=1:length(tvec)-1 P1(i+1) = P1(i) + delt*(b2*P2(i)-d1*P1(i)-t12*P1(i)); P2(i+1) = P2(i) + delt*(t12*P1(i)-d2*P2(i)-t23*P2(i)); P3(i+1) = P3(i) + delt*(t23*P2(i)-d3*P3(i)-t34*P3(i)); P4(i+1) = P4(i) + delt*(t34*P3(i)-d4*P4(i)); end

disp(P1) disp(P2) disp(P3) disp(P4)

end

Parameters[b2, d1, d2, d3, d4, t12, t23, t34 ] Migration Initial conditions: [Pinit1,Pinit2, Pinit3, Pini4 ] Time data: [M2ann, tStartM2, tEndM2] [tinit, tfinal, delt ] Definition of M2 Parameters[b2, d1, d2, d3, d4, t12, t23, t34 ] Migration Initial conditions: [Pinit1,Pinit2, Pinit3, Pini4 ] Time data: [M2ann, tStartM2, tEndM2] [tinit, tfinal, delt ] Definition of M2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!