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)) req_length strout = strin(1:req_length); else strout = [strin, blanks(req_length - insize)]; end end