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 =92; end % There are a total of 29 entries in each of the rate and state variable arrays. % There are a total of 69 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 (ms)'); LEGEND_CONSTANTS(:,1) = strpad('F in component Environment (C_per_mole)'); LEGEND_CONSTANTS(:,2) = strpad('K_o in component Environment (mM)'); LEGEND_CONSTANTS(:,3) = strpad('Ca_o in component Environment (mM)'); LEGEND_CONSTANTS(:,4) = strpad('Na_o in component Environment (mM)'); LEGEND_CONSTANTS(:,5) = strpad('Cl_o in component Environment (mM)'); LEGEND_CONSTANTS(:,6) = strpad('FonRT in component Environment (per_mV)'); LEGEND_CONSTANTS(:,7) = strpad('tissue in component Environment (dimensionless)'); LEGEND_STATES(:,1) = strpad('V in component cell (mV)'); LEGEND_ALGEBRAIC(:,63) = strpad('INa in component INa (uA_per_uF)'); LEGEND_ALGEBRAIC(:,32) = strpad('ICaL in component ICaL (uA_per_uF)'); LEGEND_ALGEBRAIC(:,78) = strpad('IK1 in component IK1 (uA_per_uF)'); LEGEND_ALGEBRAIC(:,84) = strpad('IKp in component IKp (uA_per_uF)'); LEGEND_ALGEBRAIC(:,86) = strpad('IKs in component IKs (uA_per_uF)'); LEGEND_ALGEBRAIC(:,82) = strpad('IKr in component IKr (uA_per_uF)'); LEGEND_ALGEBRAIC(:,50) = strpad('IpCa in component IpCa (uA_per_uF)'); LEGEND_ALGEBRAIC(:,51) = strpad('ICab in component ICab (uA_per_uF)'); LEGEND_ALGEBRAIC(:,49) = strpad('INaCa in component INaCa (uA_per_uF)'); LEGEND_ALGEBRAIC(:,42) = strpad('INaK in component INaK (uA_per_uF)'); LEGEND_ALGEBRAIC(:,83) = strpad('Ito in component Ito (uA_per_uF)'); LEGEND_ALGEBRAIC(:,56) = strpad('Ito2 in component Ito2 (uA_per_uF)'); LEGEND_ALGEBRAIC(:,89) = strpad('IClb in component IClb (uA_per_uF)'); LEGEND_ALGEBRAIC(:,66) = strpad('INal in component INal (uA_per_uF)'); LEGEND_ALGEBRAIC(:,52) = strpad('caiont in component cell (uA_per_uF)'); LEGEND_ALGEBRAIC(:,69) = strpad('naiont in component cell (uA_per_uF)'); LEGEND_ALGEBRAIC(:,87) = strpad('kiont in component cell (uA_per_uF)'); LEGEND_ALGEBRAIC(:,90) = strpad('clont in component cell (uA_per_uF)'); LEGEND_CONSTANTS(:,8) = strpad('l in component cell (cm)'); LEGEND_CONSTANTS(:,9) = strpad('a in component cell (cm)'); LEGEND_CONSTANTS(:,57) = strpad('vcell in component cell (uL)'); LEGEND_CONSTANTS(:,61) = strpad('ageo in component cell (cm2)'); LEGEND_CONSTANTS(:,64) = strpad('Acap in component cell (uF)'); LEGEND_CONSTANTS(:,65) = strpad('vmyo in component cell (uL)'); LEGEND_CONSTANTS(:,62) = strpad('vmito in component cell (uL)'); LEGEND_CONSTANTS(:,63) = strpad('vsr in component cell (uL)'); LEGEND_CONSTANTS(:,66) = strpad('vnsr in component cell (uL)'); LEGEND_CONSTANTS(:,67) = strpad('vjsr in component cell (uL)'); LEGEND_CONSTANTS(:,68) = strpad('vss in component cell (uL)'); LEGEND_CONSTANTS(:,69) = strpad('AF in component cell (uF_mole_per_C)'); LEGEND_CONSTANTS(:,10) = strpad('stim_offset in component cell (ms)'); LEGEND_CONSTANTS(:,11) = strpad('stim_period in component cell (ms)'); LEGEND_CONSTANTS(:,12) = strpad('stim_duration in component cell (ms)'); LEGEND_CONSTANTS(:,13) = strpad('stim_amplitude in component cell (uA_per_uF)'); LEGEND_ALGEBRAIC(:,17) = strpad('i_Stim in component cell (uA_per_uF)'); LEGEND_ALGEBRAIC(:,1) = strpad('past in component cell (ms)'); LEGEND_ALGEBRAIC(:,60) = strpad('ENa in component reversal_potentials (mV)'); LEGEND_CONSTANTS(:,58) = strpad('GNa in component INa (mS_per_uF)'); LEGEND_ALGEBRAIC(:,30) = strpad('gNa in component INa (mS_per_uF)'); LEGEND_STATES(:,2) = strpad('H in component INa (dimensionless)'); LEGEND_STATES(:,3) = strpad('m in component INa (dimensionless)'); LEGEND_STATES(:,4) = strpad('J in component INa (dimensionless)'); LEGEND_ALGEBRAIC(:,2) = strpad('am in component INa (per_ms)'); LEGEND_ALGEBRAIC(:,18) = strpad('bm in component INa (per_ms)'); LEGEND_ALGEBRAIC(:,3) = strpad('ah in component INa (per_ms)'); LEGEND_ALGEBRAIC(:,19) = strpad('bh in component INa (per_ms)'); LEGEND_ALGEBRAIC(:,4) = strpad('aj in component INa (per_ms)'); LEGEND_ALGEBRAIC(:,20) = strpad('bj in component INa (per_ms)'); LEGEND_STATES(:,5) = strpad('Ca_ss in component Ca (mM)'); LEGEND_STATES(:,6) = strpad('d in component ICaL (dimensionless)'); LEGEND_STATES(:,7) = strpad('dp in component ICaL (dimensionless)'); LEGEND_STATES(:,8) = strpad('f in component ICaL (dimensionless)'); LEGEND_STATES(:,9) = strpad('fca in component ICaL (dimensionless)'); LEGEND_STATES(:,10) = strpad('fca2 in component ICaL (dimensionless)'); LEGEND_STATES(:,11) = strpad('f2 in component ICaL (dimensionless)'); LEGEND_CONSTANTS(:,14) = strpad('pca in component ICaL (L_per_F_ms)'); LEGEND_CONSTANTS(:,15) = strpad('gacai in component ICaL (dimensionless)'); LEGEND_CONSTANTS(:,16) = strpad('gacao in component ICaL (dimensionless)'); LEGEND_ALGEBRAIC(:,55) = strpad('CaMKactive in component Irel (dimensionless)'); LEGEND_ALGEBRAIC(:,31) = strpad('ibarca in component ICaL (uA_per_uF)'); LEGEND_ALGEBRAIC(:,5) = strpad('dss in component ICaL (dimensionless)'); LEGEND_ALGEBRAIC(:,21) = strpad('taud in component ICaL (ms)'); LEGEND_ALGEBRAIC(:,6) = strpad('fss in component ICaL (dimensionless)'); LEGEND_ALGEBRAIC(:,7) = strpad('f2ss in component ICaL (dimensionless)'); LEGEND_ALGEBRAIC(:,22) = strpad('tauf in component ICaL (ms)'); LEGEND_ALGEBRAIC(:,23) = strpad('tauf2 in component ICaL (ms)'); LEGEND_ALGEBRAIC(:,8) = strpad('dpss in component ICaL (dimensionless)'); LEGEND_ALGEBRAIC(:,33) = strpad('fcass in component ICaL (dimensionless)'); LEGEND_ALGEBRAIC(:,34) = strpad('fca2ss in component ICaL (dimensionless)'); LEGEND_ALGEBRAIC(:,57) = strpad('taufca in component ICaL (ms)'); LEGEND_ALGEBRAIC(:,36) = strpad('taufca2 in component ICaL (ms)'); LEGEND_ALGEBRAIC(:,71) = strpad('EK in component reversal_potentials (mV)'); LEGEND_ALGEBRAIC(:,73) = strpad('ak1 in component IK1 (per_ms)'); LEGEND_ALGEBRAIC(:,75) = strpad('bk1 in component IK1 (per_ms)'); LEGEND_CONSTANTS(:,59) = strpad('gkr in component IKr (mS_per_uF)'); LEGEND_ALGEBRAIC(:,38) = strpad('r in component IKr (dimensionless)'); LEGEND_STATES(:,12) = strpad('xr in component IKr (dimensionless)'); LEGEND_ALGEBRAIC(:,9) = strpad('xrss in component IKr (dimensionless)'); LEGEND_ALGEBRAIC(:,24) = strpad('tauxr in component IKr (ms)'); LEGEND_STATES(:,13) = strpad('Ca_i in component Ca (mM)'); LEGEND_ALGEBRAIC(:,39) = strpad('gks in component IKs (mS_per_uF)'); LEGEND_ALGEBRAIC(:,85) = strpad('EKs in component reversal_potentials (mV)'); LEGEND_ALGEBRAIC(:,10) = strpad('xss in component IKs (dimensionless)'); LEGEND_ALGEBRAIC(:,25) = strpad('tauxs in component IKs (ms)'); LEGEND_STATES(:,14) = strpad('xs1 in component IKs (dimensionless)'); LEGEND_STATES(:,15) = strpad('xs2 in component IKs (dimensionless)'); LEGEND_CONSTANTS(:,17) = strpad('gitodv in component Ito (mS_per_uF)'); LEGEND_ALGEBRAIC(:,40) = strpad('rv in component Ito (dimensionless)'); LEGEND_ALGEBRAIC(:,11) = strpad('ay in component Ito (per_ms)'); LEGEND_ALGEBRAIC(:,26) = strpad('by in component Ito (per_ms)'); LEGEND_ALGEBRAIC(:,12) = strpad('ay2 in component Ito (per_ms)'); LEGEND_ALGEBRAIC(:,27) = strpad('by2 in component Ito (per_ms)'); LEGEND_ALGEBRAIC(:,13) = strpad('ay3 in component Ito (per_ms)'); LEGEND_ALGEBRAIC(:,28) = strpad('by3 in component Ito (per_ms)'); LEGEND_STATES(:,16) = strpad('ydv in component Ito (dimensionless)'); LEGEND_STATES(:,17) = strpad('ydv2 in component Ito (dimensionless)'); LEGEND_STATES(:,18) = strpad('zdv in component Ito (dimensionless)'); LEGEND_STATES(:,19) = strpad('Na_i in component Na (mM)'); LEGEND_CONSTANTS(:,18) = strpad('kmnai in component INaK (mM)'); LEGEND_CONSTANTS(:,19) = strpad('kmko in component INaK (mM)'); LEGEND_CONSTANTS(:,20) = strpad('ibarnak in component INaK (uA_per_uF)'); LEGEND_CONSTANTS(:,60) = strpad('sigma in component INaK (dimensionless)'); LEGEND_ALGEBRAIC(:,41) = strpad('fnak in component INaK (dimensionless)'); LEGEND_ALGEBRAIC(:,43) = strpad('ca_i_NaCa in component INaCa (mM)'); LEGEND_CONSTANTS(:,21) = strpad('KmCa in component INaCa (mM)'); LEGEND_ALGEBRAIC(:,44) = strpad('allo in component INaCa (dimensionless)'); LEGEND_CONSTANTS(:,22) = strpad('NCXmax in component INaCa (uA_per_uF)'); LEGEND_CONSTANTS(:,23) = strpad('ksat in component INaCa (dimensionless)'); LEGEND_CONSTANTS(:,24) = strpad('eta in component INaCa (dimensionless)'); LEGEND_CONSTANTS(:,25) = strpad('KmNai in component INaCa (mM)'); LEGEND_CONSTANTS(:,26) = strpad('KmNao in component INaCa (mM)'); LEGEND_CONSTANTS(:,27) = strpad('KmCai in component INaCa (mM)'); LEGEND_CONSTANTS(:,28) = strpad('KmCao in component INaCa (mM)'); LEGEND_ALGEBRAIC(:,45) = strpad('num in component INaCa (mM4)'); LEGEND_ALGEBRAIC(:,46) = strpad('denom1 in component INaCa (dimensionless)'); LEGEND_ALGEBRAIC(:,47) = strpad('denom2 in component INaCa (mM4)'); LEGEND_ALGEBRAIC(:,48) = strpad('denom3 in component INaCa (mM4)'); LEGEND_CONSTANTS(:,29) = strpad('ibarpca in component IpCa (uA_per_uF)'); LEGEND_CONSTANTS(:,30) = strpad('kmpca in component IpCa (mM)'); LEGEND_STATES(:,20) = strpad('Cl_i in component Cl (mM)'); LEGEND_CONSTANTS(:,31) = strpad('PCl in component Ito2 (L_per_F_ms)'); LEGEND_STATES(:,21) = strpad('AA in component Ito2 (dimensionless)'); LEGEND_ALGEBRAIC(:,54) = strpad('Ito2_max in component Ito2 (uA_per_uF)'); LEGEND_ALGEBRAIC(:,14) = strpad('AAss in component Ito2 (dimensionless)'); LEGEND_CONSTANTS(:,32) = strpad('Kmto2 in component Ito2 (mM)'); LEGEND_ALGEBRAIC(:,88) = strpad('ECl in component reversal_potentials (mV)'); LEGEND_CONSTANTS(:,33) = strpad('GClb in component IClb (mS_per_uF)'); LEGEND_CONSTANTS(:,34) = strpad('GNaL in component INal (mS_per_uF)'); LEGEND_STATES(:,22) = strpad('mL in component INal (dimensionless)'); LEGEND_STATES(:,23) = strpad('hL in component INal (dimensionless)'); LEGEND_ALGEBRAIC(:,15) = strpad('amL in component INal (per_ms)'); LEGEND_ALGEBRAIC(:,29) = strpad('bmL in component INal (per_ms)'); LEGEND_ALGEBRAIC(:,16) = strpad('hLss in component INal (dimensionless)'); LEGEND_STATES(:,24) = strpad('K_i in component K (mM)'); LEGEND_CONSTANTS(:,35) = strpad('prnak in component reversal_potentials (dimensionless)'); LEGEND_STATES(:,25) = strpad('Ca_jsr in component Ca (mM)'); LEGEND_ALGEBRAIC(:,62) = strpad('Grel in component Irel (per_ms)'); LEGEND_ALGEBRAIC(:,35) = strpad('dro_inf in component Irel (dimensionless)'); LEGEND_CONSTANTS(:,36) = strpad('dtau_rel_max in component Irel (ms)'); LEGEND_ALGEBRAIC(:,61) = strpad('dtau_rel in component Irel (ms)'); LEGEND_ALGEBRAIC(:,37) = strpad('ross in component Irel (dimensionless)'); LEGEND_ALGEBRAIC(:,64) = strpad('riss in component Irel (dimensionless)'); LEGEND_ALGEBRAIC(:,67) = strpad('tauri in component Irel (ms)'); LEGEND_ALGEBRAIC(:,65) = strpad('irelcicr in component Irel (mM_per_ms)'); LEGEND_CONSTANTS(:,37) = strpad('CaMK0 in component Irel (dimensionless)'); LEGEND_CONSTANTS(:,38) = strpad('Km in component Irel (mM)'); LEGEND_CONSTANTS(:,39) = strpad('KmCaMK in component Irel (dimensionless)'); LEGEND_ALGEBRAIC(:,53) = strpad('CaMKbound in component Irel (dimensionless)'); LEGEND_STATES(:,26) = strpad('CaMKtrap in component Irel (dimensionless)'); LEGEND_STATES(:,27) = strpad('ro in component Irel (dimensionless)'); LEGEND_STATES(:,28) = strpad('ri in component Irel (dimensionless)'); LEGEND_ALGEBRAIC(:,59) = strpad('vg in component Irel (dimensionless)'); LEGEND_ALGEBRAIC(:,58) = strpad('cafac in component Irel (dimensionless)'); LEGEND_CONSTANTS(:,40) = strpad('dKmPLBmax in component Iup_Ileak (mM)'); LEGEND_CONSTANTS(:,41) = strpad('dJupmax in component Iup_Ileak (dimensionless)'); LEGEND_ALGEBRAIC(:,68) = strpad('dKmPLB in component Iup_Ileak (mM)'); LEGEND_ALGEBRAIC(:,70) = strpad('dJup in component Iup_Ileak (dimensionless)'); LEGEND_CONSTANTS(:,42) = strpad('iupmax in component Iup_Ileak (mM_per_ms)'); LEGEND_CONSTANTS(:,43) = strpad('Kmup in component Iup_Ileak (mM)'); LEGEND_CONSTANTS(:,44) = strpad('nsrmax in component Iup_Ileak (mM)'); LEGEND_ALGEBRAIC(:,72) = strpad('iup in component Iup_Ileak (mM_per_ms)'); LEGEND_ALGEBRAIC(:,74) = strpad('ileak in component Iup_Ileak (mM_per_ms)'); LEGEND_STATES(:,29) = strpad('Ca_nsr in component Ca (mM)'); LEGEND_ALGEBRAIC(:,77) = strpad('idiff in component Idiff_Itr (mM_per_ms)'); LEGEND_ALGEBRAIC(:,76) = strpad('itr in component Idiff_Itr (mM_per_ms)'); LEGEND_ALGEBRAIC(:,91) = strpad('CTNaCl in component Na (mM_per_ms)'); LEGEND_CONSTANTS(:,45) = strpad('CTNaClmax in component Na (mM_per_ms)'); LEGEND_ALGEBRAIC(:,92) = strpad('CTKCl in component K (mM_per_ms)'); LEGEND_CONSTANTS(:,46) = strpad('CTKClmax in component K (mM_per_ms)'); LEGEND_CONSTANTS(:,47) = strpad('kmt in component Ca (mM)'); LEGEND_CONSTANTS(:,48) = strpad('kmc in component Ca (mM)'); LEGEND_CONSTANTS(:,49) = strpad('tbar in component Ca (mM)'); LEGEND_CONSTANTS(:,50) = strpad('cbar in component Ca (mM)'); LEGEND_CONSTANTS(:,51) = strpad('kmcsqn in component Ca (mM)'); LEGEND_CONSTANTS(:,52) = strpad('csqnbar in component Ca (mM)'); LEGEND_ALGEBRAIC(:,79) = strpad('bcsqn in component Ca (dimensionless)'); LEGEND_ALGEBRAIC(:,80) = strpad('bmyo in component Ca (dimensionless)'); LEGEND_CONSTANTS(:,53) = strpad('BSRmax in component Ca (mM)'); LEGEND_CONSTANTS(:,54) = strpad('KmBSR in component Ca (mM)'); LEGEND_CONSTANTS(:,55) = strpad('BSLmax in component Ca (mM)'); LEGEND_CONSTANTS(:,56) = strpad('KmBSL in component Ca (mM)'); LEGEND_ALGEBRAIC(:,81) = strpad('bss in component Ca (dimensionless)'); LEGEND_RATES(:,1) = strpad('d/dt V in component cell (mV)'); LEGEND_RATES(:,2) = strpad('d/dt H in component INa (dimensionless)'); LEGEND_RATES(:,3) = strpad('d/dt m in component INa (dimensionless)'); LEGEND_RATES(:,4) = strpad('d/dt J in component INa (dimensionless)'); LEGEND_RATES(:,6) = strpad('d/dt d in component ICaL (dimensionless)'); LEGEND_RATES(:,7) = strpad('d/dt dp in component ICaL (dimensionless)'); LEGEND_RATES(:,8) = strpad('d/dt f in component ICaL (dimensionless)'); LEGEND_RATES(:,11) = strpad('d/dt f2 in component ICaL (dimensionless)'); LEGEND_RATES(:,9) = strpad('d/dt fca in component ICaL (dimensionless)'); LEGEND_RATES(:,10) = strpad('d/dt fca2 in component ICaL (dimensionless)'); LEGEND_RATES(:,12) = strpad('d/dt xr in component IKr (dimensionless)'); LEGEND_RATES(:,14) = strpad('d/dt xs1 in component IKs (dimensionless)'); LEGEND_RATES(:,15) = strpad('d/dt xs2 in component IKs (dimensionless)'); LEGEND_RATES(:,16) = strpad('d/dt ydv in component Ito (dimensionless)'); LEGEND_RATES(:,17) = strpad('d/dt ydv2 in component Ito (dimensionless)'); LEGEND_RATES(:,18) = strpad('d/dt zdv in component Ito (dimensionless)'); LEGEND_RATES(:,21) = strpad('d/dt AA in component Ito2 (dimensionless)'); LEGEND_RATES(:,22) = strpad('d/dt mL in component INal (dimensionless)'); LEGEND_RATES(:,23) = strpad('d/dt hL in component INal (dimensionless)'); LEGEND_RATES(:,27) = strpad('d/dt ro in component Irel (dimensionless)'); LEGEND_RATES(:,28) = strpad('d/dt ri in component Irel (dimensionless)'); LEGEND_RATES(:,26) = strpad('d/dt CaMKtrap in component Irel (dimensionless)'); LEGEND_RATES(:,19) = strpad('d/dt Na_i in component Na (mM)'); LEGEND_RATES(:,24) = strpad('d/dt K_i in component K (mM)'); LEGEND_RATES(:,20) = strpad('d/dt Cl_i in component Cl (mM)'); LEGEND_RATES(:,13) = strpad('d/dt Ca_i in component Ca (mM)'); LEGEND_RATES(:,5) = strpad('d/dt Ca_ss in component Ca (mM)'); LEGEND_RATES(:,29) = strpad('d/dt Ca_nsr in component Ca (mM)'); LEGEND_RATES(:,25) = strpad('d/dt Ca_jsr in component Ca (mM)'); 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) = 96485; CONSTANTS(:,2) = 5.4; CONSTANTS(:,3) = 1.8; CONSTANTS(:,4) = 140; CONSTANTS(:,5) = 100; CONSTANTS(:,6) = 0.0374358835078; CONSTANTS(:,7) = 0; STATES(:,1) = -85.781844107117; CONSTANTS(:,8) = 0.01; CONSTANTS(:,9) = 0.0011; CONSTANTS(:,10) = 0; CONSTANTS(:,11) = 1e3; CONSTANTS(:,12) = 3; CONSTANTS(:,13) = -20; STATES(:,2) = 0.987317750543; STATES(:,3) = 0.001356538159; STATES(:,4) = 0.991924983076; STATES(:,5) = 0.00012271265; STATES(:,6) = 0.00000164013; STATES(:,7) = 8.98230672628; STATES(:,8) = 0.999961508634; STATES(:,9) = 0.97836624923; STATES(:,10) = 0.893052931249; STATES(:,11) = 0.992234519148; CONSTANTS(:,14) = 2.43e-4; CONSTANTS(:,15) = 1; CONSTANTS(:,16) = 0.341; STATES(:,12) = 0.00000724074; STATES(:,13) = 0.00012131666; STATES(:,14) = 0.019883138161; STATES(:,15) = 0.019890650554; CONSTANTS(:,17) = 0.19; STATES(:,16) = 0.013970786703; STATES(:,17) = 0.99996472752; STATES(:,18) = 0.829206149767; STATES(:,19) = 12.972433387269; CONSTANTS(:,18) = 10; CONSTANTS(:,19) = 1.5; CONSTANTS(:,20) = 0.61875; CONSTANTS(:,21) = 1.25e-4; CONSTANTS(:,22) = 4.5; CONSTANTS(:,23) = 0.27; CONSTANTS(:,24) = 0.35; CONSTANTS(:,25) = 12.3; CONSTANTS(:,26) = 87.5; CONSTANTS(:,27) = 0.0036; CONSTANTS(:,28) = 1.3; CONSTANTS(:,29) = 0.0575; CONSTANTS(:,30) = 0.5e-3; STATES(:,20) = 15.59207157178; CONSTANTS(:,31) = 4e-7; STATES(:,21) = 0.000816605172; CONSTANTS(:,32) = 0.1502; CONSTANTS(:,33) = 2.25e-4; CONSTANTS(:,34) = 65e-4; STATES(:,22) = 0.001356538159; STATES(:,23) = 0.26130711759; STATES(:,24) = 135.469546216758; CONSTANTS(:,35) = 0.01833; STATES(:,25) = 1.737580994071; CONSTANTS(:,36) = 10; CONSTANTS(:,37) = 0.05; CONSTANTS(:,38) = 0.0015; CONSTANTS(:,39) = 0.15; STATES(:,26) = 0.021123704774; STATES(:,27) = 0; STATES(:,28) = 0.862666650318; CONSTANTS(:,40) = 0.00017; CONSTANTS(:,41) = 0.75; CONSTANTS(:,42) = 0.004375; CONSTANTS(:,43) = 0.00092; CONSTANTS(:,44) = 15; STATES(:,29) = 1.832822335168; CONSTANTS(:,45) = 9.8443e-6; CONSTANTS(:,46) = 7.0756e-6; CONSTANTS(:,47) = 0.5e-3; CONSTANTS(:,48) = 2.38e-3; CONSTANTS(:,49) = 70e-3; CONSTANTS(:,50) = 50e-3; CONSTANTS(:,51) = 0.8; CONSTANTS(:,52) = 10; CONSTANTS(:,53) = 0.047; CONSTANTS(:,54) = 0.00087; CONSTANTS(:,55) = 1.124; CONSTANTS(:,56) = 0.0087; CONSTANTS(:,57) = 1000.00.* pi.*CONSTANTS(:,9).*CONSTANTS(:,9).*CONSTANTS(:,8); CONSTANTS(:,58) = piecewise({CONSTANTS(:,7)==0.00000, 11.5000 }, 4.00000.*11.5000); CONSTANTS(:,59) = 0.0138542.*power((CONSTANTS(:,2)./5.40000), 1.0 ./ 2); CONSTANTS(:,60) = (exp(CONSTANTS(:,4)./67.3000) - 1.00000)./7.00000; CONSTANTS(:,61) = 2.00000.* pi.*CONSTANTS(:,9).*CONSTANTS(:,9)+ 2.00000.* pi.*CONSTANTS(:,9).*CONSTANTS(:,8); CONSTANTS(:,62) = CONSTANTS(:,57).*0.260000; CONSTANTS(:,63) = CONSTANTS(:,57).*0.0600000; CONSTANTS(:,64) = CONSTANTS(:,61).*2.00000; CONSTANTS(:,65) = CONSTANTS(:,57).*0.680000; CONSTANTS(:,66) = CONSTANTS(:,57).*0.0552000; CONSTANTS(:,67) = CONSTANTS(:,57).*0.00480000; CONSTANTS(:,68) = CONSTANTS(:,57).*0.0200000; CONSTANTS(:,69) = CONSTANTS(:,64)./CONSTANTS(:,1); 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(:,8) = 9.00000 - 8.00000./(1.00000+exp( - (STATES(:,1)+65.0000)./3.40000)); RATES(:,7) = (ALGEBRAIC(:,8) - STATES(:,7))./10.0000; ALGEBRAIC(:,14) = 1.00000./(1.00000+CONSTANTS(:,32)./STATES(:,5)); RATES(:,21) = (ALGEBRAIC(:,14) - STATES(:,21))./1.00000; ALGEBRAIC(:,16) = 1.00000./(1.00000+exp((STATES(:,1)+91.0000)./6.10000)); RATES(:,23) = (ALGEBRAIC(:,16) - STATES(:,23))./600.000; ALGEBRAIC(:,3) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 }, 0.135000.*exp((80.0000+STATES(:,1))./ - 6.80000)); ALGEBRAIC(:,19) = piecewise({STATES(:,1)>= - 40.0000, 1.00000./( 0.130000.*(1.00000+exp((STATES(:,1)+10.6600)./ - 11.1000))) }, 3.56000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.350000.*STATES(:,1))); RATES(:,2) = ALGEBRAIC(:,3).*(1.00000 - STATES(:,2)) - ALGEBRAIC(:,19).*STATES(:,2); ALGEBRAIC(:,2) = ( 0.320000.*1.00000.*(STATES(:,1)+47.1300))./(1.00000 - exp( - 0.100000.*(STATES(:,1)+47.1300))); ALGEBRAIC(:,18) = 0.0800000.*exp( - STATES(:,1)./11.0000); RATES(:,3) = ALGEBRAIC(:,2).*(1.00000 - STATES(:,3)) - ALGEBRAIC(:,18).*STATES(:,3); ALGEBRAIC(:,4) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 }, ( ( - 127140..*exp( 0.244400.*STATES(:,1)) - 3.47400e-05.*exp( - 0.0439100.*STATES(:,1))).*1.00000.*(STATES(:,1)+37.7800))./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300)))); ALGEBRAIC(:,20) = piecewise({STATES(:,1)>= - 40.0000, ( 0.300000.*exp( - 2.53500e-07.*STATES(:,1)))./(1.00000+exp( - 0.100000.*(STATES(:,1)+32.0000))) }, ( 0.121200.*exp( - 0.0105200.*STATES(:,1)))./(1.00000+exp( - 0.137800.*(STATES(:,1)+40.1400)))); RATES(:,4) = ALGEBRAIC(:,4).*(1.00000 - STATES(:,4)) - ALGEBRAIC(:,20).*STATES(:,4); ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1) - 4.00000)./6.74000)); ALGEBRAIC(:,21) = 0.590000+( 0.800000.*exp( 0.0520000.*(STATES(:,1)+13.0000)))./(1.00000+exp( 0.132000.*(STATES(:,1)+13.0000))); RATES(:,6) = (ALGEBRAIC(:,5) - STATES(:,6))./ALGEBRAIC(:,21); ALGEBRAIC(:,6) = 0.700000./(1.00000+exp((STATES(:,1)+17.1200)./7.00000))+0.300000; ALGEBRAIC(:,22) = 1.00000./( 0.241100.*exp( - power( 0.0450000.*(STATES(:,1) - 9.69140), 2.00000))+0.0529000); RATES(:,8) = (ALGEBRAIC(:,6) - STATES(:,8))./ALGEBRAIC(:,22); ALGEBRAIC(:,7) = 0.770000./(1.00000+exp((STATES(:,1)+17.1200)./7.00000))+0.230000; ALGEBRAIC(:,23) = 1.00000./( 0.0423000.*exp( - power( 0.0590000.*(STATES(:,1) - 18.5726), 2.00000))+0.00540000); RATES(:,11) = (ALGEBRAIC(:,7) - STATES(:,11))./ALGEBRAIC(:,23); ALGEBRAIC(:,9) = 1.00000./(1.00000+exp( - (STATES(:,1)+10.0850)./4.25000)); ALGEBRAIC(:,24) = 1.00000./(( 0.000600000.*(STATES(:,1) - 1.73840))./(1.00000 - exp( - 0.136000.*(STATES(:,1) - 1.73840)))+( 0.000300000.*(STATES(:,1)+38.3608))./(exp( 0.152200.*(STATES(:,1)+38.3608)) - 1.00000)); RATES(:,12) = (ALGEBRAIC(:,9) - STATES(:,12))./ALGEBRAIC(:,24); ALGEBRAIC(:,10) = 1.00000./(1.00000+exp( - (STATES(:,1) - 10.5000)./24.7000)); ALGEBRAIC(:,25) = 1.00000./(( 7.61000e-05.*(STATES(:,1)+44.6000))./(1.00000 - exp( - 9.97000.*(STATES(:,1)+44.6000)))+( 0.000360000.*(STATES(:,1) - 0.550000))./(exp( 0.128000.*(STATES(:,1) - 0.550000)) - 1.00000)); RATES(:,14) = (ALGEBRAIC(:,10) - STATES(:,14))./ALGEBRAIC(:,25); RATES(:,15) = ((ALGEBRAIC(:,10) - STATES(:,15))./ALGEBRAIC(:,25))./2.00000; ALGEBRAIC(:,11) = ( 25.0000.*exp((STATES(:,1) - 40.0000)./25.0000))./(1.00000+exp((STATES(:,1) - 40.0000)./25.0000)); ALGEBRAIC(:,26) = ( 25.0000.*exp( - (STATES(:,1)+90.0000)./25.0000))./(1.00000+exp( - (STATES(:,1)+90.0000)./25.0000)); RATES(:,16) = ALGEBRAIC(:,11).*(1.00000 - STATES(:,16)) - ALGEBRAIC(:,26).*STATES(:,16); ALGEBRAIC(:,12) = 0.0300000./(1.00000+exp((STATES(:,1)+60.0000)./5.00000)); ALGEBRAIC(:,27) = ( 0.200000.*exp((STATES(:,1)+25.0000)./5.00000))./(1.00000+exp((STATES(:,1)+25.0000)./5.00000)); RATES(:,17) = ALGEBRAIC(:,12).*(1.00000 - STATES(:,17)) - ALGEBRAIC(:,27).*STATES(:,17); ALGEBRAIC(:,13) = 0.00390000./(1.00000+exp((STATES(:,1)+63.0000)./5.00000)); ALGEBRAIC(:,28) = ( 0.100000.*exp((STATES(:,1)+25.0000)./5.00000))./(1.00000+exp((STATES(:,1)+25.0000)./5.00000)); RATES(:,18) = ALGEBRAIC(:,13).*(1.00000 - STATES(:,18)) - ALGEBRAIC(:,28).*STATES(:,18); ALGEBRAIC(:,15) = ( 0.320000.*1.00000.*(STATES(:,1)+47.1300))./(1.00000 - exp( - 0.100000.*(STATES(:,1)+47.1300))); ALGEBRAIC(:,29) = 0.0800000.*exp( - STATES(:,1)./11.0000); RATES(:,22) = ALGEBRAIC(:,15).*(1.00000 - STATES(:,22)) - ALGEBRAIC(:,29).*STATES(:,22); ALGEBRAIC(:,31) = ( CONSTANTS(:,14).*4.00000.*(STATES(:,1) - 15.0000).*CONSTANTS(:,1).*CONSTANTS(:,6).*( CONSTANTS(:,15).*STATES(:,5).*exp( 2.00000.*(STATES(:,1) - 15.0000).*CONSTANTS(:,6)) - CONSTANTS(:,16).*CONSTANTS(:,3)))./(exp( 2.00000.*(STATES(:,1) - 15.0000).*CONSTANTS(:,6)) - 1.00000); ALGEBRAIC(:,32) = piecewise({CONSTANTS(:,7)==0.00000, power(STATES(:,6), STATES(:,7)).*STATES(:,8).*STATES(:,11).*STATES(:,9).*STATES(:,10).*ALGEBRAIC(:,31) }, STATES(:,6).*STATES(:,8).*STATES(:,11).*STATES(:,9).*STATES(:,10).*ALGEBRAIC(:,31)); ALGEBRAIC(:,34) = 1.00000./(1.00000 - ALGEBRAIC(:,32)./0.0100000); ALGEBRAIC(:,36) = 300.000./(1.00000+exp(( - ALGEBRAIC(:,32) - 0.175000)./0.0400000))+125.000; RATES(:,10) = (ALGEBRAIC(:,34) - STATES(:,10))./ALGEBRAIC(:,36); ALGEBRAIC(:,35) = power(STATES(:,25), 1.90000)./(power(STATES(:,25), 1.90000)+power(( 49.2800.*STATES(:,5))./(STATES(:,5)+0.00280000), 1.90000)); ALGEBRAIC(:,37) = ALGEBRAIC(:,35)./(power(1.00000./ALGEBRAIC(:,32), 2.00000)+1.00000); RATES(:,27) = (ALGEBRAIC(:,37) - STATES(:,27))./3.00000; ALGEBRAIC(:,53) = ( CONSTANTS(:,37).*(1.00000 - STATES(:,26)))./(1.00000+CONSTANTS(:,38)./STATES(:,5)); ALGEBRAIC(:,55) = ALGEBRAIC(:,53)+STATES(:,26); RATES(:,26) = 0.0500000.*ALGEBRAIC(:,55).*(ALGEBRAIC(:,55) - STATES(:,26)) - 0.000680000.*STATES(:,26); ALGEBRAIC(:,33) = 0.300000./(1.00000 - ALGEBRAIC(:,32)./0.0500000)+0.550000./(1.00000+STATES(:,5)./0.00300000)+0.150000; ALGEBRAIC(:,57) = ( 10.0000.*ALGEBRAIC(:,55))./(0.150000+ALGEBRAIC(:,55))+1.00000./(1.00000+STATES(:,5)./0.00300000)+0.500000; RATES(:,9) = (ALGEBRAIC(:,33) - STATES(:,9))./ALGEBRAIC(:,57); ALGEBRAIC(:,58) = 1.00000./(1.00000+exp((ALGEBRAIC(:,32)+0.0500000)./0.0150000)); ALGEBRAIC(:,64) = 1.00000./(1.00000+exp(((STATES(:,5) - 0.000400000)+ 0.00200000.*ALGEBRAIC(:,58))./2.50000e-05)); ALGEBRAIC(:,61) = ( CONSTANTS(:,36).*ALGEBRAIC(:,55))./(CONSTANTS(:,39)+ALGEBRAIC(:,55)); ALGEBRAIC(:,67) = 3.00000+ALGEBRAIC(:,61)+(350.000 - ALGEBRAIC(:,61))./(1.00000+exp(((STATES(:,5) - 0.00300000)+ 0.00300000.*ALGEBRAIC(:,58))./0.000200000)); RATES(:,28) = (ALGEBRAIC(:,64) - STATES(:,28))./ALGEBRAIC(:,67); ALGEBRAIC(:,68) = ( CONSTANTS(:,40).*ALGEBRAIC(:,55))./(CONSTANTS(:,39)+ALGEBRAIC(:,55)); ALGEBRAIC(:,70) = ( CONSTANTS(:,41).*ALGEBRAIC(:,55))./(CONSTANTS(:,39)+ALGEBRAIC(:,55)); ALGEBRAIC(:,72) = ( (ALGEBRAIC(:,70)+1.00000).*CONSTANTS(:,42).*STATES(:,13))./((STATES(:,13)+CONSTANTS(:,43)) - ALGEBRAIC(:,68)); ALGEBRAIC(:,74) = ( CONSTANTS(:,42).*STATES(:,29))./CONSTANTS(:,44); ALGEBRAIC(:,76) = (STATES(:,29) - STATES(:,25))./120.000; RATES(:,29) = (ALGEBRAIC(:,72) - ( ALGEBRAIC(:,76).*CONSTANTS(:,67))./CONSTANTS(:,66)) - ALGEBRAIC(:,74); ALGEBRAIC(:,50) = ( CONSTANTS(:,29).*STATES(:,13))./(CONSTANTS(:,30)+STATES(:,13)); ALGEBRAIC(:,51) = ( 1.99508e-07.*4.00000.*STATES(:,1).*CONSTANTS(:,1).*CONSTANTS(:,6).*( STATES(:,13).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,6)) - 0.341000.*CONSTANTS(:,3)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,6)) - 1.00000); ALGEBRAIC(:,43) = 1.50000.*STATES(:,13); ALGEBRAIC(:,44) = 1.00000./(1.00000+power(CONSTANTS(:,21)./ALGEBRAIC(:,43), 2.00000)); ALGEBRAIC(:,45) = power(STATES(:,19), 3.00000).*CONSTANTS(:,3).*exp( CONSTANTS(:,24).*STATES(:,1).*CONSTANTS(:,6)) - power(CONSTANTS(:,4), 3.00000).*ALGEBRAIC(:,43).*exp( (CONSTANTS(:,24) - 1.00000).*STATES(:,1).*CONSTANTS(:,6)); ALGEBRAIC(:,46) = 1.00000+ CONSTANTS(:,23).*exp( (CONSTANTS(:,24) - 1.00000).*STATES(:,1).*CONSTANTS(:,6)); ALGEBRAIC(:,47) = CONSTANTS(:,28).*power(STATES(:,19), 3.00000)+ power(CONSTANTS(:,26), 3.00000).*ALGEBRAIC(:,43)+ power(CONSTANTS(:,25), 3.00000).*CONSTANTS(:,3).*(1.00000+ALGEBRAIC(:,43)./CONSTANTS(:,27)); ALGEBRAIC(:,48) = CONSTANTS(:,27).*power(CONSTANTS(:,4), 3.00000).*(1.00000+power(STATES(:,19)./CONSTANTS(:,25), 3.00000))+ power(STATES(:,19), 3.00000).*CONSTANTS(:,3)+ power(CONSTANTS(:,4), 3.00000).*ALGEBRAIC(:,43); ALGEBRAIC(:,49) = ( CONSTANTS(:,22).*ALGEBRAIC(:,44).*ALGEBRAIC(:,45))./( ALGEBRAIC(:,46).*(ALGEBRAIC(:,47)+ALGEBRAIC(:,48))); ALGEBRAIC(:,77) = (STATES(:,5) - STATES(:,13))./0.200000; ALGEBRAIC(:,80) = 1.00000./(1.00000+( CONSTANTS(:,50).*CONSTANTS(:,48))./power(STATES(:,13)+CONSTANTS(:,48), 2.00000)+( CONSTANTS(:,47).*CONSTANTS(:,49))./power(STATES(:,13)+CONSTANTS(:,47), 2.00000)); RATES(:,13) = ALGEBRAIC(:,80).*(( - ((ALGEBRAIC(:,51)+ALGEBRAIC(:,50)) - 2.00000.*ALGEBRAIC(:,49)).*CONSTANTS(:,69))./( CONSTANTS(:,65).*2.00000)+( (ALGEBRAIC(:,74) - ALGEBRAIC(:,72)).*CONSTANTS(:,66))./CONSTANTS(:,65)+( ALGEBRAIC(:,77).*CONSTANTS(:,68))./CONSTANTS(:,65)); ALGEBRAIC(:,59) = piecewise({CONSTANTS(:,7)==0.00000, 1.00000./(1.00000+exp((ALGEBRAIC(:,31)+13.0000)./5.00000)) }, 1.00000); ALGEBRAIC(:,62) = 3000.00.*ALGEBRAIC(:,59); ALGEBRAIC(:,65) = ALGEBRAIC(:,62).*STATES(:,27).*STATES(:,28).*(STATES(:,25) - STATES(:,5)); ALGEBRAIC(:,81) = 1.00000./(1.00000+( CONSTANTS(:,53).*CONSTANTS(:,54))./power(CONSTANTS(:,54)+STATES(:,5), 2.00000)+( CONSTANTS(:,55).*CONSTANTS(:,56))./power(CONSTANTS(:,56)+STATES(:,5), 2.00000)); RATES(:,5) = ALGEBRAIC(:,81).*((( - ALGEBRAIC(:,32).*CONSTANTS(:,69))./( CONSTANTS(:,68).*2.00000)+( ALGEBRAIC(:,65).*CONSTANTS(:,67))./CONSTANTS(:,68)) - ALGEBRAIC(:,77)); ALGEBRAIC(:,79) = 1.00000./(1.00000+( CONSTANTS(:,51).*CONSTANTS(:,52))./power(STATES(:,25)+CONSTANTS(:,51), 2.00000)); RATES(:,25) = ALGEBRAIC(:,79).*(ALGEBRAIC(:,76) - ALGEBRAIC(:,65)); ALGEBRAIC(:,52) = (ALGEBRAIC(:,32)+ALGEBRAIC(:,51)+ALGEBRAIC(:,50)) - 2.00000.*ALGEBRAIC(:,49); ALGEBRAIC(:,60) = log(CONSTANTS(:,4)./STATES(:,19))./CONSTANTS(:,6); ALGEBRAIC(:,30) = CONSTANTS(:,58).*STATES(:,3).*STATES(:,3).*STATES(:,3).*STATES(:,2).*STATES(:,4); ALGEBRAIC(:,63) = ALGEBRAIC(:,30).*(STATES(:,1) - ALGEBRAIC(:,60)); ALGEBRAIC(:,41) = 1.00000./(1.00000+ 0.124500.*exp( - 0.100000.*STATES(:,1).*CONSTANTS(:,6))+ 0.0365000.*CONSTANTS(:,60).*exp( - STATES(:,1).*CONSTANTS(:,6))); ALGEBRAIC(:,42) = ( (( CONSTANTS(:,20).*ALGEBRAIC(:,41).*1.00000)./(1.00000+power(CONSTANTS(:,18)./STATES(:,19), 2.00000))).*CONSTANTS(:,2))./(CONSTANTS(:,2)+CONSTANTS(:,19)); ALGEBRAIC(:,66) = CONSTANTS(:,34).*power(STATES(:,22), 3.00000).*STATES(:,23).*(STATES(:,1) - ALGEBRAIC(:,60)); ALGEBRAIC(:,69) = ALGEBRAIC(:,63)+ 3.00000.*ALGEBRAIC(:,49)+ 3.00000.*ALGEBRAIC(:,42)+ALGEBRAIC(:,66); ALGEBRAIC(:,71) = log(CONSTANTS(:,2)./STATES(:,24))./CONSTANTS(:,6); ALGEBRAIC(:,73) = 1.02000./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,71)) - 59.2150))); ALGEBRAIC(:,75) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1) - ALGEBRAIC(:,71))+5.47600))+ 1.00000.*exp( 0.0617500.*((STATES(:,1) - ALGEBRAIC(:,71)) - 594.310)))./(1.00000+exp( - 0.514300.*((STATES(:,1) - ALGEBRAIC(:,71))+4.75300))); ALGEBRAIC(:,78) = (( 0.500000.*power((CONSTANTS(:,2)./5.40000), 1.0 ./ 2).*ALGEBRAIC(:,73))./(ALGEBRAIC(:,73)+ALGEBRAIC(:,75))).*(STATES(:,1) - ALGEBRAIC(:,71)); ALGEBRAIC(:,84) = ( 0.00276000.*(STATES(:,1) - ALGEBRAIC(:,71)))./(1.00000+exp((7.48800 - STATES(:,1))./5.98000)); ALGEBRAIC(:,39) = 0.0248975.*(1.00000+0.600000./(1.00000+power(3.80000e-05./STATES(:,13), 1.40000))); ALGEBRAIC(:,85) = log((CONSTANTS(:,2)+ CONSTANTS(:,35).*CONSTANTS(:,4))./(STATES(:,24)+ CONSTANTS(:,35).*STATES(:,19)))./CONSTANTS(:,6); ALGEBRAIC(:,86) = ALGEBRAIC(:,39).*STATES(:,14).*STATES(:,15).*(STATES(:,1) - ALGEBRAIC(:,85)); ALGEBRAIC(:,38) = 1.00000./(1.00000+exp((STATES(:,1)+10.0000)./15.4000)); ALGEBRAIC(:,82) = CONSTANTS(:,59).*STATES(:,12).*ALGEBRAIC(:,38).*(STATES(:,1) - ALGEBRAIC(:,71)); ALGEBRAIC(:,40) = exp(STATES(:,1)./300.000); ALGEBRAIC(:,83) = CONSTANTS(:,17).*power(STATES(:,16), 3.00000).*STATES(:,17).*STATES(:,18).*ALGEBRAIC(:,40).*(STATES(:,1) - ALGEBRAIC(:,71)); ALGEBRAIC(:,1) = floor(VOI./CONSTANTS(:,11)).*CONSTANTS(:,11); ALGEBRAIC(:,17) = piecewise({VOI - ALGEBRAIC(:,1)>=CONSTANTS(:,10)&VOI - ALGEBRAIC(:,1)<=CONSTANTS(:,10)+CONSTANTS(:,12), CONSTANTS(:,13) }, 0.00000); ALGEBRAIC(:,87) = ((ALGEBRAIC(:,82)+ALGEBRAIC(:,86)+ALGEBRAIC(:,78)+ALGEBRAIC(:,84)) - 2.00000.*ALGEBRAIC(:,42))+ALGEBRAIC(:,83)+ 0.500000.*ALGEBRAIC(:,17); ALGEBRAIC(:,54) = ( CONSTANTS(:,31).*STATES(:,1).*CONSTANTS(:,1).*CONSTANTS(:,6).*(STATES(:,20) - CONSTANTS(:,5).*exp( STATES(:,1).*CONSTANTS(:,6))))./(1.00000 - exp( STATES(:,1).*CONSTANTS(:,6))); ALGEBRAIC(:,56) = ALGEBRAIC(:,54).*STATES(:,21); ALGEBRAIC(:,88) = - log(CONSTANTS(:,5)./STATES(:,20))./CONSTANTS(:,6); ALGEBRAIC(:,89) = CONSTANTS(:,33).*(STATES(:,1) - ALGEBRAIC(:,88)); ALGEBRAIC(:,90) = ALGEBRAIC(:,89)+ALGEBRAIC(:,56)+ 0.500000.*ALGEBRAIC(:,17); RATES(:,1) = - (ALGEBRAIC(:,69)+ALGEBRAIC(:,87)+ALGEBRAIC(:,52)+ALGEBRAIC(:,90)); ALGEBRAIC(:,91) = ( CONSTANTS(:,45).*power(ALGEBRAIC(:,60) - ALGEBRAIC(:,88), 4.00000))./(power(ALGEBRAIC(:,60) - ALGEBRAIC(:,88), 4.00000)+power(87.8251, 4.00000)); RATES(:,19) = ( - ALGEBRAIC(:,69).*CONSTANTS(:,69))./CONSTANTS(:,65)+ALGEBRAIC(:,91); ALGEBRAIC(:,92) = ( CONSTANTS(:,46).*(ALGEBRAIC(:,71) - ALGEBRAIC(:,88)))./((ALGEBRAIC(:,71) - ALGEBRAIC(:,88))+87.8251); RATES(:,24) = ( - ALGEBRAIC(:,87).*CONSTANTS(:,69))./CONSTANTS(:,65)+ALGEBRAIC(:,92); RATES(:,20) = ( ALGEBRAIC(:,90).*CONSTANTS(:,69))./CONSTANTS(:,65)+ALGEBRAIC(:,91)+ALGEBRAIC(:,92); 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(:,8) = 9.00000 - 8.00000./(1.00000+exp( - (STATES(:,1)+65.0000)./3.40000)); ALGEBRAIC(:,14) = 1.00000./(1.00000+CONSTANTS(:,32)./STATES(:,5)); ALGEBRAIC(:,16) = 1.00000./(1.00000+exp((STATES(:,1)+91.0000)./6.10000)); ALGEBRAIC(:,3) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 }, 0.135000.*exp((80.0000+STATES(:,1))./ - 6.80000)); ALGEBRAIC(:,19) = piecewise({STATES(:,1)>= - 40.0000, 1.00000./( 0.130000.*(1.00000+exp((STATES(:,1)+10.6600)./ - 11.1000))) }, 3.56000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.350000.*STATES(:,1))); ALGEBRAIC(:,2) = ( 0.320000.*1.00000.*(STATES(:,1)+47.1300))./(1.00000 - exp( - 0.100000.*(STATES(:,1)+47.1300))); ALGEBRAIC(:,18) = 0.0800000.*exp( - STATES(:,1)./11.0000); ALGEBRAIC(:,4) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 }, ( ( - 127140..*exp( 0.244400.*STATES(:,1)) - 3.47400e-05.*exp( - 0.0439100.*STATES(:,1))).*1.00000.*(STATES(:,1)+37.7800))./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300)))); ALGEBRAIC(:,20) = piecewise({STATES(:,1)>= - 40.0000, ( 0.300000.*exp( - 2.53500e-07.*STATES(:,1)))./(1.00000+exp( - 0.100000.*(STATES(:,1)+32.0000))) }, ( 0.121200.*exp( - 0.0105200.*STATES(:,1)))./(1.00000+exp( - 0.137800.*(STATES(:,1)+40.1400)))); ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1) - 4.00000)./6.74000)); ALGEBRAIC(:,21) = 0.590000+( 0.800000.*exp( 0.0520000.*(STATES(:,1)+13.0000)))./(1.00000+exp( 0.132000.*(STATES(:,1)+13.0000))); ALGEBRAIC(:,6) = 0.700000./(1.00000+exp((STATES(:,1)+17.1200)./7.00000))+0.300000; ALGEBRAIC(:,22) = 1.00000./( 0.241100.*exp( - power( 0.0450000.*(STATES(:,1) - 9.69140), 2.00000))+0.0529000); ALGEBRAIC(:,7) = 0.770000./(1.00000+exp((STATES(:,1)+17.1200)./7.00000))+0.230000; ALGEBRAIC(:,23) = 1.00000./( 0.0423000.*exp( - power( 0.0590000.*(STATES(:,1) - 18.5726), 2.00000))+0.00540000); ALGEBRAIC(:,9) = 1.00000./(1.00000+exp( - (STATES(:,1)+10.0850)./4.25000)); ALGEBRAIC(:,24) = 1.00000./(( 0.000600000.*(STATES(:,1) - 1.73840))./(1.00000 - exp( - 0.136000.*(STATES(:,1) - 1.73840)))+( 0.000300000.*(STATES(:,1)+38.3608))./(exp( 0.152200.*(STATES(:,1)+38.3608)) - 1.00000)); ALGEBRAIC(:,10) = 1.00000./(1.00000+exp( - (STATES(:,1) - 10.5000)./24.7000)); ALGEBRAIC(:,25) = 1.00000./(( 7.61000e-05.*(STATES(:,1)+44.6000))./(1.00000 - exp( - 9.97000.*(STATES(:,1)+44.6000)))+( 0.000360000.*(STATES(:,1) - 0.550000))./(exp( 0.128000.*(STATES(:,1) - 0.550000)) - 1.00000)); ALGEBRAIC(:,11) = ( 25.0000.*exp((STATES(:,1) - 40.0000)./25.0000))./(1.00000+exp((STATES(:,1) - 40.0000)./25.0000)); ALGEBRAIC(:,26) = ( 25.0000.*exp( - (STATES(:,1)+90.0000)./25.0000))./(1.00000+exp( - (STATES(:,1)+90.0000)./25.0000)); ALGEBRAIC(:,12) = 0.0300000./(1.00000+exp((STATES(:,1)+60.0000)./5.00000)); ALGEBRAIC(:,27) = ( 0.200000.*exp((STATES(:,1)+25.0000)./5.00000))./(1.00000+exp((STATES(:,1)+25.0000)./5.00000)); ALGEBRAIC(:,13) = 0.00390000./(1.00000+exp((STATES(:,1)+63.0000)./5.00000)); ALGEBRAIC(:,28) = ( 0.100000.*exp((STATES(:,1)+25.0000)./5.00000))./(1.00000+exp((STATES(:,1)+25.0000)./5.00000)); ALGEBRAIC(:,15) = ( 0.320000.*1.00000.*(STATES(:,1)+47.1300))./(1.00000 - exp( - 0.100000.*(STATES(:,1)+47.1300))); ALGEBRAIC(:,29) = 0.0800000.*exp( - STATES(:,1)./11.0000); ALGEBRAIC(:,31) = ( CONSTANTS(:,14).*4.00000.*(STATES(:,1) - 15.0000).*CONSTANTS(:,1).*CONSTANTS(:,6).*( CONSTANTS(:,15).*STATES(:,5).*exp( 2.00000.*(STATES(:,1) - 15.0000).*CONSTANTS(:,6)) - CONSTANTS(:,16).*CONSTANTS(:,3)))./(exp( 2.00000.*(STATES(:,1) - 15.0000).*CONSTANTS(:,6)) - 1.00000); ALGEBRAIC(:,32) = piecewise({CONSTANTS(:,7)==0.00000, power(STATES(:,6), STATES(:,7)).*STATES(:,8).*STATES(:,11).*STATES(:,9).*STATES(:,10).*ALGEBRAIC(:,31) }, STATES(:,6).*STATES(:,8).*STATES(:,11).*STATES(:,9).*STATES(:,10).*ALGEBRAIC(:,31)); ALGEBRAIC(:,34) = 1.00000./(1.00000 - ALGEBRAIC(:,32)./0.0100000); ALGEBRAIC(:,36) = 300.000./(1.00000+exp(( - ALGEBRAIC(:,32) - 0.175000)./0.0400000))+125.000; ALGEBRAIC(:,35) = power(STATES(:,25), 1.90000)./(power(STATES(:,25), 1.90000)+power(( 49.2800.*STATES(:,5))./(STATES(:,5)+0.00280000), 1.90000)); ALGEBRAIC(:,37) = ALGEBRAIC(:,35)./(power(1.00000./ALGEBRAIC(:,32), 2.00000)+1.00000); ALGEBRAIC(:,53) = ( CONSTANTS(:,37).*(1.00000 - STATES(:,26)))./(1.00000+CONSTANTS(:,38)./STATES(:,5)); ALGEBRAIC(:,55) = ALGEBRAIC(:,53)+STATES(:,26); ALGEBRAIC(:,33) = 0.300000./(1.00000 - ALGEBRAIC(:,32)./0.0500000)+0.550000./(1.00000+STATES(:,5)./0.00300000)+0.150000; ALGEBRAIC(:,57) = ( 10.0000.*ALGEBRAIC(:,55))./(0.150000+ALGEBRAIC(:,55))+1.00000./(1.00000+STATES(:,5)./0.00300000)+0.500000; ALGEBRAIC(:,58) = 1.00000./(1.00000+exp((ALGEBRAIC(:,32)+0.0500000)./0.0150000)); ALGEBRAIC(:,64) = 1.00000./(1.00000+exp(((STATES(:,5) - 0.000400000)+ 0.00200000.*ALGEBRAIC(:,58))./2.50000e-05)); ALGEBRAIC(:,61) = ( CONSTANTS(:,36).*ALGEBRAIC(:,55))./(CONSTANTS(:,39)+ALGEBRAIC(:,55)); ALGEBRAIC(:,67) = 3.00000+ALGEBRAIC(:,61)+(350.000 - ALGEBRAIC(:,61))./(1.00000+exp(((STATES(:,5) - 0.00300000)+ 0.00300000.*ALGEBRAIC(:,58))./0.000200000)); ALGEBRAIC(:,68) = ( CONSTANTS(:,40).*ALGEBRAIC(:,55))./(CONSTANTS(:,39)+ALGEBRAIC(:,55)); ALGEBRAIC(:,70) = ( CONSTANTS(:,41).*ALGEBRAIC(:,55))./(CONSTANTS(:,39)+ALGEBRAIC(:,55)); ALGEBRAIC(:,72) = ( (ALGEBRAIC(:,70)+1.00000).*CONSTANTS(:,42).*STATES(:,13))./((STATES(:,13)+CONSTANTS(:,43)) - ALGEBRAIC(:,68)); ALGEBRAIC(:,74) = ( CONSTANTS(:,42).*STATES(:,29))./CONSTANTS(:,44); ALGEBRAIC(:,76) = (STATES(:,29) - STATES(:,25))./120.000; ALGEBRAIC(:,50) = ( CONSTANTS(:,29).*STATES(:,13))./(CONSTANTS(:,30)+STATES(:,13)); ALGEBRAIC(:,51) = ( 1.99508e-07.*4.00000.*STATES(:,1).*CONSTANTS(:,1).*CONSTANTS(:,6).*( STATES(:,13).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,6)) - 0.341000.*CONSTANTS(:,3)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,6)) - 1.00000); ALGEBRAIC(:,43) = 1.50000.*STATES(:,13); ALGEBRAIC(:,44) = 1.00000./(1.00000+power(CONSTANTS(:,21)./ALGEBRAIC(:,43), 2.00000)); ALGEBRAIC(:,45) = power(STATES(:,19), 3.00000).*CONSTANTS(:,3).*exp( CONSTANTS(:,24).*STATES(:,1).*CONSTANTS(:,6)) - power(CONSTANTS(:,4), 3.00000).*ALGEBRAIC(:,43).*exp( (CONSTANTS(:,24) - 1.00000).*STATES(:,1).*CONSTANTS(:,6)); ALGEBRAIC(:,46) = 1.00000+ CONSTANTS(:,23).*exp( (CONSTANTS(:,24) - 1.00000).*STATES(:,1).*CONSTANTS(:,6)); ALGEBRAIC(:,47) = CONSTANTS(:,28).*power(STATES(:,19), 3.00000)+ power(CONSTANTS(:,26), 3.00000).*ALGEBRAIC(:,43)+ power(CONSTANTS(:,25), 3.00000).*CONSTANTS(:,3).*(1.00000+ALGEBRAIC(:,43)./CONSTANTS(:,27)); ALGEBRAIC(:,48) = CONSTANTS(:,27).*power(CONSTANTS(:,4), 3.00000).*(1.00000+power(STATES(:,19)./CONSTANTS(:,25), 3.00000))+ power(STATES(:,19), 3.00000).*CONSTANTS(:,3)+ power(CONSTANTS(:,4), 3.00000).*ALGEBRAIC(:,43); ALGEBRAIC(:,49) = ( CONSTANTS(:,22).*ALGEBRAIC(:,44).*ALGEBRAIC(:,45))./( ALGEBRAIC(:,46).*(ALGEBRAIC(:,47)+ALGEBRAIC(:,48))); ALGEBRAIC(:,77) = (STATES(:,5) - STATES(:,13))./0.200000; ALGEBRAIC(:,80) = 1.00000./(1.00000+( CONSTANTS(:,50).*CONSTANTS(:,48))./power(STATES(:,13)+CONSTANTS(:,48), 2.00000)+( CONSTANTS(:,47).*CONSTANTS(:,49))./power(STATES(:,13)+CONSTANTS(:,47), 2.00000)); ALGEBRAIC(:,59) = piecewise({CONSTANTS(:,7)==0.00000, 1.00000./(1.00000+exp((ALGEBRAIC(:,31)+13.0000)./5.00000)) }, 1.00000); ALGEBRAIC(:,62) = 3000.00.*ALGEBRAIC(:,59); ALGEBRAIC(:,65) = ALGEBRAIC(:,62).*STATES(:,27).*STATES(:,28).*(STATES(:,25) - STATES(:,5)); ALGEBRAIC(:,81) = 1.00000./(1.00000+( CONSTANTS(:,53).*CONSTANTS(:,54))./power(CONSTANTS(:,54)+STATES(:,5), 2.00000)+( CONSTANTS(:,55).*CONSTANTS(:,56))./power(CONSTANTS(:,56)+STATES(:,5), 2.00000)); ALGEBRAIC(:,79) = 1.00000./(1.00000+( CONSTANTS(:,51).*CONSTANTS(:,52))./power(STATES(:,25)+CONSTANTS(:,51), 2.00000)); ALGEBRAIC(:,52) = (ALGEBRAIC(:,32)+ALGEBRAIC(:,51)+ALGEBRAIC(:,50)) - 2.00000.*ALGEBRAIC(:,49); ALGEBRAIC(:,60) = log(CONSTANTS(:,4)./STATES(:,19))./CONSTANTS(:,6); ALGEBRAIC(:,30) = CONSTANTS(:,58).*STATES(:,3).*STATES(:,3).*STATES(:,3).*STATES(:,2).*STATES(:,4); ALGEBRAIC(:,63) = ALGEBRAIC(:,30).*(STATES(:,1) - ALGEBRAIC(:,60)); ALGEBRAIC(:,41) = 1.00000./(1.00000+ 0.124500.*exp( - 0.100000.*STATES(:,1).*CONSTANTS(:,6))+ 0.0365000.*CONSTANTS(:,60).*exp( - STATES(:,1).*CONSTANTS(:,6))); ALGEBRAIC(:,42) = ( (( CONSTANTS(:,20).*ALGEBRAIC(:,41).*1.00000)./(1.00000+power(CONSTANTS(:,18)./STATES(:,19), 2.00000))).*CONSTANTS(:,2))./(CONSTANTS(:,2)+CONSTANTS(:,19)); ALGEBRAIC(:,66) = CONSTANTS(:,34).*power(STATES(:,22), 3.00000).*STATES(:,23).*(STATES(:,1) - ALGEBRAIC(:,60)); ALGEBRAIC(:,69) = ALGEBRAIC(:,63)+ 3.00000.*ALGEBRAIC(:,49)+ 3.00000.*ALGEBRAIC(:,42)+ALGEBRAIC(:,66); ALGEBRAIC(:,71) = log(CONSTANTS(:,2)./STATES(:,24))./CONSTANTS(:,6); ALGEBRAIC(:,73) = 1.02000./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,71)) - 59.2150))); ALGEBRAIC(:,75) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1) - ALGEBRAIC(:,71))+5.47600))+ 1.00000.*exp( 0.0617500.*((STATES(:,1) - ALGEBRAIC(:,71)) - 594.310)))./(1.00000+exp( - 0.514300.*((STATES(:,1) - ALGEBRAIC(:,71))+4.75300))); ALGEBRAIC(:,78) = (( 0.500000.*power((CONSTANTS(:,2)./5.40000), 1.0 ./ 2).*ALGEBRAIC(:,73))./(ALGEBRAIC(:,73)+ALGEBRAIC(:,75))).*(STATES(:,1) - ALGEBRAIC(:,71)); ALGEBRAIC(:,84) = ( 0.00276000.*(STATES(:,1) - ALGEBRAIC(:,71)))./(1.00000+exp((7.48800 - STATES(:,1))./5.98000)); ALGEBRAIC(:,39) = 0.0248975.*(1.00000+0.600000./(1.00000+power(3.80000e-05./STATES(:,13), 1.40000))); ALGEBRAIC(:,85) = log((CONSTANTS(:,2)+ CONSTANTS(:,35).*CONSTANTS(:,4))./(STATES(:,24)+ CONSTANTS(:,35).*STATES(:,19)))./CONSTANTS(:,6); ALGEBRAIC(:,86) = ALGEBRAIC(:,39).*STATES(:,14).*STATES(:,15).*(STATES(:,1) - ALGEBRAIC(:,85)); ALGEBRAIC(:,38) = 1.00000./(1.00000+exp((STATES(:,1)+10.0000)./15.4000)); ALGEBRAIC(:,82) = CONSTANTS(:,59).*STATES(:,12).*ALGEBRAIC(:,38).*(STATES(:,1) - ALGEBRAIC(:,71)); ALGEBRAIC(:,40) = exp(STATES(:,1)./300.000); ALGEBRAIC(:,83) = CONSTANTS(:,17).*power(STATES(:,16), 3.00000).*STATES(:,17).*STATES(:,18).*ALGEBRAIC(:,40).*(STATES(:,1) - ALGEBRAIC(:,71)); ALGEBRAIC(:,1) = floor(VOI./CONSTANTS(:,11)).*CONSTANTS(:,11); ALGEBRAIC(:,17) = piecewise({VOI - ALGEBRAIC(:,1)>=CONSTANTS(:,10)&VOI - ALGEBRAIC(:,1)<=CONSTANTS(:,10)+CONSTANTS(:,12), CONSTANTS(:,13) }, 0.00000); ALGEBRAIC(:,87) = ((ALGEBRAIC(:,82)+ALGEBRAIC(:,86)+ALGEBRAIC(:,78)+ALGEBRAIC(:,84)) - 2.00000.*ALGEBRAIC(:,42))+ALGEBRAIC(:,83)+ 0.500000.*ALGEBRAIC(:,17); ALGEBRAIC(:,54) = ( CONSTANTS(:,31).*STATES(:,1).*CONSTANTS(:,1).*CONSTANTS(:,6).*(STATES(:,20) - CONSTANTS(:,5).*exp( STATES(:,1).*CONSTANTS(:,6))))./(1.00000 - exp( STATES(:,1).*CONSTANTS(:,6))); ALGEBRAIC(:,56) = ALGEBRAIC(:,54).*STATES(:,21); ALGEBRAIC(:,88) = - log(CONSTANTS(:,5)./STATES(:,20))./CONSTANTS(:,6); ALGEBRAIC(:,89) = CONSTANTS(:,33).*(STATES(:,1) - ALGEBRAIC(:,88)); ALGEBRAIC(:,90) = ALGEBRAIC(:,89)+ALGEBRAIC(:,56)+ 0.500000.*ALGEBRAIC(:,17); ALGEBRAIC(:,91) = ( CONSTANTS(:,45).*power(ALGEBRAIC(:,60) - ALGEBRAIC(:,88), 4.00000))./(power(ALGEBRAIC(:,60) - ALGEBRAIC(:,88), 4.00000)+power(87.8251, 4.00000)); ALGEBRAIC(:,92) = ( CONSTANTS(:,46).*(ALGEBRAIC(:,71) - ALGEBRAIC(:,88)))./((ALGEBRAIC(:,71) - ALGEBRAIC(:,88))+87.8251); end % Compute result of a piecewise function function x = piecewise(cases, default) set = [0]; for i = 1:2:length(cases) if (length(cases{i+1}) == 1) x(cases{i} & ~set,:) = cases{i+1}; else x(cases{i} & ~set,:) = cases{i+1}(cases{i} & ~set); end set = set | cases{i}; if(set), break, end end if (length(default) == 1) x(~set,:) = default; else x(~set,:) = default(~set); end 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