%T = ... %do the first period %for all t in the first period %for certain time, solve one system %transfer initial condition, solve other system %fill these into a larger array of zeros to store everything %zero the dummy functions %for the second the the Nth period %do like before... %if first time step use specific initial condtions %else use clear clc tic Period = [86400 21600 10000 5000 2500 1000 480 240 120 40 10 4 3 2 1 0.5 0.05]; N = [4 4 4 8 10 20 40 100 200 1000 400 1000 2000 4000 30000 40000 80000 ]; DIVS_Master = [100 100 10 5 2.5 1 0.1 0.05 0.05 0.02 0.01 0.005 0.005 0.005 0.005 0.0025 0.00025]; Samples = [3 3 3 3 5 5 5 5 5 10 10 10 10 10 10 10 10]; Y_cell = cell(17,7); T_cell = cell(17,7); %DUTY_CYCLE = [0.875 0.75 0.625 0.5 0.375 0.25 0.125]; DUTY_CYCLE = [ 0.25 ]; global k; global K_CAL1 global K_CAL2 K_CAL1 = 2; K_CAL2 = 10; k = 0.04365; for d=1 d for q = 1:16 q T = Period(q); %period Nperiods = N(q); %Number of Periods dc = DUTY_CYCLE(d); %duty cycle divs = T/DIVS_Master(q); %number of division in a period Y = zeros(divs*Nperiods,3); %solution array time = zeros(divs*Nperiods,1); %time array Light = zeros(divs*Nperiods,1); dP_REL = zeros(divs*Nperiods,1); init = [0.5 K_CAL1/(K_CAL1+1) K_CAL2/(K_CAL2+1)]; %opts = odeset('RelTol',1e-4,'AbsTol',1e-4); %opts = odeset('RelTol',1e-5); for j = 1:Nperiods if j > 1 init(:) = Y((j-1)*divs,:); %set initial value as previous value end for i = 1:2 if i == 1; [time1,Amp1] = ode113(@CRM_TwoRegs_LIGHT_July24_4_RuBP,[0:T/divs:T*dc],[init(1,1) init(1,2) init(1,3)]); elseif i == 2; [time2,Amp2] = ode113(@CRM_TwoRegs_DARK_July24_4_RuBP,[T*dc:T/divs:T],[Amp1(dc*divs+1,1) Amp1(dc*divs+1,2) Amp1(dc*divs+1,3)]); end end time(1+(j-1)*divs:(j-1)*divs+divs*dc+1,1) = time1+(j-1)*T; time(divs*dc+1+(j-1)*divs:j*divs+1,1) = time2+(j-1)*T; Y(1+(j-1)*divs:(j-1)*divs+divs*dc+1,:) = Amp1; Y(divs*dc+1+(j-1)*divs:j*divs+1,:) = Amp2; Light(1+(j-1)*divs:(j-1)*divs+divs*dc+1,1) = 1; Light(divs*dc+1+(j-1)*divs:j*divs+1,1) = 0; end a_star_cell = Y(:,1); a_0_cell = 1-Y(:,1); b_on_cell = Y(:,2); b2_on_cell = Y(:,3); dP_REL = Y(:,1)./(k + Y(:,1)); %P/Pm dP_REL_pen = dP_REL.*Y(:,2).*Y(:,3); dP_REL_cell = dP_REL; dP_REL_cell_pen = dP_REL_pen; T_cell = time; muBAR(q,d) = 1.28*((K_CAL1+1)/K_CAL1)*((K_CAL2+1)/K_CAL2)*1.122*mean(dP_REL((Nperiods-2)*divs:Nperiods*divs,1)); muBAR_pen(q,d) = 1.28*((K_CAL1+1)/K_CAL1)*((K_CAL2+1)/K_CAL2)*1.122*mean(dP_REL_pen((Nperiods-2)*divs:Nperiods*divs,1)); S = Samples(q); saveable_dP_REL_cell_pen{q,d} = dP_REL_cell_pen((N(q)-S)*Period(q)/DIVS_Master(q):(N(q))*Period(q)/DIVS_Master(q),1); saveable_a_star_cell{q,d} = a_star_cell((N(q)-S)*Period(q)/DIVS_Master(q):(N(q))*Period(q)/DIVS_Master(q),1); saveable_a_0_cell{q,d} = a_0_cell((N(q)-S)*Period(q)/DIVS_Master(q):(N(q))*Period(q)/DIVS_Master(q),1); saveable_b_on_cell{q,d} = b_on_cell((N(q)-S)*Period(q)/DIVS_Master(q):(N(q))*Period(q)/DIVS_Master(q),1); saveable_b2_on_cell{q,d} = b2_on_cell((N(q)-S)*Period(q)/DIVS_Master(q):(N(q))*Period(q)/DIVS_Master(q),1); saveable_T_cell{q,d} = T_cell((N(q)-S)*Period(q)/DIVS_Master(q):(N(q))*Period(q)/DIVS_Master(q),1); end toc end %making the saveable stuff save('CRM_TwoRegs_July24th_4_RuBP', 'muBAR_pen', 'DUTY_CYCLE', 'Period', 'saveable_dP_REL_cell_pen', 'saveable_a_star_cell', 'saveable_a_0_cell', 'saveable_b_on_cell', 'saveable_T_cell', 'saveable_b2_on_cell')