Generated Code
The following is matlab code generated by the CellML API from this CellML file. (Back to language selection)
The raw code is available.
function [VOI, STATES, ALGEBRAIC, CONSTANTS] = mainFunction() % This is the "main function". In Matlab, things work best if you rename this function to match the filename. [VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel(); end function [algebraicVariableCount] = getAlgebraicVariableCount() % Used later when setting a global variable with the number of algebraic variables. % Note: This is not the "main method". algebraicVariableCount =42; end % There are a total of 31 entries in each of the rate and state variable arrays. % There are a total of 57 entries in the constant variable array. % function [VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel() % Create ALGEBRAIC of correct size global algebraicVariableCount; algebraicVariableCount = getAlgebraicVariableCount(); % Initialise constants and state variables [INIT_STATES, CONSTANTS] = initConsts; % Set timespan to solve over tspan = [0, 10]; % Set numerical accuracy options for ODE solver options = odeset('RelTol', 1e-06, 'AbsTol', 1e-06, 'MaxStep', 1); % Solve model with ODE solver [VOI, STATES] = ode15s(@(VOI, STATES)computeRates(VOI, STATES, CONSTANTS), tspan, INIT_STATES, options); % Compute algebraic variables [RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS); ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI); % Plot state variables against variable of integration [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends(); figure(); plot(VOI, STATES); xlabel(LEGEND_VOI); l = legend(LEGEND_STATES); set(l,'Interpreter','none'); end function [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends() LEGEND_STATES = ''; LEGEND_ALGEBRAIC = ''; LEGEND_VOI = ''; LEGEND_CONSTANTS = ''; LEGEND_VOI = strpad('time in component environment (second)'); LEGEND_STATES(:,1) = strpad('Casp8 in component Casp8 (micromolar)'); LEGEND_STATES(:,2) = strpad('Casp8Bid in component Casp8 (micromolar)'); LEGEND_STATES(:,3) = strpad('Bid in component Bid (micromolar)'); LEGEND_ALGEBRAIC(:,3) = strpad('J_0 in component Casp8 (flux)'); LEGEND_ALGEBRAIC(:,1) = strpad('J_f0 in component Casp8 (flux)'); LEGEND_ALGEBRAIC(:,2) = strpad('J_Casp8 in component Casp8 (flux)'); LEGEND_CONSTANTS(:,1) = strpad('k_f0 in component model_constant (first_order_rate_constant)'); LEGEND_CONSTANTS(:,2) = strpad('k_10 in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,3) = strpad('k_00 in component model_constant (first_order_rate_constant)'); LEGEND_CONSTANTS(:,4) = strpad('u in component model_constant (first_order_rate_constant)'); LEGEND_STATES(:,4) = strpad('Apaf_1 in component Apaf_1 (micromolar)'); LEGEND_STATES(:,5) = strpad('CytcApaf_1 in component CytcApaf_1 (micromolar)'); LEGEND_STATES(:,6) = strpad('Cytc in component Cytc (micromolar)'); LEGEND_ALGEBRAIC(:,4) = strpad('J_Apaf_1 in component Apaf_1 (flux)'); LEGEND_ALGEBRAIC(:,5) = strpad('J_1 in component Apaf_1 (flux)'); LEGEND_CONSTANTS(:,5) = strpad('P_Apaf_1 in component model_constant (flux)'); LEGEND_CONSTANTS(:,6) = strpad('k_11 in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,7) = strpad('k_01 in component model_constant (first_order_rate_constant)'); LEGEND_STATES(:,7) = strpad('Apop in component Apop (micromolar)'); LEGEND_ALGEBRAIC(:,7) = strpad('J_1b in component CytcApaf_1 (flux)'); LEGEND_CONSTANTS(:,8) = strpad('k_11b in component model_constant (rate)'); LEGEND_CONSTANTS(:,9) = strpad('k_01b in component model_constant (first_order_rate_constant)'); LEGEND_CONSTANTS(:,10) = strpad('p in component model_constant (dimensionless)'); LEGEND_ALGEBRAIC(:,10) = strpad('J_14 in component Cytc_mito (flux)'); LEGEND_ALGEBRAIC(:,6) = strpad('J_Cytc in component Cytc (flux)'); LEGEND_STATES(:,8) = strpad('Cytc_mito in component Cytc_mito (micromolar)'); LEGEND_STATES(:,9) = strpad('Bax_2 in component Bax_2 (micromolar)'); LEGEND_ALGEBRAIC(:,8) = strpad('J_Cytc_mito in component Cytc_mito (flux)'); LEGEND_CONSTANTS(:,11) = strpad('P_Cytc_mito in component model_constant (flux)'); LEGEND_CONSTANTS(:,12) = strpad('k14 in component model_constant (second_order_rate_constant)'); LEGEND_ALGEBRAIC(:,16) = strpad('J_12b in component tBidBax (flux)'); LEGEND_ALGEBRAIC(:,9) = strpad('J_Bax_2 in component Bax_2 (flux)'); LEGEND_STATES(:,10) = strpad('tBid_mito in component tBid_mito (micromolar)'); LEGEND_STATES(:,11) = strpad('Bax in component Bax (micromolar)'); LEGEND_ALGEBRAIC(:,13) = strpad('J_11 in component tBid (flux)'); LEGEND_ALGEBRAIC(:,12) = strpad('J_12a in component tBid_mito (flux)'); LEGEND_ALGEBRAIC(:,11) = strpad('J_tBid_mito in component tBid_mito (flux)'); LEGEND_CONSTANTS(:,13) = strpad('k12a in component model_constant (second_order_rate_constant)'); LEGEND_STATES(:,12) = strpad('tBid in component tBid (micromolar)'); LEGEND_ALGEBRAIC(:,24) = strpad('J_f8 in component Casp3Bid (flux)'); LEGEND_ALGEBRAIC(:,14) = strpad('J_tBid in component tBid (flux)'); LEGEND_CONSTANTS(:,14) = strpad('k11 in component model_constant (first_order_rate_constant)'); LEGEND_STATES(:,13) = strpad('tBidBax in component tBidBax (micromolar)'); LEGEND_ALGEBRAIC(:,15) = strpad('J_tBidBax in component tBidBax (flux)'); LEGEND_CONSTANTS(:,15) = strpad('k12b in component model_constant (second_order_rate_constant)'); LEGEND_STATES(:,14) = strpad('Bcl_2 in component Bcl_2 (micromolar)'); LEGEND_ALGEBRAIC(:,18) = strpad('J_13 in component Bax (flux)'); LEGEND_ALGEBRAIC(:,17) = strpad('J_Bax in component Bax (flux)'); LEGEND_CONSTANTS(:,56) = strpad('P_Bax in component Bax (flux)'); LEGEND_CONSTANTS(:,16) = strpad('k13 in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,17) = strpad('P_oBax in component model_constant (flux)'); LEGEND_CONSTANTS(:,18) = strpad('p53 in component model_constant (micromolar)'); LEGEND_CONSTANTS(:,19) = strpad('p53_thresh in component model_constant (micromolar)'); LEGEND_CONSTANTS(:,20) = strpad('u_Bax in component model_constant (first_order_rate_constant)'); LEGEND_STATES(:,15) = strpad('Casp3 in component Casp3 (micromolar)'); LEGEND_STATES(:,16) = strpad('Casp3Bcl_2 in component Casp3Bcl_2 (micromolar)'); LEGEND_ALGEBRAIC(:,19) = strpad('J_9 in component Bcl_2 (flux)'); LEGEND_ALGEBRAIC(:,21) = strpad('J_Bcl_2 in component Bcl_2 (flux)'); LEGEND_CONSTANTS(:,21) = strpad('k_19 in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,22) = strpad('k_09 in component model_constant (first_order_rate_constant)'); LEGEND_CONSTANTS(:,57) = strpad('P_Bcl_2 in component Bcl_2 (flux)'); LEGEND_CONSTANTS(:,23) = strpad('P_oBcl_2 in component model_constant (flux)'); LEGEND_CONSTANTS(:,24) = strpad('u_Bcl_2 in component model_constant (first_order_rate_constant)'); LEGEND_ALGEBRAIC(:,20) = strpad('J_f9 in component Casp3Bcl_2 (flux)'); LEGEND_CONSTANTS(:,25) = strpad('k_f9 in component model_constant (first_order_rate_constant)'); LEGEND_STATES(:,17) = strpad('Casp3Bid in component Casp3Bid (micromolar)'); LEGEND_ALGEBRAIC(:,22) = strpad('J_8 in component Casp3Bid (flux)'); LEGEND_CONSTANTS(:,26) = strpad('k_18 in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,27) = strpad('k_08 in component model_constant (first_order_rate_constant)'); LEGEND_CONSTANTS(:,28) = strpad('k_f8 in component model_constant (first_order_rate_constant)'); LEGEND_ALGEBRAIC(:,23) = strpad('J_Bid in component Bid (flux)'); LEGEND_CONSTANTS(:,29) = strpad('P_Bid in component model_constant (flux)'); LEGEND_STATES(:,18) = strpad('IAP in component IAP (micromolar)'); LEGEND_STATES(:,19) = strpad('Casp3IAP in component Casp3 (micromolar)'); LEGEND_ALGEBRAIC(:,33) = strpad('J_f6 in component Casp9Pro3 (flux)'); LEGEND_ALGEBRAIC(:,32) = strpad('J_f6b in component ApopCasp9_2Pro3 (flux)'); LEGEND_ALGEBRAIC(:,26) = strpad('J_7 in component Casp3 (flux)'); LEGEND_ALGEBRAIC(:,25) = strpad('J_Casp3 in component Casp3 (flux)'); LEGEND_CONSTANTS(:,30) = strpad('k_17 in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,31) = strpad('k_07 in component model_constant (first_order_rate_constant)'); LEGEND_ALGEBRAIC(:,28) = strpad('J_2 in component Pro9 (flux)'); LEGEND_ALGEBRAIC(:,41) = strpad('J_4b in component ApopCasp9 (flux)'); LEGEND_STATES(:,20) = strpad('Pro9 in component Pro9 (micromolar)'); LEGEND_STATES(:,21) = strpad('ApopPro9 in component Pro9 (micromolar)'); LEGEND_STATES(:,22) = strpad('ApopPro9_2 in component ApopPro9_2 (micromolar)'); LEGEND_ALGEBRAIC(:,29) = strpad('J_3 in component Pro9 (flux)'); LEGEND_ALGEBRAIC(:,27) = strpad('J_Pro9 in component Pro9 (flux)'); LEGEND_CONSTANTS(:,32) = strpad('k_12 in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,33) = strpad('k_02 in component model_constant (first_order_rate_constant)'); LEGEND_CONSTANTS(:,34) = strpad('k_13 in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,35) = strpad('k_03 in component model_constant (first_order_rate_constant)'); LEGEND_CONSTANTS(:,36) = strpad('P_Pro9 in component model_constant (flux)'); LEGEND_ALGEBRAIC(:,30) = strpad('J_f3 in component ApopPro9_2 (flux)'); LEGEND_CONSTANTS(:,37) = strpad('k_f3 in component model_constant (first_order_rate_constant)'); LEGEND_STATES(:,23) = strpad('ApopCasp9_2Pro3 in component ApopCasp9_2Pro3 (micromolar)'); LEGEND_STATES(:,24) = strpad('ApopCasp9_2 in component ApopCasp9_2 (micromolar)'); LEGEND_STATES(:,25) = strpad('Pro3 in component Pro3 (micromolar)'); LEGEND_ALGEBRAIC(:,31) = strpad('J_6b in component ApopCasp9_2Pro3 (flux)'); LEGEND_CONSTANTS(:,38) = strpad('k_16b in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,39) = strpad('k_06b in component model_constant (first_order_rate_constant)'); LEGEND_CONSTANTS(:,40) = strpad('k_f6b in component model_constant (first_order_rate_constant)'); LEGEND_STATES(:,26) = strpad('Casp9Pro3 in component Casp9Pro3 (micromolar)'); LEGEND_ALGEBRAIC(:,34) = strpad('J_6 in component Pro3 (flux)'); LEGEND_CONSTANTS(:,41) = strpad('k_f6 in component model_constant (first_order_rate_constant)'); LEGEND_STATES(:,27) = strpad('Casp9 in component Casp9 (micromolar)'); LEGEND_ALGEBRAIC(:,35) = strpad('J_Pro3 in component Pro3 (flux)'); LEGEND_CONSTANTS(:,42) = strpad('k_16 in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,43) = strpad('k_06 in component model_constant (first_order_rate_constant)'); LEGEND_CONSTANTS(:,44) = strpad('P_Pro3 in component model_constant (flux)'); LEGEND_STATES(:,28) = strpad('Casp9IAP in component IAP (micromolar)'); LEGEND_STATES(:,29) = strpad('ApopCasp9IAP in component IAP (micromolar)'); LEGEND_STATES(:,30) = strpad('ApopCasp9_2IAP in component IAP (micromolar)'); LEGEND_STATES(:,31) = strpad('ApopCasp9 in component ApopCasp9 (micromolar)'); LEGEND_ALGEBRAIC(:,36) = strpad('J_5 in component IAP (flux)'); LEGEND_ALGEBRAIC(:,37) = strpad('J_5b in component IAP (flux)'); LEGEND_ALGEBRAIC(:,38) = strpad('J_5c in component IAP (flux)'); LEGEND_ALGEBRAIC(:,40) = strpad('J_IAP in component IAP (flux)'); LEGEND_CONSTANTS(:,45) = strpad('P_IAP in component model_constant (flux)'); LEGEND_CONSTANTS(:,46) = strpad('k_15 in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,47) = strpad('k_05 in component model_constant (first_order_rate_constant)'); LEGEND_CONSTANTS(:,48) = strpad('k_15b in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,49) = strpad('k_05b in component model_constant (first_order_rate_constant)'); LEGEND_CONSTANTS(:,50) = strpad('k_15c in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,51) = strpad('k_05c in component model_constant (first_order_rate_constant)'); LEGEND_ALGEBRAIC(:,39) = strpad('J_4 in component ApopCasp9 (flux)'); LEGEND_CONSTANTS(:,52) = strpad('k_14 in component model_constant (first_order_rate_constant)'); LEGEND_CONSTANTS(:,53) = strpad('k_04 in component model_constant (second_order_rate_constant)'); LEGEND_CONSTANTS(:,54) = strpad('k_14b in component model_constant (first_order_rate_constant)'); LEGEND_CONSTANTS(:,55) = strpad('k_04b in component model_constant (second_order_rate_constant)'); LEGEND_ALGEBRAIC(:,42) = strpad('J_Casp9 in component Casp9 (flux)'); LEGEND_RATES(:,1) = strpad('d/dt Casp8 in component Casp8 (micromolar)'); LEGEND_RATES(:,2) = strpad('d/dt Casp8Bid in component Casp8 (micromolar)'); LEGEND_RATES(:,4) = strpad('d/dt Apaf_1 in component Apaf_1 (micromolar)'); LEGEND_RATES(:,5) = strpad('d/dt CytcApaf_1 in component CytcApaf_1 (micromolar)'); LEGEND_RATES(:,6) = strpad('d/dt Cytc in component Cytc (micromolar)'); LEGEND_RATES(:,8) = strpad('d/dt Cytc_mito in component Cytc_mito (micromolar)'); LEGEND_RATES(:,9) = strpad('d/dt Bax_2 in component Bax_2 (micromolar)'); LEGEND_RATES(:,10) = strpad('d/dt tBid_mito in component tBid_mito (micromolar)'); LEGEND_RATES(:,12) = strpad('d/dt tBid in component tBid (micromolar)'); LEGEND_RATES(:,13) = strpad('d/dt tBidBax in component tBidBax (micromolar)'); LEGEND_RATES(:,11) = strpad('d/dt Bax in component Bax (micromolar)'); LEGEND_RATES(:,14) = strpad('d/dt Bcl_2 in component Bcl_2 (micromolar)'); LEGEND_RATES(:,16) = strpad('d/dt Casp3Bcl_2 in component Casp3Bcl_2 (micromolar)'); LEGEND_RATES(:,17) = strpad('d/dt Casp3Bid in component Casp3Bid (micromolar)'); LEGEND_RATES(:,3) = strpad('d/dt Bid in component Bid (micromolar)'); LEGEND_RATES(:,19) = strpad('d/dt Casp3IAP in component Casp3 (micromolar)'); LEGEND_RATES(:,15) = strpad('d/dt Casp3 in component Casp3 (micromolar)'); LEGEND_RATES(:,7) = strpad('d/dt Apop in component Apop (micromolar)'); LEGEND_RATES(:,20) = strpad('d/dt Pro9 in component Pro9 (micromolar)'); LEGEND_RATES(:,21) = strpad('d/dt ApopPro9 in component Pro9 (micromolar)'); LEGEND_RATES(:,22) = strpad('d/dt ApopPro9_2 in component ApopPro9_2 (micromolar)'); LEGEND_RATES(:,23) = strpad('d/dt ApopCasp9_2Pro3 in component ApopCasp9_2Pro3 (micromolar)'); LEGEND_RATES(:,26) = strpad('d/dt Casp9Pro3 in component Casp9Pro3 (micromolar)'); LEGEND_RATES(:,25) = strpad('d/dt Pro3 in component Pro3 (micromolar)'); LEGEND_RATES(:,28) = strpad('d/dt Casp9IAP in component IAP (micromolar)'); LEGEND_RATES(:,29) = strpad('d/dt ApopCasp9IAP in component IAP (micromolar)'); LEGEND_RATES(:,30) = strpad('d/dt ApopCasp9_2IAP in component IAP (micromolar)'); LEGEND_RATES(:,18) = strpad('d/dt IAP in component IAP (micromolar)'); LEGEND_RATES(:,31) = strpad('d/dt ApopCasp9 in component ApopCasp9 (micromolar)'); LEGEND_RATES(:,27) = strpad('d/dt Casp9 in component Casp9 (micromolar)'); LEGEND_RATES(:,24) = strpad('d/dt ApopCasp9_2 in component ApopCasp9_2 (micromolar)'); LEGEND_STATES = LEGEND_STATES'; LEGEND_ALGEBRAIC = LEGEND_ALGEBRAIC'; LEGEND_RATES = LEGEND_RATES'; LEGEND_CONSTANTS = LEGEND_CONSTANTS'; end function [STATES, CONSTANTS] = initConsts() VOI = 0; CONSTANTS = []; STATES = []; ALGEBRAIC = []; STATES(:,1) = 0; STATES(:,2) = 0; STATES(:,3) = 0.004; CONSTANTS(:,1) = 0.1; CONSTANTS(:,2) = 10; CONSTANTS(:,3) = 0.5; CONSTANTS(:,4) = 0.006; STATES(:,4) = 0.004; STATES(:,5) = 0; STATES(:,6) = 0; CONSTANTS(:,5) = 0.0003; CONSTANTS(:,6) = 5; CONSTANTS(:,7) = 0.5; STATES(:,7) = 0; CONSTANTS(:,8) = 50000; CONSTANTS(:,9) = 0.5; CONSTANTS(:,10) = 4; STATES(:,8) = 0.004; STATES(:,9) = 0; CONSTANTS(:,11) = 0.0003; CONSTANTS(:,12) = 10; STATES(:,10) = 0; STATES(:,11) = 0.004; CONSTANTS(:,13) = 10; STATES(:,12) = 0; CONSTANTS(:,14) = 10; STATES(:,13) = 0; CONSTANTS(:,15) = 10; STATES(:,14) = 0.004; CONSTANTS(:,16) = 10; CONSTANTS(:,17) = 0.00003; CONSTANTS(:,18) = 0.0066; CONSTANTS(:,19) = 0.004; CONSTANTS(:,20) = 0.006; STATES(:,15) = 0; STATES(:,16) = 0; CONSTANTS(:,21) = 10; CONSTANTS(:,22) = 0.5; CONSTANTS(:,23) = 0.00008; CONSTANTS(:,24) = 0.006; CONSTANTS(:,25) = 0.1; STATES(:,17) = 0; CONSTANTS(:,26) = 10; CONSTANTS(:,27) = 0.5; CONSTANTS(:,28) = 0.1; CONSTANTS(:,29) = 0.00003; STATES(:,18) = 0.004; STATES(:,19) = 0; CONSTANTS(:,30) = 5; CONSTANTS(:,31) = 0.0035; STATES(:,20) = 0.004; STATES(:,21) = 0; STATES(:,22) = 0; CONSTANTS(:,32) = 10; CONSTANTS(:,33) = 0.5; CONSTANTS(:,34) = 10; CONSTANTS(:,35) = 0.5; CONSTANTS(:,36) = 0.0003; CONSTANTS(:,37) = 0.1; STATES(:,23) = 0; STATES(:,24) = 0; STATES(:,25) = 0.004; CONSTANTS(:,38) = 10; CONSTANTS(:,39) = 0.5; CONSTANTS(:,40) = 0.1; STATES(:,26) = 0; CONSTANTS(:,41) = 0.001; STATES(:,27) = 0; CONSTANTS(:,42) = 10; CONSTANTS(:,43) = 0.5; CONSTANTS(:,44) = 0.0003; STATES(:,28) = 0; STATES(:,29) = 0; STATES(:,30) = 0; STATES(:,31) = 0; CONSTANTS(:,45) = 0.00003; CONSTANTS(:,46) = 5; CONSTANTS(:,47) = 0.0035; CONSTANTS(:,48) = 5; CONSTANTS(:,49) = 0.0035; CONSTANTS(:,50) = 5; CONSTANTS(:,51) = 0.0035; CONSTANTS(:,52) = 5; CONSTANTS(:,53) = 0.5; CONSTANTS(:,54) = 5; CONSTANTS(:,55) = 0.5; CONSTANTS(:,56) = CONSTANTS(:,17).*(1.00000+power(CONSTANTS(:,18), 4.00000)./(power(CONSTANTS(:,18), 4.00000)+power(CONSTANTS(:,19), 4.00000))); CONSTANTS(:,57) = ( CONSTANTS(:,23).*power(CONSTANTS(:,19), 4.00000))./(power(CONSTANTS(:,18), 4.00000)+power(CONSTANTS(:,19), 4.00000)); if (isempty(STATES)), warning('Initial values for states not set');, end end function [RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS) global algebraicVariableCount; statesSize = size(STATES); statesColumnCount = statesSize(2); if ( statesColumnCount == 1) STATES = STATES'; ALGEBRAIC = zeros(1, algebraicVariableCount); utilOnes = 1; else statesRowCount = statesSize(1); ALGEBRAIC = zeros(statesRowCount, algebraicVariableCount); RATES = zeros(statesRowCount, statesColumnCount); utilOnes = ones(statesRowCount, 1); end ALGEBRAIC(:,3) = CONSTANTS(:,2).*STATES(:,1).*STATES(:,3) - CONSTANTS(:,3).*STATES(:,2); ALGEBRAIC(:,1) = CONSTANTS(:,1).*STATES(:,2); ALGEBRAIC(:,2) = - CONSTANTS(:,4).*STATES(:,1); RATES(:,1) = - ALGEBRAIC(:,3)+ALGEBRAIC(:,1)+ALGEBRAIC(:,2); RATES(:,2) = ALGEBRAIC(:,3) - ALGEBRAIC(:,1); ALGEBRAIC(:,4) = CONSTANTS(:,5) - CONSTANTS(:,4).*STATES(:,4); ALGEBRAIC(:,5) = CONSTANTS(:,6).*STATES(:,6).*STATES(:,4) - CONSTANTS(:,7).*STATES(:,5); RATES(:,4) = - ALGEBRAIC(:,5)+ALGEBRAIC(:,4); ALGEBRAIC(:,7) = CONSTANTS(:,8).*power(STATES(:,5), CONSTANTS(:,10)) - CONSTANTS(:,9).*STATES(:,7); RATES(:,5) = ALGEBRAIC(:,5) - 7.00000.*ALGEBRAIC(:,7); ALGEBRAIC(:,10) = CONSTANTS(:,12).*STATES(:,9).*STATES(:,8); ALGEBRAIC(:,6) = - CONSTANTS(:,4).*STATES(:,6); RATES(:,6) = (ALGEBRAIC(:,10) - ALGEBRAIC(:,5))+ALGEBRAIC(:,6); ALGEBRAIC(:,8) = CONSTANTS(:,11) - CONSTANTS(:,4).*STATES(:,8); RATES(:,8) = - ALGEBRAIC(:,10)+ALGEBRAIC(:,8); ALGEBRAIC(:,13) = CONSTANTS(:,14).*STATES(:,12); ALGEBRAIC(:,12) = CONSTANTS(:,13).*STATES(:,10).*STATES(:,11); ALGEBRAIC(:,11) = - CONSTANTS(:,4).*STATES(:,10); RATES(:,10) = (ALGEBRAIC(:,13) - ALGEBRAIC(:,12))+ALGEBRAIC(:,11); ALGEBRAIC(:,16) = CONSTANTS(:,15).*STATES(:,13).*STATES(:,11); ALGEBRAIC(:,9) = - CONSTANTS(:,4).*STATES(:,9); RATES(:,9) = ALGEBRAIC(:,16)+ALGEBRAIC(:,9); ALGEBRAIC(:,15) = - CONSTANTS(:,4).*STATES(:,13); RATES(:,13) = (ALGEBRAIC(:,12) - ALGEBRAIC(:,16))+ALGEBRAIC(:,15); ALGEBRAIC(:,18) = CONSTANTS(:,16).*STATES(:,14).*STATES(:,11); ALGEBRAIC(:,17) = CONSTANTS(:,56) - CONSTANTS(:,20).*STATES(:,11); RATES(:,11) = (( - ALGEBRAIC(:,12) - ALGEBRAIC(:,16)) - ALGEBRAIC(:,18))+ALGEBRAIC(:,17); ALGEBRAIC(:,19) = CONSTANTS(:,21).*STATES(:,15).*STATES(:,14) - CONSTANTS(:,22).*STATES(:,16); ALGEBRAIC(:,21) = CONSTANTS(:,57) - CONSTANTS(:,24).*STATES(:,14); RATES(:,14) = ( - ALGEBRAIC(:,19) - ALGEBRAIC(:,18))+ALGEBRAIC(:,21); ALGEBRAIC(:,20) = CONSTANTS(:,25).*STATES(:,16); RATES(:,16) = ALGEBRAIC(:,19) - ALGEBRAIC(:,20); ALGEBRAIC(:,24) = CONSTANTS(:,28).*STATES(:,17); ALGEBRAIC(:,14) = - CONSTANTS(:,4).*STATES(:,12); RATES(:,12) = ((ALGEBRAIC(:,1)+ALGEBRAIC(:,24)) - ALGEBRAIC(:,13))+ALGEBRAIC(:,16)+ALGEBRAIC(:,14); ALGEBRAIC(:,22) = CONSTANTS(:,26).*STATES(:,15).*STATES(:,3) - CONSTANTS(:,27).*STATES(:,17); RATES(:,17) = ALGEBRAIC(:,22) - ALGEBRAIC(:,24); ALGEBRAIC(:,23) = CONSTANTS(:,29) - CONSTANTS(:,4).*STATES(:,3); RATES(:,3) = ( - ALGEBRAIC(:,3) - ALGEBRAIC(:,22))+ALGEBRAIC(:,23); ALGEBRAIC(:,26) = CONSTANTS(:,30).*STATES(:,15).*STATES(:,18) - CONSTANTS(:,31).*STATES(:,19); RATES(:,19) = ALGEBRAIC(:,26); ALGEBRAIC(:,28) = CONSTANTS(:,32).*STATES(:,7).*STATES(:,20) - CONSTANTS(:,33).*STATES(:,21); ALGEBRAIC(:,29) = CONSTANTS(:,34).*STATES(:,21).*STATES(:,20) - CONSTANTS(:,35).*STATES(:,22); ALGEBRAIC(:,27) = CONSTANTS(:,36) - CONSTANTS(:,4).*STATES(:,20); RATES(:,20) = ( - ALGEBRAIC(:,28) - ALGEBRAIC(:,29))+ALGEBRAIC(:,27); RATES(:,21) = ALGEBRAIC(:,28) - ALGEBRAIC(:,29); ALGEBRAIC(:,30) = CONSTANTS(:,37).*STATES(:,22); RATES(:,22) = ALGEBRAIC(:,29) - ALGEBRAIC(:,30); ALGEBRAIC(:,32) = CONSTANTS(:,40).*STATES(:,23); ALGEBRAIC(:,31) = CONSTANTS(:,38).*STATES(:,24).*STATES(:,25) - CONSTANTS(:,39).*STATES(:,23); RATES(:,23) = ALGEBRAIC(:,31) - ALGEBRAIC(:,32); ALGEBRAIC(:,33) = CONSTANTS(:,41).*STATES(:,26); ALGEBRAIC(:,25) = - CONSTANTS(:,4).*STATES(:,15); RATES(:,15) = (((((ALGEBRAIC(:,33)+ALGEBRAIC(:,32)) - ALGEBRAIC(:,26)) - ALGEBRAIC(:,22))+ALGEBRAIC(:,24)) - ALGEBRAIC(:,19))+ALGEBRAIC(:,20)+ALGEBRAIC(:,25); ALGEBRAIC(:,34) = CONSTANTS(:,42).*STATES(:,27).*STATES(:,25) - CONSTANTS(:,43).*STATES(:,26); RATES(:,26) = ALGEBRAIC(:,34) - ALGEBRAIC(:,33); ALGEBRAIC(:,35) = CONSTANTS(:,44) - CONSTANTS(:,4).*STATES(:,25); RATES(:,25) = ( - ALGEBRAIC(:,34) - ALGEBRAIC(:,31))+ALGEBRAIC(:,35); ALGEBRAIC(:,36) = CONSTANTS(:,46).*STATES(:,27).*STATES(:,18) - CONSTANTS(:,47).*STATES(:,28); RATES(:,28) = ALGEBRAIC(:,36); ALGEBRAIC(:,37) = CONSTANTS(:,48).*STATES(:,31).*STATES(:,18) - CONSTANTS(:,49).*STATES(:,29); RATES(:,29) = ALGEBRAIC(:,37); ALGEBRAIC(:,38) = CONSTANTS(:,50).*STATES(:,24).*STATES(:,18) - CONSTANTS(:,51).*STATES(:,30); RATES(:,30) = ALGEBRAIC(:,38); ALGEBRAIC(:,40) = CONSTANTS(:,45) - CONSTANTS(:,4).*STATES(:,18); RATES(:,18) = ((( - ALGEBRAIC(:,36) - ALGEBRAIC(:,37)) - ALGEBRAIC(:,38)) - ALGEBRAIC(:,26))+ALGEBRAIC(:,40); ALGEBRAIC(:,39) = CONSTANTS(:,52).*STATES(:,24) - CONSTANTS(:,53).*STATES(:,31).*STATES(:,27); RATES(:,24) = (((ALGEBRAIC(:,30) - ALGEBRAIC(:,39)) - ALGEBRAIC(:,38)) - ALGEBRAIC(:,31))+ALGEBRAIC(:,32); ALGEBRAIC(:,41) = CONSTANTS(:,54).*STATES(:,31) - CONSTANTS(:,55).*STATES(:,7).*STATES(:,27); RATES(:,7) = (ALGEBRAIC(:,7) - ALGEBRAIC(:,28))+ALGEBRAIC(:,41); RATES(:,31) = (ALGEBRAIC(:,39) - ALGEBRAIC(:,41)) - ALGEBRAIC(:,37); ALGEBRAIC(:,42) = - CONSTANTS(:,4).*STATES(:,27); RATES(:,27) = (((ALGEBRAIC(:,39)+ALGEBRAIC(:,41)) - ALGEBRAIC(:,36)) - ALGEBRAIC(:,34))+ALGEBRAIC(:,33)+ALGEBRAIC(:,42); RATES = RATES'; end % Calculate algebraic variables function ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI) statesSize = size(STATES); statesColumnCount = statesSize(2); if ( statesColumnCount == 1) STATES = STATES'; utilOnes = 1; else statesRowCount = statesSize(1); utilOnes = ones(statesRowCount, 1); end ALGEBRAIC(:,3) = CONSTANTS(:,2).*STATES(:,1).*STATES(:,3) - CONSTANTS(:,3).*STATES(:,2); ALGEBRAIC(:,1) = CONSTANTS(:,1).*STATES(:,2); ALGEBRAIC(:,2) = - CONSTANTS(:,4).*STATES(:,1); ALGEBRAIC(:,4) = CONSTANTS(:,5) - CONSTANTS(:,4).*STATES(:,4); ALGEBRAIC(:,5) = CONSTANTS(:,6).*STATES(:,6).*STATES(:,4) - CONSTANTS(:,7).*STATES(:,5); ALGEBRAIC(:,7) = CONSTANTS(:,8).*power(STATES(:,5), CONSTANTS(:,10)) - CONSTANTS(:,9).*STATES(:,7); ALGEBRAIC(:,10) = CONSTANTS(:,12).*STATES(:,9).*STATES(:,8); ALGEBRAIC(:,6) = - CONSTANTS(:,4).*STATES(:,6); ALGEBRAIC(:,8) = CONSTANTS(:,11) - CONSTANTS(:,4).*STATES(:,8); ALGEBRAIC(:,13) = CONSTANTS(:,14).*STATES(:,12); ALGEBRAIC(:,12) = CONSTANTS(:,13).*STATES(:,10).*STATES(:,11); ALGEBRAIC(:,11) = - CONSTANTS(:,4).*STATES(:,10); ALGEBRAIC(:,16) = CONSTANTS(:,15).*STATES(:,13).*STATES(:,11); ALGEBRAIC(:,9) = - CONSTANTS(:,4).*STATES(:,9); ALGEBRAIC(:,15) = - CONSTANTS(:,4).*STATES(:,13); ALGEBRAIC(:,18) = CONSTANTS(:,16).*STATES(:,14).*STATES(:,11); ALGEBRAIC(:,17) = CONSTANTS(:,56) - CONSTANTS(:,20).*STATES(:,11); ALGEBRAIC(:,19) = CONSTANTS(:,21).*STATES(:,15).*STATES(:,14) - CONSTANTS(:,22).*STATES(:,16); ALGEBRAIC(:,21) = CONSTANTS(:,57) - CONSTANTS(:,24).*STATES(:,14); ALGEBRAIC(:,20) = CONSTANTS(:,25).*STATES(:,16); ALGEBRAIC(:,24) = CONSTANTS(:,28).*STATES(:,17); ALGEBRAIC(:,14) = - CONSTANTS(:,4).*STATES(:,12); ALGEBRAIC(:,22) = CONSTANTS(:,26).*STATES(:,15).*STATES(:,3) - CONSTANTS(:,27).*STATES(:,17); ALGEBRAIC(:,23) = CONSTANTS(:,29) - CONSTANTS(:,4).*STATES(:,3); ALGEBRAIC(:,26) = CONSTANTS(:,30).*STATES(:,15).*STATES(:,18) - CONSTANTS(:,31).*STATES(:,19); ALGEBRAIC(:,28) = CONSTANTS(:,32).*STATES(:,7).*STATES(:,20) - CONSTANTS(:,33).*STATES(:,21); ALGEBRAIC(:,29) = CONSTANTS(:,34).*STATES(:,21).*STATES(:,20) - CONSTANTS(:,35).*STATES(:,22); ALGEBRAIC(:,27) = CONSTANTS(:,36) - CONSTANTS(:,4).*STATES(:,20); ALGEBRAIC(:,30) = CONSTANTS(:,37).*STATES(:,22); ALGEBRAIC(:,32) = CONSTANTS(:,40).*STATES(:,23); ALGEBRAIC(:,31) = CONSTANTS(:,38).*STATES(:,24).*STATES(:,25) - CONSTANTS(:,39).*STATES(:,23); ALGEBRAIC(:,33) = CONSTANTS(:,41).*STATES(:,26); ALGEBRAIC(:,25) = - CONSTANTS(:,4).*STATES(:,15); ALGEBRAIC(:,34) = CONSTANTS(:,42).*STATES(:,27).*STATES(:,25) - CONSTANTS(:,43).*STATES(:,26); ALGEBRAIC(:,35) = CONSTANTS(:,44) - CONSTANTS(:,4).*STATES(:,25); ALGEBRAIC(:,36) = CONSTANTS(:,46).*STATES(:,27).*STATES(:,18) - CONSTANTS(:,47).*STATES(:,28); ALGEBRAIC(:,37) = CONSTANTS(:,48).*STATES(:,31).*STATES(:,18) - CONSTANTS(:,49).*STATES(:,29); ALGEBRAIC(:,38) = CONSTANTS(:,50).*STATES(:,24).*STATES(:,18) - CONSTANTS(:,51).*STATES(:,30); ALGEBRAIC(:,40) = CONSTANTS(:,45) - CONSTANTS(:,4).*STATES(:,18); ALGEBRAIC(:,39) = CONSTANTS(:,52).*STATES(:,24) - CONSTANTS(:,53).*STATES(:,31).*STATES(:,27); ALGEBRAIC(:,41) = CONSTANTS(:,54).*STATES(:,31) - CONSTANTS(:,55).*STATES(:,7).*STATES(:,27); ALGEBRAIC(:,42) = - CONSTANTS(:,4).*STATES(:,27); end % Pad out or shorten strings to a set length function strout = strpad(strin) req_length = 160; insize = size(strin,2); if insize > req_length strout = strin(1:req_length); else strout = [strin, blanks(req_length - insize)]; end end