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 =40; end % There are a total of 11 entries in each of the rate and state variable arrays. % There are a total of 24 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('t in component environment (second)'); LEGEND_CONSTANTS(:,1) = strpad('R in component environment (J_per_K_per_mol)'); LEGEND_CONSTANTS(:,2) = strpad('T in component environment (kelvin)'); LEGEND_CONSTANTS(:,3) = strpad('F in component environment (C_per_mol)'); LEGEND_CONSTANTS(:,4) = strpad('C_m in component environment (fF)'); LEGEND_STATES(:,1) = strpad('q_Ca_o in component environment (fmol)'); LEGEND_STATES(:,2) = strpad('q_Ca_i in component environment (fmol)'); LEGEND_STATES(:,3) = strpad('q_Na_o in component environment (fmol)'); LEGEND_STATES(:,4) = strpad('q_Na_i in component environment (fmol)'); LEGEND_STATES(:,5) = strpad('q_P1_NCX in component environment (fmol)'); LEGEND_STATES(:,6) = strpad('q_P2_NCX in component environment (fmol)'); LEGEND_STATES(:,7) = strpad('q_P3_NCX in component environment (fmol)'); LEGEND_STATES(:,8) = strpad('q_P4_NCX in component environment (fmol)'); LEGEND_STATES(:,9) = strpad('q_P5_NCX in component environment (fmol)'); LEGEND_STATES(:,10) = strpad('q_P6_NCX in component environment (fmol)'); LEGEND_ALGEBRAIC(:,30) = strpad('v_Ca_o_NCX in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,23) = strpad('v_Ca_i_NCX in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,34) = strpad('v_Na_o_NCX in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,20) = strpad('v_Na_i_NCX in component NCX (fmol_per_sec)'); LEGEND_STATES(:,11) = strpad('q_mem in component environment (fC)'); LEGEND_ALGEBRAIC(:,38) = strpad('I_mem_NCX in component NCX (fA)'); LEGEND_CONSTANTS(:,5) = strpad('kappa_1_NCX in component NCX_parameters (fmol_per_sec)'); LEGEND_CONSTANTS(:,6) = strpad('kappa_2_NCX in component NCX_parameters (fmol_per_sec)'); LEGEND_CONSTANTS(:,7) = strpad('kappa_3_NCX in component NCX_parameters (fmol_per_sec)'); LEGEND_CONSTANTS(:,8) = strpad('kappa_4_NCX in component NCX_parameters (fmol_per_sec)'); LEGEND_CONSTANTS(:,9) = strpad('kappa_5_NCX in component NCX_parameters (fmol_per_sec)'); LEGEND_CONSTANTS(:,10) = strpad('kappa_6_NCX in component NCX_parameters (fmol_per_sec)'); LEGEND_CONSTANTS(:,11) = strpad('K_1_NCX in component NCX_parameters (per_fmol)'); LEGEND_CONSTANTS(:,12) = strpad('K_2_NCX in component NCX_parameters (per_fmol)'); LEGEND_CONSTANTS(:,13) = strpad('K_3_NCX in component NCX_parameters (per_fmol)'); LEGEND_CONSTANTS(:,14) = strpad('K_4_NCX in component NCX_parameters (per_fmol)'); LEGEND_CONSTANTS(:,15) = strpad('K_5_NCX in component NCX_parameters (per_fmol)'); LEGEND_CONSTANTS(:,16) = strpad('K_6_NCX in component NCX_parameters (per_fmol)'); LEGEND_CONSTANTS(:,17) = strpad('K_Na_i in component NCX_parameters (per_fmol)'); LEGEND_CONSTANTS(:,18) = strpad('K_Ca_i in component NCX_parameters (per_fmol)'); LEGEND_CONSTANTS(:,19) = strpad('K_Na_o in component NCX_parameters (per_fmol)'); LEGEND_CONSTANTS(:,20) = strpad('K_Ca_o in component NCX_parameters (per_fmol)'); LEGEND_CONSTANTS(:,21) = strpad('nNa_o_NCX in component NCX_parameters (dimensionless)'); LEGEND_CONSTANTS(:,22) = strpad('nNa_i_NCX in component NCX_parameters (dimensionless)'); LEGEND_CONSTANTS(:,23) = strpad('zf_NCX in component NCX_parameters (dimensionless)'); LEGEND_CONSTANTS(:,24) = strpad('zr_NCX in component NCX_parameters (dimensionless)'); LEGEND_ALGEBRAIC(:,2) = strpad('mu_Ca_o in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,3) = strpad('mu_Ca_i in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,4) = strpad('mu_Na_o in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,5) = strpad('mu_Na_i in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,6) = strpad('mu_P1_NCX in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,7) = strpad('mu_P2_NCX in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,8) = strpad('mu_P3_NCX in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,9) = strpad('mu_P4_NCX in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,10) = strpad('mu_P5_NCX in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,11) = strpad('mu_P6_NCX in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,39) = strpad('v_P1_NCX in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,24) = strpad('v_P2_NCX in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,27) = strpad('v_P3_NCX in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,31) = strpad('v_P4_NCX in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,36) = strpad('v_P5_NCX in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,40) = strpad('v_P6_NCX in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,12) = strpad('Af_r1 in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,18) = strpad('Ar_r1 in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,19) = strpad('v_r1 in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,13) = strpad('Af_r2 in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,21) = strpad('Ar_r2 in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,22) = strpad('v_r2 in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,14) = strpad('Af_r3 in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,25) = strpad('Ar_r3 in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,26) = strpad('v_r3 in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,15) = strpad('Af_r4 in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,28) = strpad('Ar_r4 in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,29) = strpad('v_r4 in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,16) = strpad('Af_r5 in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,32) = strpad('Ar_r5 in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,33) = strpad('v_r5 in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,17) = strpad('Af_r6 in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,35) = strpad('Ar_r6 in component NCX (J_per_mol)'); LEGEND_ALGEBRAIC(:,37) = strpad('v_r6 in component NCX (fmol_per_sec)'); LEGEND_ALGEBRAIC(:,1) = strpad('V_mem in component NCX (volt)'); LEGEND_RATES(:,1) = strpad('d/dt q_Ca_o in component environment (fmol)'); LEGEND_RATES(:,2) = strpad('d/dt q_Ca_i in component environment (fmol)'); LEGEND_RATES(:,3) = strpad('d/dt q_Na_o in component environment (fmol)'); LEGEND_RATES(:,4) = strpad('d/dt q_Na_i in component environment (fmol)'); LEGEND_RATES(:,11) = strpad('d/dt q_mem in component environment (fC)'); LEGEND_RATES(:,5) = strpad('d/dt q_P1_NCX in component environment (fmol)'); LEGEND_RATES(:,6) = strpad('d/dt q_P2_NCX in component environment (fmol)'); LEGEND_RATES(:,7) = strpad('d/dt q_P3_NCX in component environment (fmol)'); LEGEND_RATES(:,8) = strpad('d/dt q_P4_NCX in component environment (fmol)'); LEGEND_RATES(:,9) = strpad('d/dt q_P5_NCX in component environment (fmol)'); LEGEND_RATES(:,10) = strpad('d/dt q_P6_NCX in component environment (fmol)'); 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 = []; CONSTANTS(:,1) = 8.314; CONSTANTS(:,2) = 310; CONSTANTS(:,3) = 96485; CONSTANTS(:,4) = 153400; STATES(:,1) = 9.3276; STATES(:,2) = 0.00456; STATES(:,3) = 725.48; STATES(:,4) = 380; STATES(:,5) = 0.000103509; STATES(:,6) = 0.000103509; STATES(:,7) = 0.000103509; STATES(:,8) = 0.000103509; STATES(:,9) = 0.000103509; STATES(:,10) = 0.000103509; STATES(:,11) = -13039; CONSTANTS(:,5) = 417309; CONSTANTS(:,6) = 1.39522e+07; CONSTANTS(:,7) = 472.755; CONSTANTS(:,8) = 1.39522e+07; CONSTANTS(:,9) = 417309; CONSTANTS(:,10) = 0.370405; CONSTANTS(:,11) = 2.93394e+08; CONSTANTS(:,12) = 14.1045; CONSTANTS(:,13) = 263471; CONSTANTS(:,14) = 2.39875e+06; CONSTANTS(:,15) = 2373.73; CONSTANTS(:,16) = 956.214; CONSTANTS(:,17) = 0.0137751; CONSTANTS(:,18) = 10.2446; CONSTANTS(:,19) = 0.470129; CONSTANTS(:,20) = 7572.91; CONSTANTS(:,21) = 3; CONSTANTS(:,22) = 3; CONSTANTS(:,23) = -0.55679; CONSTANTS(:,24) = 0.44321; 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(:,6) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,11).*STATES(:,5)); ALGEBRAIC(:,12) = ALGEBRAIC(:,6); ALGEBRAIC(:,5) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,17).*STATES(:,4)); ALGEBRAIC(:,7) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,12).*STATES(:,6)); ALGEBRAIC(:,18) = CONSTANTS(:,22).*ALGEBRAIC(:,5)+ALGEBRAIC(:,7); ALGEBRAIC(:,19) = CONSTANTS(:,5).*(exp(ALGEBRAIC(:,12)./( CONSTANTS(:,1).*CONSTANTS(:,2))) - exp(ALGEBRAIC(:,18)./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,20) = CONSTANTS(:,22).*ALGEBRAIC(:,19); RATES(:,4) = ALGEBRAIC(:,20); ALGEBRAIC(:,3) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,18).*STATES(:,2)); ALGEBRAIC(:,13) = ALGEBRAIC(:,7)+ALGEBRAIC(:,3); ALGEBRAIC(:,8) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,13).*STATES(:,7)); ALGEBRAIC(:,21) = ALGEBRAIC(:,8); ALGEBRAIC(:,22) = CONSTANTS(:,6).*(exp(ALGEBRAIC(:,13)./( CONSTANTS(:,1).*CONSTANTS(:,2))) - exp(ALGEBRAIC(:,21)./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,23) = - ALGEBRAIC(:,22); RATES(:,2) = ALGEBRAIC(:,23); ALGEBRAIC(:,24) = ALGEBRAIC(:,19) - ALGEBRAIC(:,22); RATES(:,6) = ALGEBRAIC(:,24); ALGEBRAIC(:,14) = ALGEBRAIC(:,8); ALGEBRAIC(:,9) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,14).*STATES(:,8)); ALGEBRAIC(:,25) = ALGEBRAIC(:,9); ALGEBRAIC(:,26) = CONSTANTS(:,7).*(exp(ALGEBRAIC(:,14)./( CONSTANTS(:,1).*CONSTANTS(:,2))) - exp(ALGEBRAIC(:,25)./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,27) = ALGEBRAIC(:,22) - ALGEBRAIC(:,26); RATES(:,7) = ALGEBRAIC(:,27); ALGEBRAIC(:,15) = ALGEBRAIC(:,9); ALGEBRAIC(:,2) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,20).*STATES(:,1)); ALGEBRAIC(:,10) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,15).*STATES(:,9)); ALGEBRAIC(:,28) = ALGEBRAIC(:,10)+ALGEBRAIC(:,2); ALGEBRAIC(:,29) = CONSTANTS(:,8).*(exp(ALGEBRAIC(:,15)./( CONSTANTS(:,1).*CONSTANTS(:,2))) - exp(ALGEBRAIC(:,28)./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,30) = ALGEBRAIC(:,29); RATES(:,1) = ALGEBRAIC(:,30); ALGEBRAIC(:,31) = - ALGEBRAIC(:,29)+ALGEBRAIC(:,26); RATES(:,8) = ALGEBRAIC(:,31); ALGEBRAIC(:,4) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,19).*STATES(:,3)); ALGEBRAIC(:,16) = ALGEBRAIC(:,10)+ CONSTANTS(:,21).*ALGEBRAIC(:,4); ALGEBRAIC(:,11) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,16).*STATES(:,10)); ALGEBRAIC(:,32) = ALGEBRAIC(:,11); ALGEBRAIC(:,33) = CONSTANTS(:,9).*(exp(ALGEBRAIC(:,16)./( CONSTANTS(:,1).*CONSTANTS(:,2))) - exp(ALGEBRAIC(:,32)./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,34) = - CONSTANTS(:,21).*ALGEBRAIC(:,33); RATES(:,3) = ALGEBRAIC(:,34); ALGEBRAIC(:,36) = - ALGEBRAIC(:,33)+ALGEBRAIC(:,29); RATES(:,9) = ALGEBRAIC(:,36); ALGEBRAIC(:,1) = STATES(:,11)./CONSTANTS(:,4); ALGEBRAIC(:,17) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,16).*STATES(:,10))+ CONSTANTS(:,23).*CONSTANTS(:,3).*ALGEBRAIC(:,1); ALGEBRAIC(:,35) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,11).*STATES(:,5))+ CONSTANTS(:,24).*CONSTANTS(:,3).*ALGEBRAIC(:,1); ALGEBRAIC(:,37) = CONSTANTS(:,10).*(exp(ALGEBRAIC(:,17)./( CONSTANTS(:,1).*CONSTANTS(:,2))) - exp(ALGEBRAIC(:,35)./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,38) = CONSTANTS(:,3).*( - CONSTANTS(:,23).*ALGEBRAIC(:,37)+ CONSTANTS(:,24).*ALGEBRAIC(:,37)); RATES(:,11) = ALGEBRAIC(:,38); ALGEBRAIC(:,39) = ALGEBRAIC(:,37) - ALGEBRAIC(:,19); RATES(:,5) = ALGEBRAIC(:,39); ALGEBRAIC(:,40) = - ALGEBRAIC(:,37)+ALGEBRAIC(:,33); RATES(:,10) = ALGEBRAIC(:,40); 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(:,6) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,11).*STATES(:,5)); ALGEBRAIC(:,12) = ALGEBRAIC(:,6); ALGEBRAIC(:,5) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,17).*STATES(:,4)); ALGEBRAIC(:,7) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,12).*STATES(:,6)); ALGEBRAIC(:,18) = CONSTANTS(:,22).*ALGEBRAIC(:,5)+ALGEBRAIC(:,7); ALGEBRAIC(:,19) = CONSTANTS(:,5).*(exp(ALGEBRAIC(:,12)./( CONSTANTS(:,1).*CONSTANTS(:,2))) - exp(ALGEBRAIC(:,18)./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,20) = CONSTANTS(:,22).*ALGEBRAIC(:,19); ALGEBRAIC(:,3) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,18).*STATES(:,2)); ALGEBRAIC(:,13) = ALGEBRAIC(:,7)+ALGEBRAIC(:,3); ALGEBRAIC(:,8) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,13).*STATES(:,7)); ALGEBRAIC(:,21) = ALGEBRAIC(:,8); ALGEBRAIC(:,22) = CONSTANTS(:,6).*(exp(ALGEBRAIC(:,13)./( CONSTANTS(:,1).*CONSTANTS(:,2))) - exp(ALGEBRAIC(:,21)./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,23) = - ALGEBRAIC(:,22); ALGEBRAIC(:,24) = ALGEBRAIC(:,19) - ALGEBRAIC(:,22); ALGEBRAIC(:,14) = ALGEBRAIC(:,8); ALGEBRAIC(:,9) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,14).*STATES(:,8)); ALGEBRAIC(:,25) = ALGEBRAIC(:,9); ALGEBRAIC(:,26) = CONSTANTS(:,7).*(exp(ALGEBRAIC(:,14)./( CONSTANTS(:,1).*CONSTANTS(:,2))) - exp(ALGEBRAIC(:,25)./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,27) = ALGEBRAIC(:,22) - ALGEBRAIC(:,26); ALGEBRAIC(:,15) = ALGEBRAIC(:,9); ALGEBRAIC(:,2) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,20).*STATES(:,1)); ALGEBRAIC(:,10) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,15).*STATES(:,9)); ALGEBRAIC(:,28) = ALGEBRAIC(:,10)+ALGEBRAIC(:,2); ALGEBRAIC(:,29) = CONSTANTS(:,8).*(exp(ALGEBRAIC(:,15)./( CONSTANTS(:,1).*CONSTANTS(:,2))) - exp(ALGEBRAIC(:,28)./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,30) = ALGEBRAIC(:,29); ALGEBRAIC(:,31) = - ALGEBRAIC(:,29)+ALGEBRAIC(:,26); ALGEBRAIC(:,4) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,19).*STATES(:,3)); ALGEBRAIC(:,16) = ALGEBRAIC(:,10)+ CONSTANTS(:,21).*ALGEBRAIC(:,4); ALGEBRAIC(:,11) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,16).*STATES(:,10)); ALGEBRAIC(:,32) = ALGEBRAIC(:,11); ALGEBRAIC(:,33) = CONSTANTS(:,9).*(exp(ALGEBRAIC(:,16)./( CONSTANTS(:,1).*CONSTANTS(:,2))) - exp(ALGEBRAIC(:,32)./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,34) = - CONSTANTS(:,21).*ALGEBRAIC(:,33); ALGEBRAIC(:,36) = - ALGEBRAIC(:,33)+ALGEBRAIC(:,29); ALGEBRAIC(:,1) = STATES(:,11)./CONSTANTS(:,4); ALGEBRAIC(:,17) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,16).*STATES(:,10))+ CONSTANTS(:,23).*CONSTANTS(:,3).*ALGEBRAIC(:,1); ALGEBRAIC(:,35) = CONSTANTS(:,1).*CONSTANTS(:,2).*log( CONSTANTS(:,11).*STATES(:,5))+ CONSTANTS(:,24).*CONSTANTS(:,3).*ALGEBRAIC(:,1); ALGEBRAIC(:,37) = CONSTANTS(:,10).*(exp(ALGEBRAIC(:,17)./( CONSTANTS(:,1).*CONSTANTS(:,2))) - exp(ALGEBRAIC(:,35)./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,38) = CONSTANTS(:,3).*( - CONSTANTS(:,23).*ALGEBRAIC(:,37)+ CONSTANTS(:,24).*ALGEBRAIC(:,37)); ALGEBRAIC(:,39) = ALGEBRAIC(:,37) - ALGEBRAIC(:,19); ALGEBRAIC(:,40) = - ALGEBRAIC(:,37)+ALGEBRAIC(:,33); 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