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 =81; end % There are a total of 29 entries in each of the rate and state variable arrays. % There are a total of 58 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('V in component membrane (millivolt)'); LEGEND_CONSTANTS(:,1) = strpad('R in component membrane (joule_per_kilomole_kelvin)'); LEGEND_CONSTANTS(:,2) = strpad('T in component membrane (kelvin)'); LEGEND_CONSTANTS(:,3) = strpad('F in component membrane (coulomb_per_mole)'); LEGEND_CONSTANTS(:,4) = strpad('C in component membrane (microF)'); LEGEND_CONSTANTS(:,49) = strpad('RTONF in component membrane (millivolt)'); LEGEND_ALGEBRAIC(:,66) = strpad('i_Na in component fast_sodium_current (nanoA)'); LEGEND_ALGEBRAIC(:,71) = strpad('i_CaL in component L_type_calcium_current (nanoA)'); LEGEND_ALGEBRAIC(:,67) = strpad('i_to in component transient_outward_potassium_current (nanoA)'); LEGEND_ALGEBRAIC(:,35) = strpad('i_Kr in component rapid_delayed_rectifier_potassium_current (nanoA)'); LEGEND_ALGEBRAIC(:,18) = strpad('i_f in component hyperpolarising_activated_current (nanoA)'); LEGEND_ALGEBRAIC(:,68) = strpad('i_st in component sustained_outward_potassium_current (nanoA)'); LEGEND_ALGEBRAIC(:,50) = strpad('i_K1 in component time_independent_potassium_current (nanoA)'); LEGEND_ALGEBRAIC(:,65) = strpad('i_NaCa in component sodium_calcium_exchange_current (nanoA)'); LEGEND_ALGEBRAIC(:,52) = strpad('i_p in component sodium_potassium_pump (nanoA)'); LEGEND_ALGEBRAIC(:,51) = strpad('i_b in component background_current (nanoA)'); LEGEND_ALGEBRAIC(:,70) = strpad('i_ACh in component acetylcholine_sensitive_current (nanoA)'); LEGEND_CONSTANTS(:,5) = strpad('g_f in component hyperpolarising_activated_current (microS)'); LEGEND_CONSTANTS(:,6) = strpad('ACh in component acetylcholine_sensitive_current (millimolar)'); LEGEND_STATES(:,2) = strpad('y in component hyperpolarising_activated_current_y_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,1) = strpad('y_inf in component hyperpolarising_activated_current_y_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,20) = strpad('tau_y in component hyperpolarising_activated_current_y_gate (second)'); LEGEND_CONSTANTS(:,7) = strpad('g_Kr in component rapid_delayed_rectifier_potassium_current (microS)'); LEGEND_CONSTANTS(:,51) = strpad('E_K in component rapid_delayed_rectifier_potassium_current (millivolt)'); LEGEND_CONSTANTS(:,8) = strpad('Ki in component intracellular_potassium_concentration (millimolar)'); LEGEND_CONSTANTS(:,9) = strpad('Kc in component extracellular_potassium_concentration (millimolar)'); LEGEND_STATES(:,3) = strpad('paf in component rapid_delayed_rectifier_potassium_current_paf_gate (dimensionless)'); LEGEND_STATES(:,4) = strpad('pas in component rapid_delayed_rectifier_potassium_current_pas_gate (dimensionless)'); LEGEND_STATES(:,5) = strpad('pik in component rapid_delayed_rectifier_potassium_current_pik_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,2) = strpad('paf_infinity in component rapid_delayed_rectifier_potassium_current_paf_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,21) = strpad('tau_paf in component rapid_delayed_rectifier_potassium_current_paf_gate (second)'); LEGEND_ALGEBRAIC(:,3) = strpad('pas_infinity in component rapid_delayed_rectifier_potassium_current_pas_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,22) = strpad('tau_pas in component rapid_delayed_rectifier_potassium_current_pas_gate (second)'); LEGEND_ALGEBRAIC(:,4) = strpad('pik_infinity in component rapid_delayed_rectifier_potassium_current_pik_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,23) = strpad('alpha_pik in component rapid_delayed_rectifier_potassium_current_pik_gate (per_second)'); LEGEND_ALGEBRAIC(:,36) = strpad('beta_pik in component rapid_delayed_rectifier_potassium_current_pik_gate (per_second)'); LEGEND_ALGEBRAIC(:,44) = strpad('tau_pik in component rapid_delayed_rectifier_potassium_current_pik_gate (second)'); LEGEND_CONSTANTS(:,10) = strpad('g_K1 in component time_independent_potassium_current (microS)'); LEGEND_ALGEBRAIC(:,43) = strpad('g_K1_prime in component time_independent_potassium_current (microS)'); LEGEND_CONSTANTS(:,11) = strpad('g_b in component background_current (microS)'); LEGEND_CONSTANTS(:,12) = strpad('E_b in component background_current (millivolt)'); LEGEND_CONSTANTS(:,13) = strpad('I_p in component sodium_potassium_pump (nanoA)'); LEGEND_CONSTANTS(:,14) = strpad('Nai in component intracellular_sodium_concentration (millimolar)'); LEGEND_CONSTANTS(:,15) = strpad('kNaCa in component sodium_calcium_exchange_current (nanoA)'); LEGEND_ALGEBRAIC(:,61) = strpad('x1 in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_ALGEBRAIC(:,62) = strpad('x2 in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_ALGEBRAIC(:,63) = strpad('x3 in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_ALGEBRAIC(:,64) = strpad('x4 in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_ALGEBRAIC(:,58) = strpad('k41 in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_CONSTANTS(:,50) = strpad('k34 in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_ALGEBRAIC(:,55) = strpad('k23 in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_ALGEBRAIC(:,56) = strpad('k21 in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_ALGEBRAIC(:,54) = strpad('k32 in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_CONSTANTS(:,54) = strpad('k43 in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_ALGEBRAIC(:,60) = strpad('k12 in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_ALGEBRAIC(:,59) = strpad('k14 in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_CONSTANTS(:,16) = strpad('Qci in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_CONSTANTS(:,17) = strpad('Qn in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_CONSTANTS(:,18) = strpad('Qco in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_CONSTANTS(:,19) = strpad('Kci in component sodium_calcium_exchange_current (millimolar)'); LEGEND_CONSTANTS(:,20) = strpad('K1ni in component sodium_calcium_exchange_current (millimolar)'); LEGEND_CONSTANTS(:,21) = strpad('K2ni in component sodium_calcium_exchange_current (millimolar)'); LEGEND_CONSTANTS(:,22) = strpad('K3ni in component sodium_calcium_exchange_current (millimolar)'); LEGEND_CONSTANTS(:,23) = strpad('Kcni in component sodium_calcium_exchange_current (millimolar)'); LEGEND_CONSTANTS(:,24) = strpad('K3no in component sodium_calcium_exchange_current (millimolar)'); LEGEND_CONSTANTS(:,25) = strpad('K1no in component sodium_calcium_exchange_current (millimolar)'); LEGEND_CONSTANTS(:,26) = strpad('K2no in component sodium_calcium_exchange_current (millimolar)'); LEGEND_CONSTANTS(:,27) = strpad('Kco in component sodium_calcium_exchange_current (millimolar)'); LEGEND_ALGEBRAIC(:,53) = strpad('do in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_ALGEBRAIC(:,57) = strpad('di in component sodium_calcium_exchange_current (dimensionless)'); LEGEND_CONSTANTS(:,28) = strpad('Cao in component extracellular_calcium_concentration (millimolar)'); LEGEND_CONSTANTS(:,29) = strpad('Nao in component extracellular_sodium_concentration (millimolar)'); LEGEND_STATES(:,6) = strpad('Casub in component intracellular_calcium_concentration (millimolar)'); LEGEND_CONSTANTS(:,30) = strpad('g_Na in component fast_sodium_current (microlitre_per_second)'); LEGEND_CONSTANTS(:,52) = strpad('E_Na in component fast_sodium_current (millivolt)'); LEGEND_STATES(:,7) = strpad('m in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_STATES(:,8) = strpad('h1 in component fast_sodium_current_h1_gate (dimensionless)'); LEGEND_STATES(:,9) = strpad('h2 in component fast_sodium_current_h2_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,24) = strpad('alpha_m in component fast_sodium_current_m_gate (per_second)'); LEGEND_ALGEBRAIC(:,37) = strpad('beta_m in component fast_sodium_current_m_gate (per_second)'); LEGEND_CONSTANTS(:,31) = strpad('delta_m in component fast_sodium_current_m_gate (millivolt)'); LEGEND_ALGEBRAIC(:,5) = strpad('E0_m in component fast_sodium_current_m_gate (millivolt)'); LEGEND_ALGEBRAIC(:,6) = strpad('alpha_h1 in component fast_sodium_current_h1_gate (per_second)'); LEGEND_ALGEBRAIC(:,25) = strpad('beta_h1 in component fast_sodium_current_h1_gate (per_second)'); LEGEND_ALGEBRAIC(:,38) = strpad('h1_inf in component fast_sodium_current_h1_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,45) = strpad('tau_h1 in component fast_sodium_current_h1_gate (second)'); LEGEND_ALGEBRAIC(:,7) = strpad('alpha_h2 in component fast_sodium_current_h2_gate (per_second)'); LEGEND_ALGEBRAIC(:,26) = strpad('beta_h2 in component fast_sodium_current_h2_gate (per_second)'); LEGEND_ALGEBRAIC(:,39) = strpad('h2_inf in component fast_sodium_current_h2_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,46) = strpad('tau_h2 in component fast_sodium_current_h2_gate (second)'); LEGEND_CONSTANTS(:,32) = strpad('g_CaL in component L_type_calcium_current (microS)'); LEGEND_CONSTANTS(:,33) = strpad('E_CaL in component L_type_calcium_current (millivolt)'); LEGEND_STATES(:,10) = strpad('d in component L_type_calcium_current_d_gate (dimensionless)'); LEGEND_STATES(:,11) = strpad('f in component L_type_calcium_current_f_gate (dimensionless)'); LEGEND_STATES(:,12) = strpad('f2 in component L_type_calcium_current_f2_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,8) = strpad('alpha_d in component L_type_calcium_current_d_gate (per_second)'); LEGEND_ALGEBRAIC(:,27) = strpad('beta_d in component L_type_calcium_current_d_gate (per_second)'); LEGEND_ALGEBRAIC(:,40) = strpad('d_inf in component L_type_calcium_current_d_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,47) = strpad('tau_d in component L_type_calcium_current_d_gate (second)'); LEGEND_CONSTANTS(:,34) = strpad('act_shift in component L_type_calcium_current_d_gate (millivolt)'); LEGEND_CONSTANTS(:,35) = strpad('slope_factor_act in component L_type_calcium_current_d_gate (millivolt)'); LEGEND_ALGEBRAIC(:,9) = strpad('f_inf in component L_type_calcium_current_f_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,28) = strpad('tau_f in component L_type_calcium_current_f_gate (second)'); LEGEND_CONSTANTS(:,36) = strpad('inact_shift in component L_type_calcium_current_f_gate (millivolt)'); LEGEND_ALGEBRAIC(:,10) = strpad('f2_inf in component L_type_calcium_current_f2_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,29) = strpad('tau_f2 in component L_type_calcium_current_f2_gate (second)'); LEGEND_CONSTANTS(:,37) = strpad('inact_shift in component L_type_calcium_current_f2_gate (millivolt)'); LEGEND_CONSTANTS(:,53) = strpad('E_K in component transient_outward_potassium_current (millivolt)'); LEGEND_CONSTANTS(:,38) = strpad('g_to in component transient_outward_potassium_current (microS)'); LEGEND_STATES(:,13) = strpad('r in component transient_outward_potassium_current_r_gate (dimensionless)'); LEGEND_STATES(:,14) = strpad('q_fast in component transient_outward_potassium_current_qfast_gate (dimensionless)'); LEGEND_STATES(:,15) = strpad('q_slow in component transient_outward_potassium_current_qslow_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,30) = strpad('tau_r in component transient_outward_potassium_current_r_gate (second)'); LEGEND_ALGEBRAIC(:,11) = strpad('r_infinity in component transient_outward_potassium_current_r_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,31) = strpad('tau_qfast in component transient_outward_potassium_current_qfast_gate (second)'); LEGEND_ALGEBRAIC(:,12) = strpad('qfast_infinity in component transient_outward_potassium_current_qfast_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,32) = strpad('tau_qslow in component transient_outward_potassium_current_qslow_gate (second)'); LEGEND_ALGEBRAIC(:,13) = strpad('qslow_infinity in component transient_outward_potassium_current_qslow_gate (dimensionless)'); LEGEND_CONSTANTS(:,39) = strpad('E_st in component sustained_outward_potassium_current (millivolt)'); LEGEND_CONSTANTS(:,40) = strpad('g_st in component sustained_outward_potassium_current (microS)'); LEGEND_STATES(:,16) = strpad('qa in component sustained_outward_potassium_current_qa_gate (dimensionless)'); LEGEND_STATES(:,17) = strpad('qi in component sustained_outward_potassium_current_qi_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,48) = strpad('tau_qa in component sustained_outward_potassium_current_qa_gate (second)'); LEGEND_ALGEBRAIC(:,14) = strpad('qa_infinity in component sustained_outward_potassium_current_qa_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,33) = strpad('alpha_qa in component sustained_outward_potassium_current_qa_gate (per_second)'); LEGEND_ALGEBRAIC(:,41) = strpad('beta_qa in component sustained_outward_potassium_current_qa_gate (per_second)'); LEGEND_ALGEBRAIC(:,49) = strpad('tau_qi in component sustained_outward_potassium_current_qi_gate (second)'); LEGEND_ALGEBRAIC(:,15) = strpad('alpha_qi in component sustained_outward_potassium_current_qi_gate (per_second)'); LEGEND_ALGEBRAIC(:,34) = strpad('beta_qi in component sustained_outward_potassium_current_qi_gate (per_second)'); LEGEND_ALGEBRAIC(:,42) = strpad('qi_infinity in component sustained_outward_potassium_current_qi_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,69) = strpad('g_ACh in component acetylcholine_sensitive_current (microS)'); LEGEND_CONSTANTS(:,41) = strpad('g_ACh_max in component acetylcholine_sensitive_current (microS)'); LEGEND_CONSTANTS(:,42) = strpad('K_ACh in component acetylcholine_sensitive_current (millimolar)'); LEGEND_STATES(:,18) = strpad('achf in component acetylcholine_sensitive_current_achf_gate (dimensionless)'); LEGEND_STATES(:,19) = strpad('achs in component acetylcholine_sensitive_current_achs_gate (dimensionless)'); LEGEND_CONSTANTS(:,43) = strpad('alpha_achf in component acetylcholine_sensitive_current_achf_gate (per_second)'); LEGEND_ALGEBRAIC(:,16) = strpad('beta_achf in component acetylcholine_sensitive_current_achf_gate (per_second)'); LEGEND_CONSTANTS(:,44) = strpad('alpha_achs in component acetylcholine_sensitive_current_achs_gate (per_second)'); LEGEND_ALGEBRAIC(:,17) = strpad('beta_achs in component acetylcholine_sensitive_current_achs_gate (per_second)'); LEGEND_STATES(:,20) = strpad('Cai in component intracellular_calcium_concentration (millimolar)'); LEGEND_CONSTANTS(:,55) = strpad('V_up in component intracellular_calcium_concentration (micrometre3)'); LEGEND_CONSTANTS(:,56) = strpad('V_rel in component intracellular_calcium_concentration (micrometre3)'); LEGEND_CONSTANTS(:,57) = strpad('V_sub in component intracellular_calcium_concentration (micrometre3)'); LEGEND_CONSTANTS(:,58) = strpad('Vi in component intracellular_calcium_concentration (micrometre3)'); LEGEND_CONSTANTS(:,45) = strpad('V_cell in component intracellular_calcium_concentration (micrometre3)'); LEGEND_ALGEBRAIC(:,73) = strpad('i_up in component intracellular_calcium_concentration (millimolar_per_second)'); LEGEND_ALGEBRAIC(:,74) = strpad('i_tr in component intracellular_calcium_concentration (millimolar_per_second)'); LEGEND_ALGEBRAIC(:,76) = strpad('i_rel in component intracellular_calcium_concentration (millimolar_per_second)'); LEGEND_ALGEBRAIC(:,72) = strpad('i_diff in component intracellular_calcium_concentration (millimolar_per_second)'); LEGEND_STATES(:,21) = strpad('Ca_up in component intracellular_calcium_concentration (millimolar)'); LEGEND_STATES(:,22) = strpad('Ca_rel in component intracellular_calcium_concentration (millimolar)'); LEGEND_CONSTANTS(:,46) = strpad('P_rel in component intracellular_calcium_concentration (per_second)'); LEGEND_CONSTANTS(:,47) = strpad('K_up in component intracellular_calcium_concentration (millimolar)'); LEGEND_CONSTANTS(:,48) = strpad('tau_tr in component intracellular_calcium_concentration (second)'); LEGEND_STATES(:,23) = strpad('f_TC in component intracellular_calcium_concentration (dimensionless)'); LEGEND_STATES(:,24) = strpad('f_TMC in component intracellular_calcium_concentration (dimensionless)'); LEGEND_STATES(:,25) = strpad('f_TMM in component intracellular_calcium_concentration (dimensionless)'); LEGEND_STATES(:,26) = strpad('f_CMi in component intracellular_calcium_concentration (dimensionless)'); LEGEND_STATES(:,27) = strpad('f_CMs in component intracellular_calcium_concentration (dimensionless)'); LEGEND_STATES(:,28) = strpad('f_CQ in component intracellular_calcium_concentration (dimensionless)'); LEGEND_STATES(:,29) = strpad('f_CSL in component intracellular_calcium_concentration (dimensionless)'); LEGEND_ALGEBRAIC(:,75) = strpad('diff_f_TC in component intracellular_calcium_concentration (per_second)'); LEGEND_ALGEBRAIC(:,77) = strpad('diff_f_TMC in component intracellular_calcium_concentration (per_second)'); LEGEND_ALGEBRAIC(:,19) = strpad('diff_f_TMM in component intracellular_calcium_concentration (per_second)'); LEGEND_ALGEBRAIC(:,78) = strpad('diff_f_CMi in component intracellular_calcium_concentration (per_second)'); LEGEND_ALGEBRAIC(:,79) = strpad('diff_f_CMs in component intracellular_calcium_concentration (per_second)'); LEGEND_ALGEBRAIC(:,80) = strpad('diff_f_CQ in component intracellular_calcium_concentration (per_second)'); LEGEND_ALGEBRAIC(:,81) = strpad('diff_f_CSL in component intracellular_calcium_concentration (per_second)'); LEGEND_RATES(:,1) = strpad('d/dt V in component membrane (millivolt)'); LEGEND_RATES(:,2) = strpad('d/dt y in component hyperpolarising_activated_current_y_gate (dimensionless)'); LEGEND_RATES(:,3) = strpad('d/dt paf in component rapid_delayed_rectifier_potassium_current_paf_gate (dimensionless)'); LEGEND_RATES(:,4) = strpad('d/dt pas in component rapid_delayed_rectifier_potassium_current_pas_gate (dimensionless)'); LEGEND_RATES(:,5) = strpad('d/dt pik in component rapid_delayed_rectifier_potassium_current_pik_gate (dimensionless)'); LEGEND_RATES(:,7) = strpad('d/dt m in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_RATES(:,8) = strpad('d/dt h1 in component fast_sodium_current_h1_gate (dimensionless)'); LEGEND_RATES(:,9) = strpad('d/dt h2 in component fast_sodium_current_h2_gate (dimensionless)'); LEGEND_RATES(:,10) = strpad('d/dt d in component L_type_calcium_current_d_gate (dimensionless)'); LEGEND_RATES(:,11) = strpad('d/dt f in component L_type_calcium_current_f_gate (dimensionless)'); LEGEND_RATES(:,12) = strpad('d/dt f2 in component L_type_calcium_current_f2_gate (dimensionless)'); LEGEND_RATES(:,13) = strpad('d/dt r in component transient_outward_potassium_current_r_gate (dimensionless)'); LEGEND_RATES(:,14) = strpad('d/dt q_fast in component transient_outward_potassium_current_qfast_gate (dimensionless)'); LEGEND_RATES(:,15) = strpad('d/dt q_slow in component transient_outward_potassium_current_qslow_gate (dimensionless)'); LEGEND_RATES(:,16) = strpad('d/dt qa in component sustained_outward_potassium_current_qa_gate (dimensionless)'); LEGEND_RATES(:,17) = strpad('d/dt qi in component sustained_outward_potassium_current_qi_gate (dimensionless)'); LEGEND_RATES(:,18) = strpad('d/dt achf in component acetylcholine_sensitive_current_achf_gate (dimensionless)'); LEGEND_RATES(:,19) = strpad('d/dt achs in component acetylcholine_sensitive_current_achs_gate (dimensionless)'); LEGEND_RATES(:,21) = strpad('d/dt Ca_up in component intracellular_calcium_concentration (millimolar)'); LEGEND_RATES(:,22) = strpad('d/dt Ca_rel in component intracellular_calcium_concentration (millimolar)'); LEGEND_RATES(:,20) = strpad('d/dt Cai in component intracellular_calcium_concentration (millimolar)'); LEGEND_RATES(:,6) = strpad('d/dt Casub in component intracellular_calcium_concentration (millimolar)'); LEGEND_RATES(:,23) = strpad('d/dt f_TC in component intracellular_calcium_concentration (dimensionless)'); LEGEND_RATES(:,24) = strpad('d/dt f_TMC in component intracellular_calcium_concentration (dimensionless)'); LEGEND_RATES(:,25) = strpad('d/dt f_TMM in component intracellular_calcium_concentration (dimensionless)'); LEGEND_RATES(:,26) = strpad('d/dt f_CMi in component intracellular_calcium_concentration (dimensionless)'); LEGEND_RATES(:,27) = strpad('d/dt f_CMs in component intracellular_calcium_concentration (dimensionless)'); LEGEND_RATES(:,28) = strpad('d/dt f_CQ in component intracellular_calcium_concentration (dimensionless)'); LEGEND_RATES(:,29) = strpad('d/dt f_CSL in component intracellular_calcium_concentration (dimensionless)'); 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) = -49.7094187908202; CONSTANTS(:,1) = 8314.472; CONSTANTS(:,2) = 310; CONSTANTS(:,3) = 96485.3415; CONSTANTS(:,4) = 4e-5; CONSTANTS(:,5) = 0.001; CONSTANTS(:,6) = 0; STATES(:,2) = 0.0462303183096481; CONSTANTS(:,7) = 0.0035; CONSTANTS(:,8) = 140; CONSTANTS(:,9) = 5.4; STATES(:,3) = 0.192515363116553; STATES(:,4) = 0.0797182955833868; STATES(:,5) = 0.949023698965401; CONSTANTS(:,10) = 0; CONSTANTS(:,11) = 0.0012; CONSTANTS(:,12) = -22.5; CONSTANTS(:,13) = 0.14268; CONSTANTS(:,14) = 8; CONSTANTS(:,15) = 2.14455; CONSTANTS(:,16) = 0.1369; CONSTANTS(:,17) = 0.4315; CONSTANTS(:,18) = 0; CONSTANTS(:,19) = 0.0207; CONSTANTS(:,20) = 395.3; CONSTANTS(:,21) = 2.289; CONSTANTS(:,22) = 26.44; CONSTANTS(:,23) = 26.44; CONSTANTS(:,24) = 4.663; CONSTANTS(:,25) = 1628; CONSTANTS(:,26) = 561.4; CONSTANTS(:,27) = 3.663; CONSTANTS(:,28) = 2; CONSTANTS(:,29) = 140; STATES(:,6) = 0.000160310601192365; CONSTANTS(:,30) = 0; STATES(:,7) = 0.143642247226618; STATES(:,8) = 0.0243210273637729; STATES(:,9) = 0.0157156121147801; CONSTANTS(:,31) = 1e-5; CONSTANTS(:,32) = 0.009; CONSTANTS(:,33) = 62; STATES(:,10) = 0.00179250298710316; STATES(:,11) = 0.975550840189597; STATES(:,12) = 0.774394220125623; CONSTANTS(:,34) = -15; CONSTANTS(:,35) = -5; CONSTANTS(:,36) = -5; CONSTANTS(:,37) = -5; CONSTANTS(:,38) = 0; STATES(:,13) = 0.0296516611999521; STATES(:,14) = 0.899732315818241; STATES(:,15) = 0.190111737767474; CONSTANTS(:,39) = -37.4; CONSTANTS(:,40) = 0.0001; STATES(:,16) = 0.476404610622697; STATES(:,17) = 0.542303657353244; CONSTANTS(:,41) = 0.0198; CONSTANTS(:,42) = 0.00035; STATES(:,18) = 0.550559577208797; STATES(:,19) = 0.567277036232041; CONSTANTS(:,43) = 73.1; CONSTANTS(:,44) = 3.7; STATES(:,20) = 0.000184969821581882; CONSTANTS(:,45) = 3.18872e-6; STATES(:,21) = 1.11092514657408; STATES(:,22) = 0.296249516481577; CONSTANTS(:,46) = 1500; CONSTANTS(:,47) = 0.0006; CONSTANTS(:,48) = 0.06; STATES(:,23) = 0.0356473236675985; STATES(:,24) = 0.443317425115817; STATES(:,25) = 0.491718960234865; STATES(:,26) = 0.0723007987059414; STATES(:,27) = 0.0630771339141488; STATES(:,28) = 0.261430602900137; STATES(:,29) = 4.1497704886823e-5; CONSTANTS(:,49) = ( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3); CONSTANTS(:,50) = CONSTANTS(:,29)./(CONSTANTS(:,24)+CONSTANTS(:,29)); CONSTANTS(:,51) = CONSTANTS(:,49).*log(CONSTANTS(:,9)./CONSTANTS(:,8)); CONSTANTS(:,52) = CONSTANTS(:,49).*log(CONSTANTS(:,29)./CONSTANTS(:,14)); CONSTANTS(:,53) = CONSTANTS(:,49).*log(CONSTANTS(:,9)./CONSTANTS(:,8)); CONSTANTS(:,54) = CONSTANTS(:,14)./(CONSTANTS(:,22)+CONSTANTS(:,14)); CONSTANTS(:,55) = 0.0116000.*CONSTANTS(:,45); CONSTANTS(:,56) = 0.00120000.*CONSTANTS(:,45); CONSTANTS(:,57) = 0.0100000.*CONSTANTS(:,45); CONSTANTS(:,58) = 0.460000.*CONSTANTS(:,45) - CONSTANTS(:,57); 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(:,16) = 120.000./(1.00000+exp( - (STATES(:,1)+50.0000)./15.0000)); RATES(:,18) = CONSTANTS(:,43).*(1.00000 - STATES(:,18)) - ALGEBRAIC(:,16).*STATES(:,18); ALGEBRAIC(:,17) = 5.82000./(1.00000+exp( - (STATES(:,1)+50.0000)./15.0000)); RATES(:,19) = CONSTANTS(:,44).*(1.00000 - STATES(:,19)) - ALGEBRAIC(:,17).*STATES(:,19); ALGEBRAIC(:,19) = 2277.00.*2.50000.*((1.00000 - STATES(:,24)) - STATES(:,25)) - 751.000.*STATES(:,25); RATES(:,25) = ALGEBRAIC(:,19); ALGEBRAIC(:,1) = 1.00000./(1.00000+exp(((STATES(:,1)+83.1900) - ( - 7.20000.*power(CONSTANTS(:,6), 0.690000))./(power(1.26000e-05, 0.690000)+power(CONSTANTS(:,6), 0.690000)))./13.5600)); ALGEBRAIC(:,20) = 0.250000+ 2.00000.*exp( - power(STATES(:,1)+70.0000, 2.00000)./500.000); RATES(:,2) = (ALGEBRAIC(:,1) - STATES(:,2))./ALGEBRAIC(:,20); ALGEBRAIC(:,2) = 1.00000./(1.00000+exp((STATES(:,1)+10.2200)./ - 8.50000)); ALGEBRAIC(:,21) = 1.00000./( 17.0000.*exp( 0.0398000.*STATES(:,1))+ 0.211000.*exp( - 0.0510000.*STATES(:,1))); RATES(:,3) = (ALGEBRAIC(:,2) - STATES(:,3))./ALGEBRAIC(:,21); ALGEBRAIC(:,3) = 1.00000./(1.00000+exp((STATES(:,1)+10.2200)./ - 8.50000)); ALGEBRAIC(:,22) = 0.335810+ 0.906730.*exp( - power(STATES(:,1)+10.0000, 2.00000)./988.050); RATES(:,4) = (ALGEBRAIC(:,3) - STATES(:,4))./ALGEBRAIC(:,22); ALGEBRAIC(:,9) = 1.00000./(1.00000+exp((STATES(:,1) - ( - 24.0000+CONSTANTS(:,36)))./6.31000)); ALGEBRAIC(:,28) = 0.0100000+ 0.153900.*exp( - power(STATES(:,1)+40.0000, 2.00000)./185.670); RATES(:,11) = (ALGEBRAIC(:,9) - STATES(:,11))./ALGEBRAIC(:,28); ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,1) - ( - 24.0000+CONSTANTS(:,37)))./6.31000)); ALGEBRAIC(:,29) = 0.0600000+ 0.480760.*2.25000.*exp( - power(STATES(:,1) - - 40.0000, 2.00000)./138.040); RATES(:,12) = (ALGEBRAIC(:,10) - STATES(:,12))./ALGEBRAIC(:,29); ALGEBRAIC(:,30) = 0.000596000+0.00311800./( 1.03700.*exp( 0.0900000.*(STATES(:,1)+30.6100))+ 0.396000.*exp( - 0.120000.*(STATES(:,1)+23.8400))); ALGEBRAIC(:,11) = 1.00000./(1.00000+exp((STATES(:,1) - 7.44000)./ - 16.4000)); RATES(:,13) = (ALGEBRAIC(:,11) - STATES(:,13))./ALGEBRAIC(:,30); ALGEBRAIC(:,31) = 0.0126600+4.72716./(1.00000+exp((STATES(:,1)+154.500)./23.9600)); ALGEBRAIC(:,12) = 1.00000./(1.00000+exp((STATES(:,1)+33.8000)./6.12000)); RATES(:,14) = (ALGEBRAIC(:,12) - STATES(:,14))./ALGEBRAIC(:,31); ALGEBRAIC(:,32) = 0.100000+ 4.00000.*exp( - power(STATES(:,1)+65.0000, 2.00000)./500.000); ALGEBRAIC(:,13) = 1.00000./(1.00000+exp((STATES(:,1)+33.8000)./6.12000)); RATES(:,15) = (ALGEBRAIC(:,13) - STATES(:,15))./ALGEBRAIC(:,32); ALGEBRAIC(:,5) = STATES(:,1)+44.4000; ALGEBRAIC(:,24) = piecewise({abs(ALGEBRAIC(:,5))<CONSTANTS(:,31), ( - 460.000.* - 12.6730)./exp(ALGEBRAIC(:,5)./ - 12.6730) }, ( - 460.000.*ALGEBRAIC(:,5))./(exp(ALGEBRAIC(:,5)./ - 12.6730) - 1.00000)); ALGEBRAIC(:,37) = 18400.0.*exp(ALGEBRAIC(:,5)./ - 12.6730); RATES(:,7) = ALGEBRAIC(:,24).*(1.00000 - STATES(:,7)) - ALGEBRAIC(:,37).*STATES(:,7); ALGEBRAIC(:,4) = (1.00000./(1.00000+exp((STATES(:,1)+4.90000)./15.1400))).*(1.00000 - 0.300000.*exp( - power(STATES(:,1), 2.00000)./500.000)); ALGEBRAIC(:,23) = 92.0100.*exp( - 0.0183000.*STATES(:,1)); ALGEBRAIC(:,36) = 603.600.*exp( 0.00942000.*STATES(:,1)); ALGEBRAIC(:,44) = 1.00000./(ALGEBRAIC(:,23)+ALGEBRAIC(:,36)); RATES(:,5) = (ALGEBRAIC(:,4) - STATES(:,5))./ALGEBRAIC(:,44); ALGEBRAIC(:,6) = 44.9000.*exp((STATES(:,1)+66.9000)./ - 5.57000); ALGEBRAIC(:,25) = 1491.00./(1.00000+ 323.300.*exp((STATES(:,1)+94.6000)./ - 12.9000)); ALGEBRAIC(:,38) = ALGEBRAIC(:,6)./(ALGEBRAIC(:,6)+ALGEBRAIC(:,25)); ALGEBRAIC(:,45) = 0.0300000./(1.00000+exp((STATES(:,1)+40.0000)./6.00000))+0.000350000; RATES(:,8) = (ALGEBRAIC(:,38) - STATES(:,8))./ALGEBRAIC(:,45); ALGEBRAIC(:,7) = 44.9000.*exp((STATES(:,1)+66.9000)./ - 5.57000); ALGEBRAIC(:,26) = 1491.00./(1.00000+ 323.300.*exp((STATES(:,1)+94.6000)./ - 12.9000)); ALGEBRAIC(:,39) = ALGEBRAIC(:,7)./(ALGEBRAIC(:,7)+ALGEBRAIC(:,26)); ALGEBRAIC(:,46) = 0.120000./(1.00000+exp((STATES(:,1)+60.0000)./2.00000))+0.00295000; RATES(:,9) = (ALGEBRAIC(:,39) - STATES(:,9))./ALGEBRAIC(:,46); ALGEBRAIC(:,40) = 1.00000./(1.00000+exp((STATES(:,1) - ( - 3.20000+CONSTANTS(:,34)))./CONSTANTS(:,35))); ALGEBRAIC(:,8) = ( - 26.1200.*(STATES(:,1)+35.0000))./(exp((STATES(:,1)+35.0000)./ - 2.50000) - 1.00000)+( - 78.1100.*STATES(:,1))./(exp( - 0.208000.*STATES(:,1)) - 1.00000); ALGEBRAIC(:,27) = ( 10.5200.*(STATES(:,1) - 5.00000))./(exp( 0.400000.*(STATES(:,1) - 5.00000)) - 1.00000); ALGEBRAIC(:,47) = 1.00000./(ALGEBRAIC(:,8)+ALGEBRAIC(:,27)); RATES(:,10) = (ALGEBRAIC(:,40) - STATES(:,10))./ALGEBRAIC(:,47); ALGEBRAIC(:,33) = 1.00000./( 0.150000.*exp( - STATES(:,1)./11.0000)+ 0.200000.*exp( - STATES(:,1)./700.000)); ALGEBRAIC(:,41) = 1.00000./( 16.0000.*exp(STATES(:,1)./8.00000)+ 15.0000.*exp(STATES(:,1)./50.0000)); ALGEBRAIC(:,48) = 0.00100000./(ALGEBRAIC(:,33)+ALGEBRAIC(:,41)); ALGEBRAIC(:,14) = 1.00000./(1.00000+exp((STATES(:,1) - - 49.1000)./ - 8.98000)); RATES(:,16) = (ALGEBRAIC(:,14) - STATES(:,16))./ALGEBRAIC(:,48); ALGEBRAIC(:,15) = 0.150400./( 3100.00.*exp(STATES(:,1)./13.0000)+ 700.000.*exp(STATES(:,1)./70.0000)); ALGEBRAIC(:,34) = 0.150400./( 95.0000.*exp( - STATES(:,1)./10.0000)+ 50.0000.*exp( - STATES(:,1)./700.000))+0.000229000./(1.00000+exp( - STATES(:,1)./5.00000)); ALGEBRAIC(:,49) = 0.00100000./(ALGEBRAIC(:,15)+ALGEBRAIC(:,34)); ALGEBRAIC(:,42) = ALGEBRAIC(:,15)./(ALGEBRAIC(:,15)+ALGEBRAIC(:,34)); RATES(:,17) = (ALGEBRAIC(:,42) - STATES(:,17))./ALGEBRAIC(:,49); ALGEBRAIC(:,66) = ( (( CONSTANTS(:,30).*power(STATES(:,7), 3.00000).*( 0.635000.*STATES(:,8)+ 0.365000.*STATES(:,9)).*CONSTANTS(:,29).*STATES(:,1).*CONSTANTS(:,3))./CONSTANTS(:,49)).*(exp((STATES(:,1) - CONSTANTS(:,52))./CONSTANTS(:,49)) - 1.00000))./(exp(STATES(:,1)./CONSTANTS(:,49)) - 1.00000); ALGEBRAIC(:,69) = ( CONSTANTS(:,41).*STATES(:,18).*STATES(:,19).*power(CONSTANTS(:,6), 1.50000))./(power(CONSTANTS(:,42), 1.50000)+power(CONSTANTS(:,6), 1.50000)); ALGEBRAIC(:,70) = ( (( ALGEBRAIC(:,69).*CONSTANTS(:,9))./(10.0000+CONSTANTS(:,9))).*(STATES(:,1) - CONSTANTS(:,51)))./(1.00000+exp(((STATES(:,1) - CONSTANTS(:,51)) - 140.000)./( 2.50000.*CONSTANTS(:,49)))); ALGEBRAIC(:,71) = CONSTANTS(:,32).*STATES(:,10).*( 0.675000.*STATES(:,11)+ 0.325000.*STATES(:,12)).*(STATES(:,1) - CONSTANTS(:,33)).*(1.00000 - (( ALGEBRAIC(:,70).*CONSTANTS(:,6))./(9.00000e-05+CONSTANTS(:,6)))./1.00000); ALGEBRAIC(:,67) = CONSTANTS(:,38).*STATES(:,13).*( 0.450000.*STATES(:,14)+ 0.550000.*STATES(:,15)).*(STATES(:,1) - CONSTANTS(:,53)); ALGEBRAIC(:,35) = CONSTANTS(:,7).*( 0.900000.*STATES(:,3)+ 0.100000.*STATES(:,4)).*STATES(:,5).*(STATES(:,1) - CONSTANTS(:,51)); ALGEBRAIC(:,18) = STATES(:,2).*CONSTANTS(:,5).*(STATES(:,1) - - 30.0000); ALGEBRAIC(:,68) = CONSTANTS(:,40).*STATES(:,16).*STATES(:,17).*(STATES(:,1) - CONSTANTS(:,39)); ALGEBRAIC(:,43) = CONSTANTS(:,10).*(0.500000+0.500000./(1.00000+exp((STATES(:,1)+30.0000)./5.00000))); ALGEBRAIC(:,50) = ( ALGEBRAIC(:,43).*power(CONSTANTS(:,9)./(CONSTANTS(:,9)+0.590000), 3.00000).*(STATES(:,1)+81.9000))./(1.00000+exp(( 1.39300.*(STATES(:,1)+81.9000+3.60000))./CONSTANTS(:,49))); ALGEBRAIC(:,58) = exp(( - CONSTANTS(:,17).*STATES(:,1))./( 2.00000.*CONSTANTS(:,49))); ALGEBRAIC(:,53) = 1.00000+ (CONSTANTS(:,28)./CONSTANTS(:,27)).*(1.00000+exp(( CONSTANTS(:,18).*STATES(:,1))./CONSTANTS(:,49)))+CONSTANTS(:,29)./CONSTANTS(:,25)+power(CONSTANTS(:,29), 2.00000)./( CONSTANTS(:,25).*CONSTANTS(:,26))+power(CONSTANTS(:,29), 3.00000)./( CONSTANTS(:,25).*CONSTANTS(:,26).*CONSTANTS(:,24)); ALGEBRAIC(:,55) = ( (power(CONSTANTS(:,29), 2.00000)./( CONSTANTS(:,25).*CONSTANTS(:,26))+power(CONSTANTS(:,29), 3.00000)./( CONSTANTS(:,25).*CONSTANTS(:,26).*CONSTANTS(:,24))).*exp(( - CONSTANTS(:,17).*STATES(:,1))./( 2.00000.*CONSTANTS(:,49))))./ALGEBRAIC(:,53); ALGEBRAIC(:,56) = ( (CONSTANTS(:,28)./CONSTANTS(:,27)).*exp(( - CONSTANTS(:,18).*STATES(:,1))./CONSTANTS(:,49)))./ALGEBRAIC(:,53); ALGEBRAIC(:,54) = exp(( CONSTANTS(:,17).*STATES(:,1))./( 2.00000.*CONSTANTS(:,49))); ALGEBRAIC(:,61) = ALGEBRAIC(:,58).*CONSTANTS(:,50).*(ALGEBRAIC(:,55)+ALGEBRAIC(:,56))+ ALGEBRAIC(:,56).*ALGEBRAIC(:,54).*(CONSTANTS(:,54)+ALGEBRAIC(:,58)); ALGEBRAIC(:,57) = 1.00000+ (STATES(:,6)./CONSTANTS(:,19)).*(1.00000+exp(( - CONSTANTS(:,16).*STATES(:,1))./CONSTANTS(:,49))+CONSTANTS(:,14)./CONSTANTS(:,23))+CONSTANTS(:,14)./CONSTANTS(:,20)+power(CONSTANTS(:,14), 2.00000)./( CONSTANTS(:,20).*CONSTANTS(:,21))+power(CONSTANTS(:,14), 3.00000)./( CONSTANTS(:,20).*CONSTANTS(:,21).*CONSTANTS(:,22)); ALGEBRAIC(:,60) = ( (STATES(:,6)./CONSTANTS(:,19)).*exp(( - CONSTANTS(:,16).*STATES(:,1))./CONSTANTS(:,49)))./ALGEBRAIC(:,57); ALGEBRAIC(:,59) = ( (power(CONSTANTS(:,14), 2.00000)./( CONSTANTS(:,20).*CONSTANTS(:,21))+power(CONSTANTS(:,14), 3.00000)./( CONSTANTS(:,20).*CONSTANTS(:,21).*CONSTANTS(:,22))).*exp(( CONSTANTS(:,17).*STATES(:,1))./( 2.00000.*CONSTANTS(:,49))))./ALGEBRAIC(:,57); ALGEBRAIC(:,62) = ALGEBRAIC(:,54).*CONSTANTS(:,54).*(ALGEBRAIC(:,59)+ALGEBRAIC(:,60))+ ALGEBRAIC(:,58).*ALGEBRAIC(:,60).*(CONSTANTS(:,50)+ALGEBRAIC(:,54)); ALGEBRAIC(:,63) = ALGEBRAIC(:,59).*CONSTANTS(:,54).*(ALGEBRAIC(:,55)+ALGEBRAIC(:,56))+ ALGEBRAIC(:,60).*ALGEBRAIC(:,55).*(CONSTANTS(:,54)+ALGEBRAIC(:,58)); ALGEBRAIC(:,64) = ALGEBRAIC(:,55).*CONSTANTS(:,50).*(ALGEBRAIC(:,59)+ALGEBRAIC(:,60))+ ALGEBRAIC(:,59).*ALGEBRAIC(:,56).*(CONSTANTS(:,50)+ALGEBRAIC(:,54)); ALGEBRAIC(:,65) = ( CONSTANTS(:,15).*( ALGEBRAIC(:,62).*ALGEBRAIC(:,56) - ALGEBRAIC(:,61).*ALGEBRAIC(:,60)))./(ALGEBRAIC(:,61)+ALGEBRAIC(:,62)+ALGEBRAIC(:,63)+ALGEBRAIC(:,64)); ALGEBRAIC(:,52) = ( CONSTANTS(:,13).*power(CONSTANTS(:,14)./(5.64000+CONSTANTS(:,14)), 3.00000).*power(CONSTANTS(:,9)./(0.621000+CONSTANTS(:,9)), 2.00000).*1.60000)./(1.50000+exp( - (STATES(:,1)+60.0000)./40.0000)); ALGEBRAIC(:,51) = CONSTANTS(:,11).*(STATES(:,1) - CONSTANTS(:,12)); RATES(:,1) = - (ALGEBRAIC(:,66)+ALGEBRAIC(:,71)+ALGEBRAIC(:,67)+ALGEBRAIC(:,35)+ALGEBRAIC(:,18)+ALGEBRAIC(:,68)+ALGEBRAIC(:,50)+ALGEBRAIC(:,65)+ALGEBRAIC(:,52)+ALGEBRAIC(:,51)+ALGEBRAIC(:,70))./CONSTANTS(:,4); ALGEBRAIC(:,73) = 5.00000./(1.00000+CONSTANTS(:,47)./STATES(:,20)); ALGEBRAIC(:,74) = (STATES(:,21) - STATES(:,22))./CONSTANTS(:,48); RATES(:,21) = ALGEBRAIC(:,73) - ( ALGEBRAIC(:,74).*CONSTANTS(:,56))./CONSTANTS(:,55); ALGEBRAIC(:,75) = 88800.0.*STATES(:,20).*(1.00000 - STATES(:,23)) - 446.000.*STATES(:,23); RATES(:,23) = ALGEBRAIC(:,75); ALGEBRAIC(:,77) = 227700..*STATES(:,20).*((1.00000 - STATES(:,24)) - STATES(:,25)) - 7.51000.*STATES(:,24); RATES(:,24) = ALGEBRAIC(:,77); ALGEBRAIC(:,76) = ( CONSTANTS(:,46).*(STATES(:,22) - STATES(:,6)))./(1.00000+power(0.00120000./STATES(:,6), 2.00000)); ALGEBRAIC(:,80) = 534.000.*STATES(:,22).*(1.00000 - STATES(:,28)) - 445.000.*STATES(:,28); RATES(:,22) = (ALGEBRAIC(:,74) - ALGEBRAIC(:,76)) - 10.0000.*ALGEBRAIC(:,80); ALGEBRAIC(:,72) = (STATES(:,6) - STATES(:,20))./4.00000e-05; ALGEBRAIC(:,78) = 227700..*STATES(:,20).*(1.00000 - STATES(:,26)) - 542.000.*STATES(:,26); RATES(:,20) = ( ALGEBRAIC(:,72).*CONSTANTS(:,57) - ALGEBRAIC(:,73).*CONSTANTS(:,55))./CONSTANTS(:,58) - ( 0.0450000.*ALGEBRAIC(:,78)+ 0.0310000.*ALGEBRAIC(:,75)+ 0.0620000.*ALGEBRAIC(:,77)); RATES(:,26) = ALGEBRAIC(:,78); ALGEBRAIC(:,79) = 227700..*STATES(:,6).*(1.00000 - STATES(:,27)) - 542.000.*STATES(:,27); RATES(:,27) = ALGEBRAIC(:,79); RATES(:,28) = ALGEBRAIC(:,80); ALGEBRAIC(:,81) = 0.00100000.*( 115.000.*STATES(:,6).*(1.00000 - STATES(:,29)) - 1000.00.*STATES(:,29)); RATES(:,6) = ((( - (ALGEBRAIC(:,71) - 2.00000.*ALGEBRAIC(:,65))./( 2.00000.*CONSTANTS(:,3))+ ALGEBRAIC(:,76).*CONSTANTS(:,56))./CONSTANTS(:,57) - ALGEBRAIC(:,72)) - 0.0450000.*ALGEBRAIC(:,79)) - (0.0310000./1.20000).*ALGEBRAIC(:,81); RATES(:,29) = ALGEBRAIC(:,81); 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(:,16) = 120.000./(1.00000+exp( - (STATES(:,1)+50.0000)./15.0000)); ALGEBRAIC(:,17) = 5.82000./(1.00000+exp( - (STATES(:,1)+50.0000)./15.0000)); ALGEBRAIC(:,19) = 2277.00.*2.50000.*((1.00000 - STATES(:,24)) - STATES(:,25)) - 751.000.*STATES(:,25); ALGEBRAIC(:,1) = 1.00000./(1.00000+exp(((STATES(:,1)+83.1900) - ( - 7.20000.*power(CONSTANTS(:,6), 0.690000))./(power(1.26000e-05, 0.690000)+power(CONSTANTS(:,6), 0.690000)))./13.5600)); ALGEBRAIC(:,20) = 0.250000+ 2.00000.*exp( - power(STATES(:,1)+70.0000, 2.00000)./500.000); ALGEBRAIC(:,2) = 1.00000./(1.00000+exp((STATES(:,1)+10.2200)./ - 8.50000)); ALGEBRAIC(:,21) = 1.00000./( 17.0000.*exp( 0.0398000.*STATES(:,1))+ 0.211000.*exp( - 0.0510000.*STATES(:,1))); ALGEBRAIC(:,3) = 1.00000./(1.00000+exp((STATES(:,1)+10.2200)./ - 8.50000)); ALGEBRAIC(:,22) = 0.335810+ 0.906730.*exp( - power(STATES(:,1)+10.0000, 2.00000)./988.050); ALGEBRAIC(:,9) = 1.00000./(1.00000+exp((STATES(:,1) - ( - 24.0000+CONSTANTS(:,36)))./6.31000)); ALGEBRAIC(:,28) = 0.0100000+ 0.153900.*exp( - power(STATES(:,1)+40.0000, 2.00000)./185.670); ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,1) - ( - 24.0000+CONSTANTS(:,37)))./6.31000)); ALGEBRAIC(:,29) = 0.0600000+ 0.480760.*2.25000.*exp( - power(STATES(:,1) - - 40.0000, 2.00000)./138.040); ALGEBRAIC(:,30) = 0.000596000+0.00311800./( 1.03700.*exp( 0.0900000.*(STATES(:,1)+30.6100))+ 0.396000.*exp( - 0.120000.*(STATES(:,1)+23.8400))); ALGEBRAIC(:,11) = 1.00000./(1.00000+exp((STATES(:,1) - 7.44000)./ - 16.4000)); ALGEBRAIC(:,31) = 0.0126600+4.72716./(1.00000+exp((STATES(:,1)+154.500)./23.9600)); ALGEBRAIC(:,12) = 1.00000./(1.00000+exp((STATES(:,1)+33.8000)./6.12000)); ALGEBRAIC(:,32) = 0.100000+ 4.00000.*exp( - power(STATES(:,1)+65.0000, 2.00000)./500.000); ALGEBRAIC(:,13) = 1.00000./(1.00000+exp((STATES(:,1)+33.8000)./6.12000)); ALGEBRAIC(:,5) = STATES(:,1)+44.4000; ALGEBRAIC(:,24) = piecewise({abs(ALGEBRAIC(:,5))<CONSTANTS(:,31), ( - 460.000.* - 12.6730)./exp(ALGEBRAIC(:,5)./ - 12.6730) }, ( - 460.000.*ALGEBRAIC(:,5))./(exp(ALGEBRAIC(:,5)./ - 12.6730) - 1.00000)); ALGEBRAIC(:,37) = 18400.0.*exp(ALGEBRAIC(:,5)./ - 12.6730); ALGEBRAIC(:,4) = (1.00000./(1.00000+exp((STATES(:,1)+4.90000)./15.1400))).*(1.00000 - 0.300000.*exp( - power(STATES(:,1), 2.00000)./500.000)); ALGEBRAIC(:,23) = 92.0100.*exp( - 0.0183000.*STATES(:,1)); ALGEBRAIC(:,36) = 603.600.*exp( 0.00942000.*STATES(:,1)); ALGEBRAIC(:,44) = 1.00000./(ALGEBRAIC(:,23)+ALGEBRAIC(:,36)); ALGEBRAIC(:,6) = 44.9000.*exp((STATES(:,1)+66.9000)./ - 5.57000); ALGEBRAIC(:,25) = 1491.00./(1.00000+ 323.300.*exp((STATES(:,1)+94.6000)./ - 12.9000)); ALGEBRAIC(:,38) = ALGEBRAIC(:,6)./(ALGEBRAIC(:,6)+ALGEBRAIC(:,25)); ALGEBRAIC(:,45) = 0.0300000./(1.00000+exp((STATES(:,1)+40.0000)./6.00000))+0.000350000; ALGEBRAIC(:,7) = 44.9000.*exp((STATES(:,1)+66.9000)./ - 5.57000); ALGEBRAIC(:,26) = 1491.00./(1.00000+ 323.300.*exp((STATES(:,1)+94.6000)./ - 12.9000)); ALGEBRAIC(:,39) = ALGEBRAIC(:,7)./(ALGEBRAIC(:,7)+ALGEBRAIC(:,26)); ALGEBRAIC(:,46) = 0.120000./(1.00000+exp((STATES(:,1)+60.0000)./2.00000))+0.00295000; ALGEBRAIC(:,40) = 1.00000./(1.00000+exp((STATES(:,1) - ( - 3.20000+CONSTANTS(:,34)))./CONSTANTS(:,35))); ALGEBRAIC(:,8) = ( - 26.1200.*(STATES(:,1)+35.0000))./(exp((STATES(:,1)+35.0000)./ - 2.50000) - 1.00000)+( - 78.1100.*STATES(:,1))./(exp( - 0.208000.*STATES(:,1)) - 1.00000); ALGEBRAIC(:,27) = ( 10.5200.*(STATES(:,1) - 5.00000))./(exp( 0.400000.*(STATES(:,1) - 5.00000)) - 1.00000); ALGEBRAIC(:,47) = 1.00000./(ALGEBRAIC(:,8)+ALGEBRAIC(:,27)); ALGEBRAIC(:,33) = 1.00000./( 0.150000.*exp( - STATES(:,1)./11.0000)+ 0.200000.*exp( - STATES(:,1)./700.000)); ALGEBRAIC(:,41) = 1.00000./( 16.0000.*exp(STATES(:,1)./8.00000)+ 15.0000.*exp(STATES(:,1)./50.0000)); ALGEBRAIC(:,48) = 0.00100000./(ALGEBRAIC(:,33)+ALGEBRAIC(:,41)); ALGEBRAIC(:,14) = 1.00000./(1.00000+exp((STATES(:,1) - - 49.1000)./ - 8.98000)); ALGEBRAIC(:,15) = 0.150400./( 3100.00.*exp(STATES(:,1)./13.0000)+ 700.000.*exp(STATES(:,1)./70.0000)); ALGEBRAIC(:,34) = 0.150400./( 95.0000.*exp( - STATES(:,1)./10.0000)+ 50.0000.*exp( - STATES(:,1)./700.000))+0.000229000./(1.00000+exp( - STATES(:,1)./5.00000)); ALGEBRAIC(:,49) = 0.00100000./(ALGEBRAIC(:,15)+ALGEBRAIC(:,34)); ALGEBRAIC(:,42) = ALGEBRAIC(:,15)./(ALGEBRAIC(:,15)+ALGEBRAIC(:,34)); ALGEBRAIC(:,66) = ( (( CONSTANTS(:,30).*power(STATES(:,7), 3.00000).*( 0.635000.*STATES(:,8)+ 0.365000.*STATES(:,9)).*CONSTANTS(:,29).*STATES(:,1).*CONSTANTS(:,3))./CONSTANTS(:,49)).*(exp((STATES(:,1) - CONSTANTS(:,52))./CONSTANTS(:,49)) - 1.00000))./(exp(STATES(:,1)./CONSTANTS(:,49)) - 1.00000); ALGEBRAIC(:,69) = ( CONSTANTS(:,41).*STATES(:,18).*STATES(:,19).*power(CONSTANTS(:,6), 1.50000))./(power(CONSTANTS(:,42), 1.50000)+power(CONSTANTS(:,6), 1.50000)); ALGEBRAIC(:,70) = ( (( ALGEBRAIC(:,69).*CONSTANTS(:,9))./(10.0000+CONSTANTS(:,9))).*(STATES(:,1) - CONSTANTS(:,51)))./(1.00000+exp(((STATES(:,1) - CONSTANTS(:,51)) - 140.000)./( 2.50000.*CONSTANTS(:,49)))); ALGEBRAIC(:,71) = CONSTANTS(:,32).*STATES(:,10).*( 0.675000.*STATES(:,11)+ 0.325000.*STATES(:,12)).*(STATES(:,1) - CONSTANTS(:,33)).*(1.00000 - (( ALGEBRAIC(:,70).*CONSTANTS(:,6))./(9.00000e-05+CONSTANTS(:,6)))./1.00000); ALGEBRAIC(:,67) = CONSTANTS(:,38).*STATES(:,13).*( 0.450000.*STATES(:,14)+ 0.550000.*STATES(:,15)).*(STATES(:,1) - CONSTANTS(:,53)); ALGEBRAIC(:,35) = CONSTANTS(:,7).*( 0.900000.*STATES(:,3)+ 0.100000.*STATES(:,4)).*STATES(:,5).*(STATES(:,1) - CONSTANTS(:,51)); ALGEBRAIC(:,18) = STATES(:,2).*CONSTANTS(:,5).*(STATES(:,1) - - 30.0000); ALGEBRAIC(:,68) = CONSTANTS(:,40).*STATES(:,16).*STATES(:,17).*(STATES(:,1) - CONSTANTS(:,39)); ALGEBRAIC(:,43) = CONSTANTS(:,10).*(0.500000+0.500000./(1.00000+exp((STATES(:,1)+30.0000)./5.00000))); ALGEBRAIC(:,50) = ( ALGEBRAIC(:,43).*power(CONSTANTS(:,9)./(CONSTANTS(:,9)+0.590000), 3.00000).*(STATES(:,1)+81.9000))./(1.00000+exp(( 1.39300.*(STATES(:,1)+81.9000+3.60000))./CONSTANTS(:,49))); ALGEBRAIC(:,58) = exp(( - CONSTANTS(:,17).*STATES(:,1))./( 2.00000.*CONSTANTS(:,49))); ALGEBRAIC(:,53) = 1.00000+ (CONSTANTS(:,28)./CONSTANTS(:,27)).*(1.00000+exp(( CONSTANTS(:,18).*STATES(:,1))./CONSTANTS(:,49)))+CONSTANTS(:,29)./CONSTANTS(:,25)+power(CONSTANTS(:,29), 2.00000)./( CONSTANTS(:,25).*CONSTANTS(:,26))+power(CONSTANTS(:,29), 3.00000)./( CONSTANTS(:,25).*CONSTANTS(:,26).*CONSTANTS(:,24)); ALGEBRAIC(:,55) = ( (power(CONSTANTS(:,29), 2.00000)./( CONSTANTS(:,25).*CONSTANTS(:,26))+power(CONSTANTS(:,29), 3.00000)./( CONSTANTS(:,25).*CONSTANTS(:,26).*CONSTANTS(:,24))).*exp(( - CONSTANTS(:,17).*STATES(:,1))./( 2.00000.*CONSTANTS(:,49))))./ALGEBRAIC(:,53); ALGEBRAIC(:,56) = ( (CONSTANTS(:,28)./CONSTANTS(:,27)).*exp(( - CONSTANTS(:,18).*STATES(:,1))./CONSTANTS(:,49)))./ALGEBRAIC(:,53); ALGEBRAIC(:,54) = exp(( CONSTANTS(:,17).*STATES(:,1))./( 2.00000.*CONSTANTS(:,49))); ALGEBRAIC(:,61) = ALGEBRAIC(:,58).*CONSTANTS(:,50).*(ALGEBRAIC(:,55)+ALGEBRAIC(:,56))+ ALGEBRAIC(:,56).*ALGEBRAIC(:,54).*(CONSTANTS(:,54)+ALGEBRAIC(:,58)); ALGEBRAIC(:,57) = 1.00000+ (STATES(:,6)./CONSTANTS(:,19)).*(1.00000+exp(( - CONSTANTS(:,16).*STATES(:,1))./CONSTANTS(:,49))+CONSTANTS(:,14)./CONSTANTS(:,23))+CONSTANTS(:,14)./CONSTANTS(:,20)+power(CONSTANTS(:,14), 2.00000)./( CONSTANTS(:,20).*CONSTANTS(:,21))+power(CONSTANTS(:,14), 3.00000)./( CONSTANTS(:,20).*CONSTANTS(:,21).*CONSTANTS(:,22)); ALGEBRAIC(:,60) = ( (STATES(:,6)./CONSTANTS(:,19)).*exp(( - CONSTANTS(:,16).*STATES(:,1))./CONSTANTS(:,49)))./ALGEBRAIC(:,57); ALGEBRAIC(:,59) = ( (power(CONSTANTS(:,14), 2.00000)./( CONSTANTS(:,20).*CONSTANTS(:,21))+power(CONSTANTS(:,14), 3.00000)./( CONSTANTS(:,20).*CONSTANTS(:,21).*CONSTANTS(:,22))).*exp(( CONSTANTS(:,17).*STATES(:,1))./( 2.00000.*CONSTANTS(:,49))))./ALGEBRAIC(:,57); ALGEBRAIC(:,62) = ALGEBRAIC(:,54).*CONSTANTS(:,54).*(ALGEBRAIC(:,59)+ALGEBRAIC(:,60))+ ALGEBRAIC(:,58).*ALGEBRAIC(:,60).*(CONSTANTS(:,50)+ALGEBRAIC(:,54)); ALGEBRAIC(:,63) = ALGEBRAIC(:,59).*CONSTANTS(:,54).*(ALGEBRAIC(:,55)+ALGEBRAIC(:,56))+ ALGEBRAIC(:,60).*ALGEBRAIC(:,55).*(CONSTANTS(:,54)+ALGEBRAIC(:,58)); ALGEBRAIC(:,64) = ALGEBRAIC(:,55).*CONSTANTS(:,50).*(ALGEBRAIC(:,59)+ALGEBRAIC(:,60))+ ALGEBRAIC(:,59).*ALGEBRAIC(:,56).*(CONSTANTS(:,50)+ALGEBRAIC(:,54)); ALGEBRAIC(:,65) = ( CONSTANTS(:,15).*( ALGEBRAIC(:,62).*ALGEBRAIC(:,56) - ALGEBRAIC(:,61).*ALGEBRAIC(:,60)))./(ALGEBRAIC(:,61)+ALGEBRAIC(:,62)+ALGEBRAIC(:,63)+ALGEBRAIC(:,64)); ALGEBRAIC(:,52) = ( CONSTANTS(:,13).*power(CONSTANTS(:,14)./(5.64000+CONSTANTS(:,14)), 3.00000).*power(CONSTANTS(:,9)./(0.621000+CONSTANTS(:,9)), 2.00000).*1.60000)./(1.50000+exp( - (STATES(:,1)+60.0000)./40.0000)); ALGEBRAIC(:,51) = CONSTANTS(:,11).*(STATES(:,1) - CONSTANTS(:,12)); ALGEBRAIC(:,73) = 5.00000./(1.00000+CONSTANTS(:,47)./STATES(:,20)); ALGEBRAIC(:,74) = (STATES(:,21) - STATES(:,22))./CONSTANTS(:,48); ALGEBRAIC(:,75) = 88800.0.*STATES(:,20).*(1.00000 - STATES(:,23)) - 446.000.*STATES(:,23); ALGEBRAIC(:,77) = 227700..*STATES(:,20).*((1.00000 - STATES(:,24)) - STATES(:,25)) - 7.51000.*STATES(:,24); ALGEBRAIC(:,76) = ( CONSTANTS(:,46).*(STATES(:,22) - STATES(:,6)))./(1.00000+power(0.00120000./STATES(:,6), 2.00000)); ALGEBRAIC(:,80) = 534.000.*STATES(:,22).*(1.00000 - STATES(:,28)) - 445.000.*STATES(:,28); ALGEBRAIC(:,72) = (STATES(:,6) - STATES(:,20))./4.00000e-05; ALGEBRAIC(:,78) = 227700..*STATES(:,20).*(1.00000 - STATES(:,26)) - 542.000.*STATES(:,26); ALGEBRAIC(:,79) = 227700..*STATES(:,6).*(1.00000 - STATES(:,27)) - 542.000.*STATES(:,27); ALGEBRAIC(:,81) = 0.00100000.*( 115.000.*STATES(:,6).*(1.00000 - STATES(:,29)) - 1000.00.*STATES(:,29)); 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