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 =35; end % There are a total of 29 entries in each of the rate and state variable arrays. % There are a total of 45 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 (minute)'); LEGEND_STATES(:,1) = strpad('BMK1 in component BMK1 (micromolar)'); LEGEND_ALGEBRAIC(:,10) = strpad('v10a in component v10 (flux)'); LEGEND_ALGEBRAIC(:,11) = strpad('v10b in component v10 (flux)'); LEGEND_STATES(:,2) = strpad('MRNA in component MRNA (micromolar)'); LEGEND_ALGEBRAIC(:,29) = strpad('v18 in component v18 (flux)'); LEGEND_ALGEBRAIC(:,31) = strpad('v19 in component v19 (flux)'); LEGEND_STATES(:,3) = strpad('NFATc in component NFATc (micromolar)'); LEGEND_ALGEBRAIC(:,1) = strpad('v1 in component v1 (flux)'); LEGEND_ALGEBRAIC(:,32) = strpad('v14 in component v14 (flux)'); LEGEND_ALGEBRAIC(:,35) = strpad('v15 in component v15 (flux)'); LEGEND_STATES(:,4) = strpad('NFATn in component NFATn (micromolar)'); LEGEND_ALGEBRAIC(:,20) = strpad('v16 in component v16 (flux)'); LEGEND_ALGEBRAIC(:,26) = strpad('v17 in component v17 (flux)'); LEGEND_STATES(:,5) = strpad('NFATpc in component NFATpc (micromolar)'); LEGEND_ALGEBRAIC(:,2) = strpad('v2 in component v2 (flux)'); LEGEND_ALGEBRAIC(:,9) = strpad('v9 in component v9 (flux)'); LEGEND_STATES(:,6) = strpad('NFATpn in component NFATpn (micromolar)'); LEGEND_STATES(:,7) = strpad('GSK3betac in component GSK3betac (micromolar)'); LEGEND_ALGEBRAIC(:,3) = strpad('v3 in component v3 (flux)'); LEGEND_ALGEBRAIC(:,17) = strpad('v12a in component v12 (flux)'); LEGEND_ALGEBRAIC(:,19) = strpad('v12b in component v12 (flux)'); LEGEND_ALGEBRAIC(:,33) = strpad('v15a in component v15 (flux)'); LEGEND_ALGEBRAIC(:,34) = strpad('v15b in component v15 (flux)'); LEGEND_STATES(:,8) = strpad('GSK3betan in component GSK3betan (micromolar)'); LEGEND_ALGEBRAIC(:,22) = strpad('v17a in component v17 (flux)'); LEGEND_ALGEBRAIC(:,24) = strpad('v17b in component v17 (flux)'); LEGEND_STATES(:,9) = strpad('CaNc in component CaNc (micromolar)'); LEGEND_ALGEBRAIC(:,6) = strpad('v6 in component v6 (flux)'); LEGEND_STATES(:,10) = strpad('CaNc_star in component CaNc_star (micromolar)'); LEGEND_ALGEBRAIC(:,4) = strpad('v4 in component v4 (flux)'); LEGEND_ALGEBRAIC(:,7) = strpad('v7 in component v7 (flux)'); LEGEND_ALGEBRAIC(:,13) = strpad('v11a in component v11 (flux)'); LEGEND_ALGEBRAIC(:,14) = strpad('v11b in component v11 (flux)'); LEGEND_ALGEBRAIC(:,23) = strpad('v13a in component v13 (flux)'); LEGEND_ALGEBRAIC(:,25) = strpad('v13b in component v13 (flux)'); LEGEND_ALGEBRAIC(:,27) = strpad('v14a in component v14 (flux)'); LEGEND_ALGEBRAIC(:,30) = strpad('v14b in component v14 (flux)'); LEGEND_STATES(:,11) = strpad('CaNn_star in component CaNn_star (micromolar)'); LEGEND_ALGEBRAIC(:,16) = strpad('v16a in component v16 (flux)'); LEGEND_ALGEBRAIC(:,18) = strpad('v16b in component v16 (flux)'); LEGEND_STATES(:,12) = strpad('CaNn in component CaNn (micromolar)'); LEGEND_STATES(:,13) = strpad('CaM in component CaM (micromolar)'); LEGEND_ALGEBRAIC(:,5) = strpad('v5 in component v5 (flux)'); LEGEND_STATES(:,14) = strpad('CaMCa in component CaMCa (micromolar)'); LEGEND_STATES(:,15) = strpad('MCIP in component MCIP (micromolar)'); LEGEND_ALGEBRAIC(:,12) = strpad('v10 in component v10 (flux)'); LEGEND_ALGEBRAIC(:,15) = strpad('v11 in component v11 (flux)'); LEGEND_STATES(:,16) = strpad('MCIPp in component MCIPp (micromolar)'); LEGEND_ALGEBRAIC(:,21) = strpad('v12 in component v12 (flux)'); LEGEND_ALGEBRAIC(:,28) = strpad('v13 in component v13 (flux)'); LEGEND_STATES(:,17) = strpad('MCIPpp in component MCIPpp (micromolar)'); LEGEND_ALGEBRAIC(:,8) = strpad('v8 in component v8 (flux)'); LEGEND_STATES(:,18) = strpad('Comp1 in component Comp1 (micromolar)'); LEGEND_STATES(:,19) = strpad('Comp2 in component Comp2 (micromolar)'); LEGEND_STATES(:,20) = strpad('Comp3 in component Comp3 (micromolar)'); LEGEND_STATES(:,21) = strpad('P1433 in component P1433 (micromolar)'); LEGEND_STATES(:,22) = strpad('MCIP_BMK1 in component MCIP_BMK1 (micromolar)'); LEGEND_STATES(:,23) = strpad('MCIPp_CaNc_star in component MCIPp_CaNc_star (micromolar)'); LEGEND_STATES(:,24) = strpad('MCIPp_GSK3betac in component MCIPp_GSK3betac (micromolar)'); LEGEND_STATES(:,25) = strpad('MCIPpp_CaNc_star in component MCIPpp_CaNc_star (micromolar)'); LEGEND_STATES(:,26) = strpad('NFATpc_CaNc_star in component NFATpc_CaNc_star (micromolar)'); LEGEND_STATES(:,27) = strpad('NFATc_GSK3betac in component NFATc_GSK3betac (micromolar)'); LEGEND_STATES(:,28) = strpad('NFATpn_CaNn_star in component NFATpn_CaNn_star (micromolar)'); LEGEND_STATES(:,29) = strpad('NFATn_GSK3betan in component NFATn_GSK3betan (micromolar)'); LEGEND_CONSTANTS(:,1) = strpad('k29 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,2) = strpad('k30 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,3) = strpad('k31 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,4) = strpad('k32 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,5) = strpad('k33 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,6) = strpad('k34 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,7) = strpad('Ca in component model_parameters (micromolar)'); LEGEND_CONSTANTS(:,8) = strpad('k1 in component model_parameters (fifth_order_rate_constant)'); LEGEND_CONSTANTS(:,9) = strpad('k2 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,10) = strpad('k3 in component model_parameters (second_order_rate_constant)'); LEGEND_CONSTANTS(:,11) = strpad('k4 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,12) = strpad('k5 in component model_parameters (second_order_rate_constant)'); LEGEND_CONSTANTS(:,13) = strpad('k6 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,14) = strpad('k19 in component model_parameters (second_order_rate_constant)'); LEGEND_CONSTANTS(:,15) = strpad('k20 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,16) = strpad('k27 in component model_parameters (second_order_rate_constant)'); LEGEND_CONSTANTS(:,17) = strpad('k28 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,18) = strpad('k7 in component model_parameters (second_order_rate_constant)'); LEGEND_CONSTANTS(:,19) = strpad('k8 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,20) = strpad('k9 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,21) = strpad('k10 in component model_parameters (second_order_rate_constant)'); LEGEND_CONSTANTS(:,22) = strpad('k11 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,23) = strpad('k12 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,24) = strpad('k13 in component model_parameters (second_order_rate_constant)'); LEGEND_CONSTANTS(:,25) = strpad('k14 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,26) = strpad('k15 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,27) = strpad('k16 in component model_parameters (second_order_rate_constant)'); LEGEND_CONSTANTS(:,28) = strpad('k17 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,29) = strpad('k18 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,30) = strpad('k21 in component model_parameters (second_order_rate_constant)'); LEGEND_CONSTANTS(:,31) = strpad('k22 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,32) = strpad('k23 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,33) = strpad('k24 in component model_parameters (second_order_rate_constant)'); LEGEND_CONSTANTS(:,34) = strpad('k25 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,35) = strpad('k26 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,36) = strpad('k35 in component model_parameters (second_order_rate_constant)'); LEGEND_CONSTANTS(:,37) = strpad('k36 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,38) = strpad('k37 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,39) = strpad('k38 in component model_parameters (second_order_rate_constant)'); LEGEND_CONSTANTS(:,40) = strpad('k39 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,41) = strpad('k40 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,42) = strpad('k41 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,43) = strpad('k42 in component model_parameters (first_order_rate_constant)'); LEGEND_CONSTANTS(:,44) = strpad('t_half in component model_parameters (minute)'); LEGEND_CONSTANTS(:,45) = strpad('k43 in component model_parameters (first_order_rate_constant)'); LEGEND_RATES(:,1) = strpad('d/dt BMK1 in component BMK1 (micromolar)'); LEGEND_RATES(:,2) = strpad('d/dt MRNA in component MRNA (micromolar)'); LEGEND_RATES(:,3) = strpad('d/dt NFATc in component NFATc (micromolar)'); LEGEND_RATES(:,4) = strpad('d/dt NFATn in component NFATn (micromolar)'); LEGEND_RATES(:,5) = strpad('d/dt NFATpc in component NFATpc (micromolar)'); LEGEND_RATES(:,6) = strpad('d/dt NFATpn in component NFATpn (micromolar)'); LEGEND_RATES(:,7) = strpad('d/dt GSK3betac in component GSK3betac (micromolar)'); LEGEND_RATES(:,8) = strpad('d/dt GSK3betan in component GSK3betan (micromolar)'); LEGEND_RATES(:,9) = strpad('d/dt CaNc in component CaNc (micromolar)'); LEGEND_RATES(:,10) = strpad('d/dt CaNc_star in component CaNc_star (micromolar)'); LEGEND_RATES(:,11) = strpad('d/dt CaNn_star in component CaNn_star (micromolar)'); LEGEND_RATES(:,12) = strpad('d/dt CaNn in component CaNn (micromolar)'); LEGEND_RATES(:,13) = strpad('d/dt CaM in component CaM (micromolar)'); LEGEND_RATES(:,14) = strpad('d/dt CaMCa in component CaMCa (micromolar)'); LEGEND_RATES(:,15) = strpad('d/dt MCIP in component MCIP (micromolar)'); LEGEND_RATES(:,16) = strpad('d/dt MCIPp in component MCIPp (micromolar)'); LEGEND_RATES(:,17) = strpad('d/dt MCIPpp in component MCIPpp (micromolar)'); LEGEND_RATES(:,18) = strpad('d/dt Comp1 in component Comp1 (micromolar)'); LEGEND_RATES(:,19) = strpad('d/dt Comp2 in component Comp2 (micromolar)'); LEGEND_RATES(:,20) = strpad('d/dt Comp3 in component Comp3 (micromolar)'); LEGEND_RATES(:,21) = strpad('d/dt P1433 in component P1433 (micromolar)'); LEGEND_RATES(:,22) = strpad('d/dt MCIP_BMK1 in component MCIP_BMK1 (micromolar)'); LEGEND_RATES(:,23) = strpad('d/dt MCIPp_CaNc_star in component MCIPp_CaNc_star (micromolar)'); LEGEND_RATES(:,24) = strpad('d/dt MCIPp_GSK3betac in component MCIPp_GSK3betac (micromolar)'); LEGEND_RATES(:,25) = strpad('d/dt MCIPpp_CaNc_star in component MCIPpp_CaNc_star (micromolar)'); LEGEND_RATES(:,26) = strpad('d/dt NFATpc_CaNc_star in component NFATpc_CaNc_star (micromolar)'); LEGEND_RATES(:,27) = strpad('d/dt NFATc_GSK3betac in component NFATc_GSK3betac (micromolar)'); LEGEND_RATES(:,28) = strpad('d/dt NFATpn_CaNn_star in component NFATpn_CaNn_star (micromolar)'); LEGEND_RATES(:,29) = strpad('d/dt NFATn_GSK3betan in component NFATn_GSK3betan (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.012; STATES(:,2) = 3.33E-4; STATES(:,3) = 2E-5; STATES(:,4) = 4.99E-4; STATES(:,5) = 4.94E-3; STATES(:,6) = 8.01E-5; STATES(:,7) = 0.17; STATES(:,8) = 0.339; STATES(:,9) = 0.91; STATES(:,10) = 0.0275; STATES(:,11) = 0.0568; STATES(:,12) = 0.0057; STATES(:,13) = 25.2; STATES(:,14) = 7.88E-7; STATES(:,15) = 2.15E-4; STATES(:,16) = 7.76E-3; STATES(:,17) = 0.0798; STATES(:,18) = 5.21E-3; STATES(:,19) = 0.283; STATES(:,20) = 0.014; STATES(:,21) = 0.708; STATES(:,22) = 2.14E-5; STATES(:,23) = 1.07E-4; STATES(:,24) = 1.1E-3; STATES(:,25) = 1.1E-3; STATES(:,26) = 8.15E-5; STATES(:,27) = 1.36E-6; STATES(:,28) = 2.27E-6; STATES(:,29) = 8.46E-5; CONSTANTS(:,1) = 0.4; CONSTANTS(:,2) = 0.1; CONSTANTS(:,3) = 0.1; CONSTANTS(:,4) = 0.05; CONSTANTS(:,5) = 0.114; CONSTANTS(:,6) = 0.0552; CONSTANTS(:,7) = 0.2; CONSTANTS(:,8) = 5; CONSTANTS(:,9) = 100; CONSTANTS(:,10) = 2760; CONSTANTS(:,11) = 0.072; CONSTANTS(:,12) = 50; CONSTANTS(:,13) = 0.0567; CONSTANTS(:,14) = 0.5; CONSTANTS(:,15) = 0.1; CONSTANTS(:,16) = 0.4; CONSTANTS(:,17) = 0.1; CONSTANTS(:,18) = 5; CONSTANTS(:,19) = 0.1; CONSTANTS(:,20) = 0.5; CONSTANTS(:,21) = 0.1; CONSTANTS(:,22) = 0.1; CONSTANTS(:,23) = 0.1; CONSTANTS(:,24) = 0.5; CONSTANTS(:,25) = 0.5; CONSTANTS(:,26) = 0.1; CONSTANTS(:,27) = 0.1; CONSTANTS(:,28) = 0.1; CONSTANTS(:,29) = 0.1; CONSTANTS(:,30) = 0.15; CONSTANTS(:,31) = 0.15; CONSTANTS(:,32) = 0.15; CONSTANTS(:,33) = 0.1; CONSTANTS(:,34) = 0.15; CONSTANTS(:,35) = 0.1; CONSTANTS(:,36) = 0.15; CONSTANTS(:,37) = 0.1; CONSTANTS(:,38) = 0.2; CONSTANTS(:,39) = 0.1; CONSTANTS(:,40) = 0.1; CONSTANTS(:,41) = 0.1; CONSTANTS(:,42) = 0.02; CONSTANTS(:,43) = 0.03; CONSTANTS(:,44) = 15; CONSTANTS(:,45) = 0.03; 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(:,5) = CONSTANTS(:,8).*STATES(:,13).*power(CONSTANTS(:,7), 4.00000) - CONSTANTS(:,9).*STATES(:,14); RATES(:,13) = - ALGEBRAIC(:,5); ALGEBRAIC(:,6) = CONSTANTS(:,10).*STATES(:,14).*STATES(:,9) - CONSTANTS(:,11).*STATES(:,10); RATES(:,9) = - ALGEBRAIC(:,6); RATES(:,12) = - ALGEBRAIC(:,6); RATES(:,14) = ALGEBRAIC(:,5) - ALGEBRAIC(:,6); ALGEBRAIC(:,7) = CONSTANTS(:,12).*STATES(:,10).*STATES(:,15) - CONSTANTS(:,13).*STATES(:,18); RATES(:,18) = ALGEBRAIC(:,7); ALGEBRAIC(:,8) = CONSTANTS(:,14).*STATES(:,21).*STATES(:,17) - CONSTANTS(:,15).*STATES(:,19); RATES(:,19) = ALGEBRAIC(:,8); ALGEBRAIC(:,9) = CONSTANTS(:,16).*STATES(:,5).*STATES(:,21) - CONSTANTS(:,17).*STATES(:,20); RATES(:,20) = ALGEBRAIC(:,9); RATES(:,21) = - (ALGEBRAIC(:,8)+ALGEBRAIC(:,9)); ALGEBRAIC(:,10) = CONSTANTS(:,18).*STATES(:,15).*STATES(:,1) - CONSTANTS(:,19).*STATES(:,22); ALGEBRAIC(:,11) = CONSTANTS(:,20).*STATES(:,22); RATES(:,1) = ALGEBRAIC(:,11) - ALGEBRAIC(:,10); RATES(:,22) = ALGEBRAIC(:,10) - ALGEBRAIC(:,11); ALGEBRAIC(:,13) = CONSTANTS(:,21).*STATES(:,16).*STATES(:,10) - CONSTANTS(:,22).*STATES(:,23); ALGEBRAIC(:,14) = CONSTANTS(:,23).*STATES(:,23); RATES(:,23) = ALGEBRAIC(:,13) - ALGEBRAIC(:,14); ALGEBRAIC(:,4) = CONSTANTS(:,5).*STATES(:,10) - CONSTANTS(:,6).*STATES(:,11); ALGEBRAIC(:,16) = CONSTANTS(:,36).*STATES(:,6).*STATES(:,11) - CONSTANTS(:,37).*STATES(:,28); ALGEBRAIC(:,18) = CONSTANTS(:,38).*STATES(:,28); RATES(:,11) = (ALGEBRAIC(:,4)+ALGEBRAIC(:,18)) - ALGEBRAIC(:,16); ALGEBRAIC(:,17) = CONSTANTS(:,24).*STATES(:,16).*STATES(:,7) - CONSTANTS(:,25).*STATES(:,24); ALGEBRAIC(:,19) = CONSTANTS(:,26).*STATES(:,24); RATES(:,24) = ALGEBRAIC(:,17) - ALGEBRAIC(:,19); RATES(:,28) = ALGEBRAIC(:,16) - ALGEBRAIC(:,18); ALGEBRAIC(:,3) = CONSTANTS(:,3).*STATES(:,7) - CONSTANTS(:,4).*STATES(:,8); ALGEBRAIC(:,22) = CONSTANTS(:,39).*STATES(:,4).*STATES(:,8) - CONSTANTS(:,40).*STATES(:,29); ALGEBRAIC(:,24) = CONSTANTS(:,41).*STATES(:,29); RATES(:,8) = (ALGEBRAIC(:,3)+ALGEBRAIC(:,24)) - ALGEBRAIC(:,22); ALGEBRAIC(:,23) = CONSTANTS(:,27).*STATES(:,17).*STATES(:,10) - CONSTANTS(:,28).*STATES(:,25); ALGEBRAIC(:,25) = CONSTANTS(:,29).*STATES(:,25); RATES(:,25) = ALGEBRAIC(:,23) - ALGEBRAIC(:,25); RATES(:,29) = ALGEBRAIC(:,22) - ALGEBRAIC(:,24); ALGEBRAIC(:,20) = ALGEBRAIC(:,16)+ALGEBRAIC(:,18); ALGEBRAIC(:,26) = ALGEBRAIC(:,22)+ALGEBRAIC(:,24); ALGEBRAIC(:,2) = CONSTANTS(:,2).*STATES(:,6); RATES(:,6) = ALGEBRAIC(:,26) - (ALGEBRAIC(:,2)+ALGEBRAIC(:,20)); ALGEBRAIC(:,12) = ALGEBRAIC(:,10)+ALGEBRAIC(:,11); ALGEBRAIC(:,15) = ALGEBRAIC(:,13)+ALGEBRAIC(:,14); ALGEBRAIC(:,21) = ALGEBRAIC(:,17)+ALGEBRAIC(:,19); ALGEBRAIC(:,28) = ALGEBRAIC(:,23)+ALGEBRAIC(:,25); RATES(:,16) = (ALGEBRAIC(:,12)+ALGEBRAIC(:,28)) - (ALGEBRAIC(:,15)+ALGEBRAIC(:,21)); RATES(:,17) = ALGEBRAIC(:,21) - (ALGEBRAIC(:,8)+ALGEBRAIC(:,28)); ALGEBRAIC(:,29) = CONSTANTS(:,42).*STATES(:,4) - CONSTANTS(:,43).*STATES(:,2); ALGEBRAIC(:,1) = CONSTANTS(:,1).*STATES(:,3); RATES(:,4) = (ALGEBRAIC(:,1)+ALGEBRAIC(:,20)) - (ALGEBRAIC(:,26)+ALGEBRAIC(:,29)); ALGEBRAIC(:,27) = CONSTANTS(:,30).*STATES(:,5).*STATES(:,10) - CONSTANTS(:,31).*STATES(:,26); ALGEBRAIC(:,30) = CONSTANTS(:,32).*STATES(:,26); RATES(:,10) = (ALGEBRAIC(:,6)+ALGEBRAIC(:,14)+ALGEBRAIC(:,25)+ALGEBRAIC(:,30)) - (ALGEBRAIC(:,4)+ALGEBRAIC(:,7)+ALGEBRAIC(:,13)+ALGEBRAIC(:,23)+ALGEBRAIC(:,27)); RATES(:,26) = ALGEBRAIC(:,27) - ALGEBRAIC(:,30); ALGEBRAIC(:,31) = CONSTANTS(:,45).*STATES(:,2) - (log(2.00000)./CONSTANTS(:,44)).*STATES(:,15); RATES(:,2) = ALGEBRAIC(:,31) - ALGEBRAIC(:,29); RATES(:,15) = ALGEBRAIC(:,15) - (ALGEBRAIC(:,7)+ALGEBRAIC(:,12)+ALGEBRAIC(:,31)); ALGEBRAIC(:,33) = CONSTANTS(:,33).*STATES(:,3).*STATES(:,7) - CONSTANTS(:,34).*STATES(:,27); ALGEBRAIC(:,34) = CONSTANTS(:,35).*STATES(:,27); RATES(:,7) = (ALGEBRAIC(:,19)+ALGEBRAIC(:,34)) - (ALGEBRAIC(:,3)+ALGEBRAIC(:,17)+ALGEBRAIC(:,33)); RATES(:,27) = ALGEBRAIC(:,33) - ALGEBRAIC(:,34); ALGEBRAIC(:,32) = ALGEBRAIC(:,27)+ALGEBRAIC(:,30); ALGEBRAIC(:,35) = ALGEBRAIC(:,33)+ALGEBRAIC(:,34); RATES(:,3) = ALGEBRAIC(:,32) - (ALGEBRAIC(:,1)+ALGEBRAIC(:,35)); RATES(:,5) = (ALGEBRAIC(:,2)+ALGEBRAIC(:,35)) - (ALGEBRAIC(:,9)+ALGEBRAIC(:,32)); 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(:,5) = CONSTANTS(:,8).*STATES(:,13).*power(CONSTANTS(:,7), 4.00000) - CONSTANTS(:,9).*STATES(:,14); ALGEBRAIC(:,6) = CONSTANTS(:,10).*STATES(:,14).*STATES(:,9) - CONSTANTS(:,11).*STATES(:,10); ALGEBRAIC(:,7) = CONSTANTS(:,12).*STATES(:,10).*STATES(:,15) - CONSTANTS(:,13).*STATES(:,18); ALGEBRAIC(:,8) = CONSTANTS(:,14).*STATES(:,21).*STATES(:,17) - CONSTANTS(:,15).*STATES(:,19); ALGEBRAIC(:,9) = CONSTANTS(:,16).*STATES(:,5).*STATES(:,21) - CONSTANTS(:,17).*STATES(:,20); ALGEBRAIC(:,10) = CONSTANTS(:,18).*STATES(:,15).*STATES(:,1) - CONSTANTS(:,19).*STATES(:,22); ALGEBRAIC(:,11) = CONSTANTS(:,20).*STATES(:,22); ALGEBRAIC(:,13) = CONSTANTS(:,21).*STATES(:,16).*STATES(:,10) - CONSTANTS(:,22).*STATES(:,23); ALGEBRAIC(:,14) = CONSTANTS(:,23).*STATES(:,23); ALGEBRAIC(:,4) = CONSTANTS(:,5).*STATES(:,10) - CONSTANTS(:,6).*STATES(:,11); ALGEBRAIC(:,16) = CONSTANTS(:,36).*STATES(:,6).*STATES(:,11) - CONSTANTS(:,37).*STATES(:,28); ALGEBRAIC(:,18) = CONSTANTS(:,38).*STATES(:,28); ALGEBRAIC(:,17) = CONSTANTS(:,24).*STATES(:,16).*STATES(:,7) - CONSTANTS(:,25).*STATES(:,24); ALGEBRAIC(:,19) = CONSTANTS(:,26).*STATES(:,24); ALGEBRAIC(:,3) = CONSTANTS(:,3).*STATES(:,7) - CONSTANTS(:,4).*STATES(:,8); ALGEBRAIC(:,22) = CONSTANTS(:,39).*STATES(:,4).*STATES(:,8) - CONSTANTS(:,40).*STATES(:,29); ALGEBRAIC(:,24) = CONSTANTS(:,41).*STATES(:,29); ALGEBRAIC(:,23) = CONSTANTS(:,27).*STATES(:,17).*STATES(:,10) - CONSTANTS(:,28).*STATES(:,25); ALGEBRAIC(:,25) = CONSTANTS(:,29).*STATES(:,25); ALGEBRAIC(:,20) = ALGEBRAIC(:,16)+ALGEBRAIC(:,18); ALGEBRAIC(:,26) = ALGEBRAIC(:,22)+ALGEBRAIC(:,24); ALGEBRAIC(:,2) = CONSTANTS(:,2).*STATES(:,6); ALGEBRAIC(:,12) = ALGEBRAIC(:,10)+ALGEBRAIC(:,11); ALGEBRAIC(:,15) = ALGEBRAIC(:,13)+ALGEBRAIC(:,14); ALGEBRAIC(:,21) = ALGEBRAIC(:,17)+ALGEBRAIC(:,19); ALGEBRAIC(:,28) = ALGEBRAIC(:,23)+ALGEBRAIC(:,25); ALGEBRAIC(:,29) = CONSTANTS(:,42).*STATES(:,4) - CONSTANTS(:,43).*STATES(:,2); ALGEBRAIC(:,1) = CONSTANTS(:,1).*STATES(:,3); ALGEBRAIC(:,27) = CONSTANTS(:,30).*STATES(:,5).*STATES(:,10) - CONSTANTS(:,31).*STATES(:,26); ALGEBRAIC(:,30) = CONSTANTS(:,32).*STATES(:,26); ALGEBRAIC(:,31) = CONSTANTS(:,45).*STATES(:,2) - (log(2.00000)./CONSTANTS(:,44)).*STATES(:,15); ALGEBRAIC(:,33) = CONSTANTS(:,33).*STATES(:,3).*STATES(:,7) - CONSTANTS(:,34).*STATES(:,27); ALGEBRAIC(:,34) = CONSTANTS(:,35).*STATES(:,27); ALGEBRAIC(:,32) = ALGEBRAIC(:,27)+ALGEBRAIC(:,30); ALGEBRAIC(:,35) = ALGEBRAIC(:,33)+ALGEBRAIC(:,34); 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