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 =76; end % There are a total of 29 entries in each of the rate and state variable arrays. % There are a total of 86 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 (millisecond)'); LEGEND_STATES(:,1) = strpad('Vm in component Vm (millivolt)'); LEGEND_CONSTANTS(:,1) = strpad('Cm in component model_parameters (picoF)'); LEGEND_ALGEBRAIC(:,32) = strpad('i_CaT in component i_CaT (picoA)'); LEGEND_ALGEBRAIC(:,15) = strpad('i_CaL in component i_CaL (picoA)'); LEGEND_ALGEBRAIC(:,50) = strpad('i_f in component i_f (picoA)'); LEGEND_ALGEBRAIC(:,51) = strpad('i_st in component i_st (picoA)'); LEGEND_ALGEBRAIC(:,38) = strpad('i_Kr in component i_Kr (picoA)'); LEGEND_ALGEBRAIC(:,43) = strpad('i_Ks in component i_Ks (picoA)'); LEGEND_ALGEBRAIC(:,45) = strpad('i_to in component AP_sensitive_currents (picoA)'); LEGEND_ALGEBRAIC(:,47) = strpad('i_sus in component AP_sensitive_currents (picoA)'); LEGEND_ALGEBRAIC(:,53) = strpad('i_NaK in component i_NaK (picoA)'); LEGEND_ALGEBRAIC(:,67) = strpad('i_NaCa in component i_NaCa (picoA)'); LEGEND_ALGEBRAIC(:,54) = strpad('i_b_Ca in component i_b_Ca (picoA)'); LEGEND_ALGEBRAIC(:,52) = strpad('i_b_Na in component i_b_Na (picoA)'); LEGEND_CONSTANTS(:,76) = strpad('E_Na in component electric_potentials (millivolt)'); LEGEND_CONSTANTS(:,77) = strpad('E_K in component electric_potentials (millivolt)'); LEGEND_CONSTANTS(:,78) = strpad('E_Ks in component electric_potentials (millivolt)'); LEGEND_CONSTANTS(:,2) = strpad('R in component model_parameters (joule_per_kilomole_kelvin)'); LEGEND_CONSTANTS(:,3) = strpad('T in component model_parameters (kelvin)'); LEGEND_CONSTANTS(:,4) = strpad('F in component model_parameters (coulomb_per_mole)'); LEGEND_CONSTANTS(:,5) = strpad('Nai in component model_parameters (millimolar)'); LEGEND_CONSTANTS(:,6) = strpad('Nao in component model_parameters (millimolar)'); LEGEND_CONSTANTS(:,7) = strpad('Ki in component model_parameters (millimolar)'); LEGEND_CONSTANTS(:,8) = strpad('Ko in component model_parameters (millimolar)'); LEGEND_CONSTANTS(:,9) = strpad('E_CaL in component i_CaL (millivolt)'); LEGEND_CONSTANTS(:,10) = strpad('g_CaL in component i_CaL (nanoS_per_picoF)'); LEGEND_STATES(:,2) = strpad('Ca_sub in component calcium_dynamics (millimolar)'); LEGEND_STATES(:,3) = strpad('dL in component i_CaL_dL_gate (dimensionless)'); LEGEND_STATES(:,4) = strpad('fL in component i_CaL_fL_gate (dimensionless)'); LEGEND_STATES(:,5) = strpad('fCa in component i_CaL_fCa_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,1) = strpad('dL_infinity in component i_CaL_dL_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,46) = strpad('tau_dL in component i_CaL_dL_gate (millisecond)'); LEGEND_ALGEBRAIC(:,33) = strpad('alpha_dL in component i_CaL_dL_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,44) = strpad('beta_dL in component i_CaL_dL_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,17) = strpad('adVm in component i_CaL_dL_gate (millivolt)'); LEGEND_ALGEBRAIC(:,39) = strpad('bdVm in component i_CaL_dL_gate (millivolt)'); LEGEND_ALGEBRAIC(:,2) = strpad('fL_infinity in component i_CaL_fL_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,18) = strpad('tau_fL in component i_CaL_fL_gate (millisecond)'); LEGEND_CONSTANTS(:,11) = strpad('alpha_fCa in component i_CaL_fCa_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,3) = strpad('fCa_infinity in component i_CaL_fCa_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,19) = strpad('tau_fCa in component i_CaL_fCa_gate (millisecond)'); LEGEND_CONSTANTS(:,12) = strpad('Km_fCa in component i_CaL_fCa_gate (millimolar)'); LEGEND_CONSTANTS(:,13) = strpad('g_CaT in component i_CaT (nanoS_per_picoF)'); LEGEND_CONSTANTS(:,14) = strpad('E_CaT in component i_CaT (millivolt)'); LEGEND_STATES(:,6) = strpad('dT in component i_CaT_dT_gate (dimensionless)'); LEGEND_STATES(:,7) = strpad('fT in component i_CaT_fT_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,4) = strpad('dT_infinity in component i_CaT_dT_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,20) = strpad('tau_dT in component i_CaT_dT_gate (millisecond)'); LEGEND_ALGEBRAIC(:,5) = strpad('fT_infinity in component i_CaT_fT_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,21) = strpad('tau_fT in component i_CaT_fT_gate (millisecond)'); LEGEND_CONSTANTS(:,15) = strpad('g_Kr in component i_Kr (nanoS_per_picoF)'); LEGEND_STATES(:,8) = strpad('paS in component i_Kr_pa_gate (dimensionless)'); LEGEND_STATES(:,9) = strpad('paF in component i_Kr_pa_gate (dimensionless)'); LEGEND_STATES(:,10) = strpad('pi_ in component i_Kr_pi_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,6) = strpad('pa_infinity in component i_Kr_pa_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,22) = strpad('tau_paS in component i_Kr_pa_gate (millisecond)'); LEGEND_ALGEBRAIC(:,23) = strpad('tau_paF in component i_Kr_pa_gate (millisecond)'); LEGEND_ALGEBRAIC(:,7) = strpad('pi_infinity in component i_Kr_pi_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,24) = strpad('tau_pi in component i_Kr_pi_gate (millisecond)'); LEGEND_CONSTANTS(:,16) = strpad('g_Ks in component i_Ks (nanoS_per_picoF)'); LEGEND_STATES(:,11) = strpad('n in component i_Ks_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,34) = strpad('n_infinity in component i_Ks_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,40) = strpad('tau_n in component i_Ks_n_gate (millisecond)'); LEGEND_ALGEBRAIC(:,8) = strpad('alpha_n in component i_Ks_n_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,25) = strpad('beta_n in component i_Ks_n_gate (per_millisecond)'); LEGEND_CONSTANTS(:,17) = strpad('g_to in component AP_sensitive_currents (nanoS_per_picoF)'); LEGEND_CONSTANTS(:,18) = strpad('g_sus in component AP_sensitive_currents (nanoS_per_picoF)'); LEGEND_STATES(:,12) = strpad('q in component AP_sensitive_currents_q_gate (dimensionless)'); LEGEND_STATES(:,13) = strpad('r in component AP_sensitive_currents_r_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,9) = strpad('q_infinity in component AP_sensitive_currents_q_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,26) = strpad('tau_q in component AP_sensitive_currents_q_gate (millisecond)'); LEGEND_ALGEBRAIC(:,10) = strpad('r_infinity in component AP_sensitive_currents_r_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,27) = strpad('tau_r in component AP_sensitive_currents_r_gate (millisecond)'); LEGEND_ALGEBRAIC(:,48) = strpad('i_f_Na in component i_f (picoA)'); LEGEND_ALGEBRAIC(:,49) = strpad('i_f_K in component i_f (picoA)'); LEGEND_CONSTANTS(:,19) = strpad('g_if in component i_f (nanoS_per_picoF)'); LEGEND_STATES(:,14) = strpad('y in component i_f_y_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,11) = strpad('y_infinity in component i_f_y_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,28) = strpad('tau_y in component i_f_y_gate (millisecond)'); LEGEND_CONSTANTS(:,20) = strpad('VIf_half in component i_f_y_gate (millivolt)'); LEGEND_CONSTANTS(:,21) = strpad('g_st in component i_st (nanoS_per_picoF)'); LEGEND_CONSTANTS(:,22) = strpad('E_st in component i_st (millivolt)'); LEGEND_STATES(:,15) = strpad('qa in component i_st_qa_gate (dimensionless)'); LEGEND_STATES(:,16) = strpad('qi in component i_st_qi_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,12) = strpad('qa_infinity in component i_st_qa_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,41) = strpad('tau_qa in component i_st_qa_gate (millisecond)'); LEGEND_ALGEBRAIC(:,29) = strpad('alpha_qa in component i_st_qa_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,35) = strpad('beta_qa in component i_st_qa_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,36) = strpad('qi_infinity in component i_st_qi_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,42) = strpad('tau_qi in component i_st_qi_gate (millisecond)'); LEGEND_ALGEBRAIC(:,13) = strpad('alpha_qi in component i_st_qi_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,30) = strpad('beta_qi in component i_st_qi_gate (per_millisecond)'); LEGEND_CONSTANTS(:,23) = strpad('g_b_Na in component i_b_Na (nanoS_per_picoF)'); LEGEND_CONSTANTS(:,24) = strpad('Km_Kp in component i_NaK (millimolar)'); LEGEND_CONSTANTS(:,25) = strpad('Km_Nap in component i_NaK (millimolar)'); LEGEND_CONSTANTS(:,26) = strpad('i_NaK_max in component i_NaK (picoA_per_picoF)'); LEGEND_CONSTANTS(:,27) = strpad('g_b_Ca in component i_b_Ca (nanoS_per_picoF)'); LEGEND_CONSTANTS(:,28) = strpad('kNaCa in component i_NaCa (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,64) = strpad('x1 in component i_NaCa (dimensionless)'); LEGEND_ALGEBRAIC(:,60) = strpad('x2 in component i_NaCa (dimensionless)'); LEGEND_ALGEBRAIC(:,65) = strpad('x3 in component i_NaCa (dimensionless)'); LEGEND_ALGEBRAIC(:,66) = strpad('x4 in component i_NaCa (dimensionless)'); LEGEND_ALGEBRAIC(:,55) = strpad('k41 in component i_NaCa (dimensionless)'); LEGEND_CONSTANTS(:,81) = strpad('k34 in component i_NaCa (dimensionless)'); LEGEND_ALGEBRAIC(:,63) = strpad('k23 in component i_NaCa (dimensionless)'); LEGEND_ALGEBRAIC(:,62) = strpad('k21 in component i_NaCa (dimensionless)'); LEGEND_ALGEBRAIC(:,59) = strpad('k32 in component i_NaCa (dimensionless)'); LEGEND_CONSTANTS(:,80) = strpad('k43 in component i_NaCa (dimensionless)'); LEGEND_ALGEBRAIC(:,57) = strpad('k12 in component i_NaCa (dimensionless)'); LEGEND_ALGEBRAIC(:,58) = strpad('k14 in component i_NaCa (dimensionless)'); LEGEND_CONSTANTS(:,29) = strpad('Qci in component i_NaCa (dimensionless)'); LEGEND_CONSTANTS(:,30) = strpad('Qn in component i_NaCa (dimensionless)'); LEGEND_CONSTANTS(:,31) = strpad('Qco in component i_NaCa (dimensionless)'); LEGEND_CONSTANTS(:,32) = strpad('K3ni in component i_NaCa (millimolar)'); LEGEND_CONSTANTS(:,33) = strpad('Kci in component i_NaCa (millimolar)'); LEGEND_CONSTANTS(:,34) = strpad('K1ni in component i_NaCa (millimolar)'); LEGEND_CONSTANTS(:,35) = strpad('K2ni in component i_NaCa (millimolar)'); LEGEND_CONSTANTS(:,36) = strpad('Kcni in component i_NaCa (millimolar)'); LEGEND_CONSTANTS(:,37) = strpad('K3no in component i_NaCa (millimolar)'); LEGEND_CONSTANTS(:,38) = strpad('K1no in component i_NaCa (millimolar)'); LEGEND_CONSTANTS(:,39) = strpad('K2no in component i_NaCa (millimolar)'); LEGEND_CONSTANTS(:,40) = strpad('Kco in component i_NaCa (millimolar)'); LEGEND_CONSTANTS(:,79) = strpad('RTOnF in component i_NaCa (millivolt)'); LEGEND_ALGEBRAIC(:,61) = strpad('do in component i_NaCa (dimensionless)'); LEGEND_ALGEBRAIC(:,56) = strpad('di in component i_NaCa (dimensionless)'); LEGEND_CONSTANTS(:,41) = strpad('Cao in component model_parameters (millimolar)'); LEGEND_ALGEBRAIC(:,68) = strpad('j_SRCarel in component j_SRCarel (millimolar_per_millisecond)'); LEGEND_STATES(:,17) = strpad('R in component j_SRCarel (dimensionless)'); LEGEND_STATES(:,18) = strpad('O in component j_SRCarel (dimensionless)'); LEGEND_STATES(:,19) = strpad('I in component j_SRCarel (dimensionless)'); LEGEND_STATES(:,20) = strpad('RI in component j_SRCarel (dimensionless)'); LEGEND_CONSTANTS(:,42) = strpad('ks in component j_SRCarel (per_millisecond)'); LEGEND_CONSTANTS(:,43) = strpad('MaxSR in component j_SRCarel (dimensionless)'); LEGEND_CONSTANTS(:,44) = strpad('MinSR in component j_SRCarel (dimensionless)'); LEGEND_CONSTANTS(:,45) = strpad('EC50_SR in component j_SRCarel (millimolar)'); LEGEND_CONSTANTS(:,46) = strpad('HSR in component j_SRCarel (dimensionless)'); LEGEND_ALGEBRAIC(:,31) = strpad('koSRCa in component j_SRCarel (per_millimolar2_millisecond)'); LEGEND_ALGEBRAIC(:,37) = strpad('kiSRCa in component j_SRCarel (per_millimolar_millisecond)'); LEGEND_CONSTANTS(:,47) = strpad('koCa in component j_SRCarel (per_millimolar2_millisecond)'); LEGEND_CONSTANTS(:,48) = strpad('kiCa in component j_SRCarel (per_millimolar_millisecond)'); LEGEND_ALGEBRAIC(:,14) = strpad('kCaSR in component j_SRCarel (dimensionless)'); LEGEND_CONSTANTS(:,49) = strpad('kim in component j_SRCarel (per_millisecond)'); LEGEND_CONSTANTS(:,50) = strpad('kom in component j_SRCarel (per_millisecond)'); LEGEND_STATES(:,21) = strpad('Ca_jsr in component calcium_dynamics (millimolar)'); LEGEND_ALGEBRAIC(:,69) = strpad('j_Ca_dif in component intracellular_calcium_fluxes (millimolar_per_millisecond)'); LEGEND_ALGEBRAIC(:,71) = strpad('j_up in component intracellular_calcium_fluxes (millimolar_per_millisecond)'); LEGEND_ALGEBRAIC(:,73) = strpad('j_tr in component intracellular_calcium_fluxes (millimolar_per_millisecond)'); LEGEND_CONSTANTS(:,51) = strpad('tau_dif_Ca in component intracellular_calcium_fluxes (millisecond)'); LEGEND_CONSTANTS(:,52) = strpad('tau_tr in component intracellular_calcium_fluxes (millisecond)'); LEGEND_CONSTANTS(:,53) = strpad('P_up in component intracellular_calcium_fluxes (millimolar_per_millisecond)'); LEGEND_CONSTANTS(:,54) = strpad('K_up in component intracellular_calcium_fluxes (millimolar)'); LEGEND_STATES(:,22) = strpad('Ca_nsr in component calcium_dynamics (millimolar)'); LEGEND_STATES(:,23) = strpad('Cai in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,55) = strpad('TC_tot in component calcium_buffering (millimolar)'); LEGEND_CONSTANTS(:,56) = strpad('TMC_tot in component calcium_buffering (millimolar)'); LEGEND_CONSTANTS(:,57) = strpad('CM_tot in component calcium_buffering (millimolar)'); LEGEND_CONSTANTS(:,58) = strpad('CQ_tot in component calcium_buffering (millimolar)'); LEGEND_ALGEBRAIC(:,72) = strpad('delta_fTC in component calcium_buffering (per_millisecond)'); LEGEND_ALGEBRAIC(:,74) = strpad('delta_fTMC in component calcium_buffering (per_millisecond)'); LEGEND_ALGEBRAIC(:,70) = strpad('delta_fCMs in component calcium_buffering (per_millisecond)'); LEGEND_ALGEBRAIC(:,76) = strpad('delta_fCMi in component calcium_buffering (per_millisecond)'); LEGEND_ALGEBRAIC(:,75) = strpad('delta_fCQ in component calcium_buffering (per_millisecond)'); LEGEND_ALGEBRAIC(:,16) = strpad('delta_fTMM in component calcium_buffering (per_millisecond)'); LEGEND_STATES(:,24) = strpad('fTMM in component calcium_buffering (dimensionless)'); LEGEND_STATES(:,25) = strpad('fCMi in component calcium_buffering (dimensionless)'); LEGEND_STATES(:,26) = strpad('fCMs in component calcium_buffering (dimensionless)'); LEGEND_STATES(:,27) = strpad('fTC in component calcium_buffering (dimensionless)'); LEGEND_STATES(:,28) = strpad('fTMC in component calcium_buffering (dimensionless)'); LEGEND_STATES(:,29) = strpad('fCQ in component calcium_buffering (dimensionless)'); LEGEND_CONSTANTS(:,59) = strpad('kf_TC in component calcium_buffering (per_millimolar_millisecond)'); LEGEND_CONSTANTS(:,60) = strpad('kf_TMM in component calcium_buffering (per_millimolar_millisecond)'); LEGEND_CONSTANTS(:,61) = strpad('kf_TMC in component calcium_buffering (per_millimolar_millisecond)'); LEGEND_CONSTANTS(:,62) = strpad('kf_CM in component calcium_buffering (per_millimolar_millisecond)'); LEGEND_CONSTANTS(:,63) = strpad('kf_CQ in component calcium_buffering (per_millimolar_millisecond)'); LEGEND_CONSTANTS(:,64) = strpad('kb_TC in component calcium_buffering (per_millisecond)'); LEGEND_CONSTANTS(:,65) = strpad('kb_TMC in component calcium_buffering (per_millisecond)'); LEGEND_CONSTANTS(:,66) = strpad('kb_TMM in component calcium_buffering (per_millisecond)'); LEGEND_CONSTANTS(:,67) = strpad('kb_CM in component calcium_buffering (per_millisecond)'); LEGEND_CONSTANTS(:,68) = strpad('kb_CQ in component calcium_buffering (per_millisecond)'); LEGEND_CONSTANTS(:,69) = strpad('Mgi in component model_parameters (millimolar)'); LEGEND_CONSTANTS(:,85) = strpad('V_i in component model_parameters (picolitre)'); LEGEND_CONSTANTS(:,84) = strpad('V_jsr in component model_parameters (picolitre)'); LEGEND_CONSTANTS(:,86) = strpad('V_nsr in component model_parameters (picolitre)'); LEGEND_CONSTANTS(:,83) = strpad('V_sub in component model_parameters (picolitre)'); LEGEND_CONSTANTS(:,82) = strpad('V_cell in component model_parameters (picolitre)'); LEGEND_CONSTANTS(:,70) = strpad('V_jsr_part in component model_parameters (dimensionless)'); LEGEND_CONSTANTS(:,71) = strpad('V_i_part in component model_parameters (dimensionless)'); LEGEND_CONSTANTS(:,72) = strpad('V_nsr_part in component model_parameters (dimensionless)'); LEGEND_CONSTANTS(:,73) = strpad('R_cell in component model_parameters (micrometre)'); LEGEND_CONSTANTS(:,74) = strpad('L_cell in component model_parameters (micrometre)'); LEGEND_CONSTANTS(:,75) = strpad('L_sub in component model_parameters (micrometre)'); LEGEND_RATES(:,1) = strpad('d/dt Vm in component Vm (millivolt)'); LEGEND_RATES(:,3) = strpad('d/dt dL in component i_CaL_dL_gate (dimensionless)'); LEGEND_RATES(:,4) = strpad('d/dt fL in component i_CaL_fL_gate (dimensionless)'); LEGEND_RATES(:,5) = strpad('d/dt fCa in component i_CaL_fCa_gate (dimensionless)'); LEGEND_RATES(:,6) = strpad('d/dt dT in component i_CaT_dT_gate (dimensionless)'); LEGEND_RATES(:,7) = strpad('d/dt fT in component i_CaT_fT_gate (dimensionless)'); LEGEND_RATES(:,8) = strpad('d/dt paS in component i_Kr_pa_gate (dimensionless)'); LEGEND_RATES(:,9) = strpad('d/dt paF in component i_Kr_pa_gate (dimensionless)'); LEGEND_RATES(:,10) = strpad('d/dt pi_ in component i_Kr_pi_gate (dimensionless)'); LEGEND_RATES(:,11) = strpad('d/dt n in component i_Ks_n_gate (dimensionless)'); LEGEND_RATES(:,12) = strpad('d/dt q in component AP_sensitive_currents_q_gate (dimensionless)'); LEGEND_RATES(:,13) = strpad('d/dt r in component AP_sensitive_currents_r_gate (dimensionless)'); LEGEND_RATES(:,14) = strpad('d/dt y in component i_f_y_gate (dimensionless)'); LEGEND_RATES(:,15) = strpad('d/dt qa in component i_st_qa_gate (dimensionless)'); LEGEND_RATES(:,16) = strpad('d/dt qi in component i_st_qi_gate (dimensionless)'); LEGEND_RATES(:,17) = strpad('d/dt R in component j_SRCarel (dimensionless)'); LEGEND_RATES(:,18) = strpad('d/dt O in component j_SRCarel (dimensionless)'); LEGEND_RATES(:,19) = strpad('d/dt I in component j_SRCarel (dimensionless)'); LEGEND_RATES(:,20) = strpad('d/dt RI in component j_SRCarel (dimensionless)'); LEGEND_RATES(:,27) = strpad('d/dt fTC in component calcium_buffering (dimensionless)'); LEGEND_RATES(:,28) = strpad('d/dt fTMC in component calcium_buffering (dimensionless)'); LEGEND_RATES(:,24) = strpad('d/dt fTMM in component calcium_buffering (dimensionless)'); LEGEND_RATES(:,25) = strpad('d/dt fCMi in component calcium_buffering (dimensionless)'); LEGEND_RATES(:,26) = strpad('d/dt fCMs in component calcium_buffering (dimensionless)'); LEGEND_RATES(:,29) = strpad('d/dt fCQ in component calcium_buffering (dimensionless)'); LEGEND_RATES(:,23) = strpad('d/dt Cai in component calcium_dynamics (millimolar)'); LEGEND_RATES(:,2) = strpad('d/dt Ca_sub in component calcium_dynamics (millimolar)'); LEGEND_RATES(:,22) = strpad('d/dt Ca_nsr in component calcium_dynamics (millimolar)'); LEGEND_RATES(:,21) = strpad('d/dt Ca_jsr in component calcium_dynamics (millimolar)'); 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) = -57.9639346865; CONSTANTS(:,1) = 32; CONSTANTS(:,2) = 8314.4; CONSTANTS(:,3) = 310.15; CONSTANTS(:,4) = 96485; CONSTANTS(:,5) = 10; CONSTANTS(:,6) = 140; CONSTANTS(:,7) = 140; CONSTANTS(:,8) = 5.4; CONSTANTS(:,9) = 45; CONSTANTS(:,10) = 0.464; STATES(:,2) = 0.000138112560112; STATES(:,3) = 0.000584545564405; STATES(:,4) = 0.862381249774; STATES(:,5) = 0.711395919653; CONSTANTS(:,11) = 0.021; CONSTANTS(:,12) = 0.00035; CONSTANTS(:,13) = 0.1832; CONSTANTS(:,14) = 45; STATES(:,6) = 0.00504393374639; STATES(:,7) = 0.420757825415; CONSTANTS(:,15) = 0.08113973; STATES(:,8) = 0.453100576739; STATES(:,9) = 0.144755091176; STATES(:,10) = 0.849409822329; CONSTANTS(:,16) = 0.0259; STATES(:,11) = 0.0264600410928; CONSTANTS(:,17) = 0.252; CONSTANTS(:,18) = 0.02; STATES(:,12) = 0.694241313965; STATES(:,13) = 0.00558131733359; CONSTANTS(:,19) = 0.15; STATES(:,14) = 0.113643187247; CONSTANTS(:,20) = -64; CONSTANTS(:,21) = 0.003; CONSTANTS(:,22) = 37.4; STATES(:,15) = 0.42380243163; STATES(:,16) = 0.447294008304; CONSTANTS(:,23) = 0.00486; CONSTANTS(:,24) = 1.4; CONSTANTS(:,25) = 14; CONSTANTS(:,26) = 2.88; CONSTANTS(:,27) = 0.0006; CONSTANTS(:,28) = 187.5; CONSTANTS(:,29) = 0.1369; CONSTANTS(:,30) = 0.4315; CONSTANTS(:,31) = 0; CONSTANTS(:,32) = 26.44; CONSTANTS(:,33) = 0.0207; CONSTANTS(:,34) = 395.3; CONSTANTS(:,35) = 2.289; CONSTANTS(:,36) = 26.44; CONSTANTS(:,37) = 4.663; CONSTANTS(:,38) = 1628; CONSTANTS(:,39) = 561.4; CONSTANTS(:,40) = 3.663; CONSTANTS(:,41) = 2; STATES(:,17) = 0.688047760973; STATES(:,18) = 1.7340201253e-7; STATES(:,19) = 7.86181717518e-8; STATES(:,20) = 0.311951987007; CONSTANTS(:,42) = 250000; CONSTANTS(:,43) = 15; CONSTANTS(:,44) = 1; CONSTANTS(:,45) = 0.45; CONSTANTS(:,46) = 2.5; CONSTANTS(:,47) = 10; CONSTANTS(:,48) = 0.5; CONSTANTS(:,49) = 0.005; CONSTANTS(:,50) = 0.06; STATES(:,21) = 0.316762674605; CONSTANTS(:,51) = 0.04; CONSTANTS(:,52) = 40; CONSTANTS(:,53) = 0.012; CONSTANTS(:,54) = 0.0006; STATES(:,22) = 1.49348117734; STATES(:,23) = 0.000150018670943; CONSTANTS(:,55) = 0.031; CONSTANTS(:,56) = 0.062; CONSTANTS(:,57) = 0.045; CONSTANTS(:,58) = 10; STATES(:,24) = 0.501049376634; STATES(:,25) = 0.0594880901438; STATES(:,26) = 0.054381370046; STATES(:,27) = 0.0291316176172; STATES(:,28) = 0.432694959597; STATES(:,29) = 0.273207128393; CONSTANTS(:,59) = 88.8; CONSTANTS(:,60) = 2.277; CONSTANTS(:,61) = 227.7; CONSTANTS(:,62) = 227.7; CONSTANTS(:,63) = 0.534; CONSTANTS(:,64) = 0.446; CONSTANTS(:,65) = 0.00751; CONSTANTS(:,66) = 0.751; CONSTANTS(:,67) = 0.542; CONSTANTS(:,68) = 0.445; CONSTANTS(:,69) = 2.5; CONSTANTS(:,70) = 0.0012; CONSTANTS(:,71) = 0.46; CONSTANTS(:,72) = 0.0116; CONSTANTS(:,73) = 4; CONSTANTS(:,74) = 70; CONSTANTS(:,75) = 0.02; CONSTANTS(:,76) = (( CONSTANTS(:,2).*CONSTANTS(:,3))./CONSTANTS(:,4)).*log(CONSTANTS(:,6)./CONSTANTS(:,5)); CONSTANTS(:,77) = (( CONSTANTS(:,2).*CONSTANTS(:,3))./CONSTANTS(:,4)).*log(CONSTANTS(:,8)./CONSTANTS(:,7)); CONSTANTS(:,78) = (( CONSTANTS(:,2).*CONSTANTS(:,3))./CONSTANTS(:,4)).*log((CONSTANTS(:,8)+ 0.120000.*CONSTANTS(:,6))./(CONSTANTS(:,7)+ 0.120000.*CONSTANTS(:,5))); CONSTANTS(:,79) = ( CONSTANTS(:,2).*CONSTANTS(:,3))./CONSTANTS(:,4); CONSTANTS(:,80) = CONSTANTS(:,5)./(CONSTANTS(:,32)+CONSTANTS(:,5)); CONSTANTS(:,81) = CONSTANTS(:,6)./(CONSTANTS(:,37)+CONSTANTS(:,6)); CONSTANTS(:,82) = 0.00100000.* pi.*power(CONSTANTS(:,73), 2.00000).*CONSTANTS(:,74); CONSTANTS(:,83) = 0.00100000.*2.00000.* pi.*CONSTANTS(:,75).*(CONSTANTS(:,73) - CONSTANTS(:,75)./2.00000).*CONSTANTS(:,74); CONSTANTS(:,84) = CONSTANTS(:,70).*CONSTANTS(:,82); CONSTANTS(:,85) = CONSTANTS(:,71).*CONSTANTS(:,82) - CONSTANTS(:,83); CONSTANTS(:,86) = CONSTANTS(:,72).*CONSTANTS(:,82); 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) = CONSTANTS(:,60).*CONSTANTS(:,69).*(1.00000 - (STATES(:,28)+STATES(:,24))) - CONSTANTS(:,66).*STATES(:,24); RATES(:,24) = ALGEBRAIC(:,16); ALGEBRAIC(:,2) = 1.00000./(1.00000+exp((STATES(:,1)+35.0000)./7.30000)); ALGEBRAIC(:,18) = 44.3000+ 257.100.*exp( - power((STATES(:,1)+32.5000)./13.9000, 2.00000)); RATES(:,4) = (ALGEBRAIC(:,2) - STATES(:,4))./ALGEBRAIC(:,18); ALGEBRAIC(:,3) = CONSTANTS(:,12)./(CONSTANTS(:,12)+STATES(:,2)); ALGEBRAIC(:,19) = ALGEBRAIC(:,3)./CONSTANTS(:,11); RATES(:,5) = (ALGEBRAIC(:,3) - STATES(:,5))./ALGEBRAIC(:,19); ALGEBRAIC(:,4) = 1.00000./(1.00000+exp( - (STATES(:,1)+26.3000)./6.00000)); ALGEBRAIC(:,20) = 1.00000./( 1.06800.*exp((STATES(:,1)+26.3000)./30.0000)+ 1.06800.*exp( - (STATES(:,1)+26.3000)./30.0000)); RATES(:,6) = (ALGEBRAIC(:,4) - STATES(:,6))./ALGEBRAIC(:,20); ALGEBRAIC(:,5) = 1.00000./(1.00000+exp((STATES(:,1)+61.7000)./5.60000)); ALGEBRAIC(:,21) = 1.00000./( 0.0153000.*exp( - (STATES(:,1)+61.7000)./83.3000)+ 0.0150000.*exp((STATES(:,1)+61.7000)./15.3800)); RATES(:,7) = (ALGEBRAIC(:,5) - STATES(:,7))./ALGEBRAIC(:,21); ALGEBRAIC(:,6) = 1.00000./(1.00000+exp( - (STATES(:,1)+23.2000)./10.6000)); ALGEBRAIC(:,22) = 0.846554./( 0.00420000.*exp(STATES(:,1)./17.0000)+ 0.000150000.*exp( - STATES(:,1)./21.6000)); RATES(:,8) = (ALGEBRAIC(:,6) - STATES(:,8))./ALGEBRAIC(:,22); ALGEBRAIC(:,23) = 0.846554./( 0.0372000.*exp(STATES(:,1)./15.9000)+ 0.000960000.*exp( - STATES(:,1)./22.5000)); RATES(:,9) = (ALGEBRAIC(:,6) - STATES(:,9))./ALGEBRAIC(:,23); ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,1)+28.6000)./17.1000)); ALGEBRAIC(:,24) = 1.00000./( 0.100000.*exp( - STATES(:,1)./54.6450)+ 0.656000.*exp(STATES(:,1)./106.157)); RATES(:,10) = (ALGEBRAIC(:,7) - STATES(:,10))./ALGEBRAIC(:,24); ALGEBRAIC(:,9) = 1.00000./(1.00000+exp((STATES(:,1)+49.0000)./13.0000)); ALGEBRAIC(:,26) = 6.06000+39.1020./( 0.570000.*exp( - 0.0800000.*(STATES(:,1)+44.0000))+ 0.0650000.*exp( 0.100000.*(STATES(:,1)+45.9300))); RATES(:,12) = (ALGEBRAIC(:,9) - STATES(:,12))./ALGEBRAIC(:,26); ALGEBRAIC(:,10) = 1.00000./(1.00000+exp( - (STATES(:,1) - 19.3000)./15.0000)); ALGEBRAIC(:,27) = 2.75352+14.4052./( 1.03700.*exp( 0.0900000.*(STATES(:,1)+30.6100))+ 0.369000.*exp( - 0.120000.*(STATES(:,1)+23.8400))); RATES(:,13) = (ALGEBRAIC(:,10) - STATES(:,13))./ALGEBRAIC(:,27); ALGEBRAIC(:,11) = 1.00000./(1.00000+exp((STATES(:,1) - CONSTANTS(:,20))./13.5000)); ALGEBRAIC(:,28) = 0.716653./(exp( - (STATES(:,1)+386.900)./45.3020)+exp((STATES(:,1) - 73.0800)./19.2310)); RATES(:,14) = (ALGEBRAIC(:,11) - STATES(:,14))./ALGEBRAIC(:,28); ALGEBRAIC(:,14) = CONSTANTS(:,43) - (CONSTANTS(:,43) - CONSTANTS(:,44))./(1.00000+power(CONSTANTS(:,45)./STATES(:,21), CONSTANTS(:,46))); ALGEBRAIC(:,31) = CONSTANTS(:,47)./ALGEBRAIC(:,14); ALGEBRAIC(:,37) = CONSTANTS(:,48).*ALGEBRAIC(:,14); RATES(:,17) = ( CONSTANTS(:,49).*STATES(:,20) - ALGEBRAIC(:,37).*STATES(:,2).*STATES(:,17)) - ( ALGEBRAIC(:,31).*power(STATES(:,2), 2.00000).*STATES(:,17) - CONSTANTS(:,50).*STATES(:,18)); RATES(:,18) = ( ALGEBRAIC(:,31).*power(STATES(:,2), 2.00000).*STATES(:,17) - CONSTANTS(:,50).*STATES(:,18)) - ( ALGEBRAIC(:,37).*STATES(:,2).*STATES(:,18) - CONSTANTS(:,49).*STATES(:,19)); RATES(:,19) = ( ALGEBRAIC(:,37).*STATES(:,2).*STATES(:,18) - CONSTANTS(:,49).*STATES(:,19)) - ( CONSTANTS(:,50).*STATES(:,19) - ALGEBRAIC(:,31).*power(STATES(:,2), 2.00000).*STATES(:,20)); RATES(:,20) = ( CONSTANTS(:,50).*STATES(:,19) - ALGEBRAIC(:,31).*power(STATES(:,2), 2.00000).*STATES(:,20)) - ( CONSTANTS(:,49).*STATES(:,20) - ALGEBRAIC(:,37).*STATES(:,2).*STATES(:,17)); ALGEBRAIC(:,8) = 0.0140000./(1.00000+exp( - (STATES(:,1) - 40.0000)./9.00000)); ALGEBRAIC(:,25) = 0.00100000.*exp( - STATES(:,1)./45.0000); ALGEBRAIC(:,34) = ALGEBRAIC(:,8)./(ALGEBRAIC(:,8)+ALGEBRAIC(:,25)); ALGEBRAIC(:,40) = 1.00000./(ALGEBRAIC(:,8)+ALGEBRAIC(:,25)); RATES(:,11) = (ALGEBRAIC(:,34) - STATES(:,11))./ALGEBRAIC(:,40); ALGEBRAIC(:,12) = 1.00000./(1.00000+exp( - (STATES(:,1)+57.0000)./5.00000)); ALGEBRAIC(:,29) = 1.00000./( 0.150000.*exp( - STATES(:,1)./11.0000)+ 0.200000.*exp( - STATES(:,1)./700.000)); ALGEBRAIC(:,35) = 1.00000./( 16.0000.*exp(STATES(:,1)./8.00000)+ 15.0000.*exp(STATES(:,1)./50.0000)); ALGEBRAIC(:,41) = 1.00000./(ALGEBRAIC(:,29)+ALGEBRAIC(:,35)); RATES(:,15) = (ALGEBRAIC(:,12) - STATES(:,15))./ALGEBRAIC(:,41); ALGEBRAIC(:,13) = 1.00000./( 3100.00.*exp(STATES(:,1)./13.0000)+ 700.000.*exp(STATES(:,1)./70.0000)); ALGEBRAIC(:,30) = 1.00000./( 95.0000.*exp( - STATES(:,1)./10.0000)+ 50.0000.*exp( - STATES(:,1)./700.000))+0.000229000./(1.00000+exp( - STATES(:,1)./5.00000)); ALGEBRAIC(:,36) = ALGEBRAIC(:,13)./(ALGEBRAIC(:,13)+ALGEBRAIC(:,30)); ALGEBRAIC(:,42) = 6.65000./(ALGEBRAIC(:,13)+ALGEBRAIC(:,30)); RATES(:,16) = (ALGEBRAIC(:,36) - STATES(:,16))./ALGEBRAIC(:,42); ALGEBRAIC(:,1) = 1.00000./(1.00000+exp( - (STATES(:,1)+13.5000)./6.00000)); ALGEBRAIC(:,17) = piecewise({STATES(:,1)== - 35.0000, - 35.0000 , STATES(:,1)==0.00000, 1.00000e-05 }, STATES(:,1)); ALGEBRAIC(:,33) = ( - 0.0283900.*(ALGEBRAIC(:,17)+35.0000))./(exp( - (ALGEBRAIC(:,17)+35.0000)./2.50000) - 1.00000) - ( 0.0849000.*ALGEBRAIC(:,17))./(exp( - ALGEBRAIC(:,17)./4.80000) - 1.00000); ALGEBRAIC(:,39) = piecewise({STATES(:,1)==5.00000, 5.00001 }, STATES(:,1)); ALGEBRAIC(:,44) = ( 0.0114300.*(ALGEBRAIC(:,39) - 5.00000))./(exp((ALGEBRAIC(:,39) - 5.00000)./2.50000) - 1.00000); ALGEBRAIC(:,46) = 1.00000./(ALGEBRAIC(:,33)+ALGEBRAIC(:,44)); RATES(:,3) = (ALGEBRAIC(:,1) - STATES(:,3))./ALGEBRAIC(:,46); ALGEBRAIC(:,32) = CONSTANTS(:,1).*CONSTANTS(:,13).*(STATES(:,1) - CONSTANTS(:,14)).*STATES(:,6).*STATES(:,7); ALGEBRAIC(:,15) = CONSTANTS(:,1).*CONSTANTS(:,10).*(STATES(:,1) - CONSTANTS(:,9)).*STATES(:,3).*STATES(:,4).*STATES(:,5); ALGEBRAIC(:,48) = CONSTANTS(:,1).*0.383300.*CONSTANTS(:,19).*(STATES(:,1) - CONSTANTS(:,76)).*power(STATES(:,14), 2.00000); ALGEBRAIC(:,49) = CONSTANTS(:,1).*0.616700.*CONSTANTS(:,19).*(STATES(:,1) - CONSTANTS(:,77)).*power(STATES(:,14), 2.00000); ALGEBRAIC(:,50) = ALGEBRAIC(:,48)+ALGEBRAIC(:,49); ALGEBRAIC(:,51) = CONSTANTS(:,1).*CONSTANTS(:,21).*(STATES(:,1) - CONSTANTS(:,22)).*STATES(:,15).*STATES(:,16); ALGEBRAIC(:,38) = CONSTANTS(:,1).*CONSTANTS(:,15).*(STATES(:,1) - CONSTANTS(:,77)).*( 0.600000.*STATES(:,9)+ 0.400000.*STATES(:,8)).*STATES(:,10); ALGEBRAIC(:,43) = CONSTANTS(:,1).*CONSTANTS(:,16).*(STATES(:,1) - CONSTANTS(:,78)).*power(STATES(:,11), 2.00000); ALGEBRAIC(:,45) = CONSTANTS(:,1).*CONSTANTS(:,17).*(STATES(:,1) - CONSTANTS(:,77)).*STATES(:,12).*STATES(:,13); ALGEBRAIC(:,47) = CONSTANTS(:,1).*CONSTANTS(:,18).*(STATES(:,1) - CONSTANTS(:,77)).*STATES(:,13); ALGEBRAIC(:,53) = ( CONSTANTS(:,1).*CONSTANTS(:,26))./( (1.00000+power(CONSTANTS(:,24)./CONSTANTS(:,8), 1.20000)).*(1.00000+power(CONSTANTS(:,25)./CONSTANTS(:,5), 1.30000)).*(1.00000+exp( - ((STATES(:,1) - CONSTANTS(:,76))+120.000)./30.0000))); ALGEBRAIC(:,55) = exp(( - CONSTANTS(:,30).*STATES(:,1))./( 2.00000.*CONSTANTS(:,79))); ALGEBRAIC(:,61) = 1.00000+ (CONSTANTS(:,41)./CONSTANTS(:,40)).*(1.00000+exp(( CONSTANTS(:,31).*STATES(:,1))./CONSTANTS(:,79)))+ (CONSTANTS(:,6)./CONSTANTS(:,38)).*(1.00000+ (CONSTANTS(:,6)./CONSTANTS(:,39)).*(1.00000+CONSTANTS(:,6)./CONSTANTS(:,37))); ALGEBRAIC(:,63) = ( (( (CONSTANTS(:,6)./CONSTANTS(:,38)).*CONSTANTS(:,6))./CONSTANTS(:,39)).*(1.00000+CONSTANTS(:,6)./CONSTANTS(:,37)).*exp(( - CONSTANTS(:,30).*STATES(:,1))./( 2.00000.*CONSTANTS(:,79))))./ALGEBRAIC(:,61); ALGEBRAIC(:,62) = ( (CONSTANTS(:,41)./CONSTANTS(:,40)).*exp(( CONSTANTS(:,31).*STATES(:,1))./CONSTANTS(:,79)))./ALGEBRAIC(:,61); ALGEBRAIC(:,59) = exp(( CONSTANTS(:,30).*STATES(:,1))./( 2.00000.*CONSTANTS(:,79))); ALGEBRAIC(:,64) = ALGEBRAIC(:,55).*CONSTANTS(:,81).*(ALGEBRAIC(:,63)+ALGEBRAIC(:,62))+ ALGEBRAIC(:,62).*ALGEBRAIC(:,59).*(CONSTANTS(:,80)+ALGEBRAIC(:,55)); ALGEBRAIC(:,56) = 1.00000+ (STATES(:,2)./CONSTANTS(:,33)).*(1.00000+exp(( - CONSTANTS(:,29).*STATES(:,1))./CONSTANTS(:,79))+CONSTANTS(:,5)./CONSTANTS(:,36))+ (CONSTANTS(:,5)./CONSTANTS(:,34)).*(1.00000+ (CONSTANTS(:,5)./CONSTANTS(:,35)).*(1.00000+CONSTANTS(:,5)./CONSTANTS(:,32))); ALGEBRAIC(:,57) = ( (STATES(:,2)./CONSTANTS(:,33)).*exp(( - CONSTANTS(:,29).*STATES(:,1))./CONSTANTS(:,79)))./ALGEBRAIC(:,56); ALGEBRAIC(:,58) = ( (( (CONSTANTS(:,5)./CONSTANTS(:,34)).*CONSTANTS(:,5))./CONSTANTS(:,35)).*(1.00000+CONSTANTS(:,5)./CONSTANTS(:,32)).*exp(( CONSTANTS(:,30).*STATES(:,1))./( 2.00000.*CONSTANTS(:,79))))./ALGEBRAIC(:,56); ALGEBRAIC(:,60) = ALGEBRAIC(:,59).*CONSTANTS(:,80).*(ALGEBRAIC(:,58)+ALGEBRAIC(:,57))+ ALGEBRAIC(:,55).*ALGEBRAIC(:,57).*(CONSTANTS(:,81)+ALGEBRAIC(:,59)); ALGEBRAIC(:,65) = ALGEBRAIC(:,58).*CONSTANTS(:,80).*(ALGEBRAIC(:,63)+ALGEBRAIC(:,62))+ ALGEBRAIC(:,57).*ALGEBRAIC(:,63).*(CONSTANTS(:,80)+ALGEBRAIC(:,55)); ALGEBRAIC(:,66) = ALGEBRAIC(:,63).*CONSTANTS(:,81).*(ALGEBRAIC(:,58)+ALGEBRAIC(:,57))+ ALGEBRAIC(:,58).*ALGEBRAIC(:,62).*(CONSTANTS(:,81)+ALGEBRAIC(:,59)); ALGEBRAIC(:,67) = ( CONSTANTS(:,1).*CONSTANTS(:,28).*( ALGEBRAIC(:,60).*ALGEBRAIC(:,62) - ALGEBRAIC(:,64).*ALGEBRAIC(:,57)))./(ALGEBRAIC(:,64)+ALGEBRAIC(:,60)+ALGEBRAIC(:,65)+ALGEBRAIC(:,66)); ALGEBRAIC(:,54) = CONSTANTS(:,1).*CONSTANTS(:,27).*(STATES(:,1) - CONSTANTS(:,9)); ALGEBRAIC(:,52) = CONSTANTS(:,1).*CONSTANTS(:,23).*(STATES(:,1) - CONSTANTS(:,76)); RATES(:,1) = - (ALGEBRAIC(:,15)+ALGEBRAIC(:,32)+ALGEBRAIC(:,50)+ALGEBRAIC(:,51)+ALGEBRAIC(:,38)+ALGEBRAIC(:,43)+ALGEBRAIC(:,45)+ALGEBRAIC(:,47)+ALGEBRAIC(:,53)+ALGEBRAIC(:,67)+ALGEBRAIC(:,54)+ALGEBRAIC(:,52))./CONSTANTS(:,1); ALGEBRAIC(:,70) = CONSTANTS(:,62).*STATES(:,2).*(1.00000 - STATES(:,26)) - CONSTANTS(:,67).*STATES(:,26); RATES(:,26) = ALGEBRAIC(:,70); ALGEBRAIC(:,68) = CONSTANTS(:,42).*STATES(:,18).*(STATES(:,21) - STATES(:,2)); ALGEBRAIC(:,69) = (STATES(:,2) - STATES(:,23))./CONSTANTS(:,51); RATES(:,2) = ( ALGEBRAIC(:,68).*CONSTANTS(:,84))./CONSTANTS(:,83) - (((ALGEBRAIC(:,15)+ALGEBRAIC(:,32)+ALGEBRAIC(:,54)) - 2.00000.*ALGEBRAIC(:,67))./( 2.00000.*CONSTANTS(:,4).*CONSTANTS(:,83))+ALGEBRAIC(:,69)+ CONSTANTS(:,57).*ALGEBRAIC(:,70)); ALGEBRAIC(:,72) = CONSTANTS(:,59).*STATES(:,23).*(1.00000 - STATES(:,27)) - CONSTANTS(:,64).*STATES(:,27); RATES(:,27) = ALGEBRAIC(:,72); ALGEBRAIC(:,71) = CONSTANTS(:,53)./(1.00000+CONSTANTS(:,54)./STATES(:,23)); ALGEBRAIC(:,73) = (STATES(:,22) - STATES(:,21))./CONSTANTS(:,52); RATES(:,22) = ALGEBRAIC(:,71) - ( ALGEBRAIC(:,73).*CONSTANTS(:,84))./CONSTANTS(:,86); ALGEBRAIC(:,74) = CONSTANTS(:,61).*STATES(:,23).*(1.00000 - (STATES(:,28)+STATES(:,24))) - CONSTANTS(:,65).*STATES(:,28); RATES(:,28) = ALGEBRAIC(:,74); ALGEBRAIC(:,75) = CONSTANTS(:,63).*STATES(:,21).*(1.00000 - STATES(:,29)) - CONSTANTS(:,68).*STATES(:,29); RATES(:,29) = ALGEBRAIC(:,75); RATES(:,21) = ALGEBRAIC(:,73) - (ALGEBRAIC(:,68)+ CONSTANTS(:,58).*ALGEBRAIC(:,75)); ALGEBRAIC(:,76) = CONSTANTS(:,62).*STATES(:,23).*(1.00000 - STATES(:,25)) - CONSTANTS(:,67).*STATES(:,25); RATES(:,25) = ALGEBRAIC(:,76); RATES(:,23) = ( ALGEBRAIC(:,69).*CONSTANTS(:,83) - ALGEBRAIC(:,71).*CONSTANTS(:,86))./CONSTANTS(:,85) - ( CONSTANTS(:,57).*ALGEBRAIC(:,76)+ CONSTANTS(:,55).*ALGEBRAIC(:,72)+ CONSTANTS(:,56).*ALGEBRAIC(:,74)); 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) = CONSTANTS(:,60).*CONSTANTS(:,69).*(1.00000 - (STATES(:,28)+STATES(:,24))) - CONSTANTS(:,66).*STATES(:,24); ALGEBRAIC(:,2) = 1.00000./(1.00000+exp((STATES(:,1)+35.0000)./7.30000)); ALGEBRAIC(:,18) = 44.3000+ 257.100.*exp( - power((STATES(:,1)+32.5000)./13.9000, 2.00000)); ALGEBRAIC(:,3) = CONSTANTS(:,12)./(CONSTANTS(:,12)+STATES(:,2)); ALGEBRAIC(:,19) = ALGEBRAIC(:,3)./CONSTANTS(:,11); ALGEBRAIC(:,4) = 1.00000./(1.00000+exp( - (STATES(:,1)+26.3000)./6.00000)); ALGEBRAIC(:,20) = 1.00000./( 1.06800.*exp((STATES(:,1)+26.3000)./30.0000)+ 1.06800.*exp( - (STATES(:,1)+26.3000)./30.0000)); ALGEBRAIC(:,5) = 1.00000./(1.00000+exp((STATES(:,1)+61.7000)./5.60000)); ALGEBRAIC(:,21) = 1.00000./( 0.0153000.*exp( - (STATES(:,1)+61.7000)./83.3000)+ 0.0150000.*exp((STATES(:,1)+61.7000)./15.3800)); ALGEBRAIC(:,6) = 1.00000./(1.00000+exp( - (STATES(:,1)+23.2000)./10.6000)); ALGEBRAIC(:,22) = 0.846554./( 0.00420000.*exp(STATES(:,1)./17.0000)+ 0.000150000.*exp( - STATES(:,1)./21.6000)); ALGEBRAIC(:,23) = 0.846554./( 0.0372000.*exp(STATES(:,1)./15.9000)+ 0.000960000.*exp( - STATES(:,1)./22.5000)); ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,1)+28.6000)./17.1000)); ALGEBRAIC(:,24) = 1.00000./( 0.100000.*exp( - STATES(:,1)./54.6450)+ 0.656000.*exp(STATES(:,1)./106.157)); ALGEBRAIC(:,9) = 1.00000./(1.00000+exp((STATES(:,1)+49.0000)./13.0000)); ALGEBRAIC(:,26) = 6.06000+39.1020./( 0.570000.*exp( - 0.0800000.*(STATES(:,1)+44.0000))+ 0.0650000.*exp( 0.100000.*(STATES(:,1)+45.9300))); ALGEBRAIC(:,10) = 1.00000./(1.00000+exp( - (STATES(:,1) - 19.3000)./15.0000)); ALGEBRAIC(:,27) = 2.75352+14.4052./( 1.03700.*exp( 0.0900000.*(STATES(:,1)+30.6100))+ 0.369000.*exp( - 0.120000.*(STATES(:,1)+23.8400))); ALGEBRAIC(:,11) = 1.00000./(1.00000+exp((STATES(:,1) - CONSTANTS(:,20))./13.5000)); ALGEBRAIC(:,28) = 0.716653./(exp( - (STATES(:,1)+386.900)./45.3020)+exp((STATES(:,1) - 73.0800)./19.2310)); ALGEBRAIC(:,14) = CONSTANTS(:,43) - (CONSTANTS(:,43) - CONSTANTS(:,44))./(1.00000+power(CONSTANTS(:,45)./STATES(:,21), CONSTANTS(:,46))); ALGEBRAIC(:,31) = CONSTANTS(:,47)./ALGEBRAIC(:,14); ALGEBRAIC(:,37) = CONSTANTS(:,48).*ALGEBRAIC(:,14); ALGEBRAIC(:,8) = 0.0140000./(1.00000+exp( - (STATES(:,1) - 40.0000)./9.00000)); ALGEBRAIC(:,25) = 0.00100000.*exp( - STATES(:,1)./45.0000); ALGEBRAIC(:,34) = ALGEBRAIC(:,8)./(ALGEBRAIC(:,8)+ALGEBRAIC(:,25)); ALGEBRAIC(:,40) = 1.00000./(ALGEBRAIC(:,8)+ALGEBRAIC(:,25)); ALGEBRAIC(:,12) = 1.00000./(1.00000+exp( - (STATES(:,1)+57.0000)./5.00000)); ALGEBRAIC(:,29) = 1.00000./( 0.150000.*exp( - STATES(:,1)./11.0000)+ 0.200000.*exp( - STATES(:,1)./700.000)); ALGEBRAIC(:,35) = 1.00000./( 16.0000.*exp(STATES(:,1)./8.00000)+ 15.0000.*exp(STATES(:,1)./50.0000)); ALGEBRAIC(:,41) = 1.00000./(ALGEBRAIC(:,29)+ALGEBRAIC(:,35)); ALGEBRAIC(:,13) = 1.00000./( 3100.00.*exp(STATES(:,1)./13.0000)+ 700.000.*exp(STATES(:,1)./70.0000)); ALGEBRAIC(:,30) = 1.00000./( 95.0000.*exp( - STATES(:,1)./10.0000)+ 50.0000.*exp( - STATES(:,1)./700.000))+0.000229000./(1.00000+exp( - STATES(:,1)./5.00000)); ALGEBRAIC(:,36) = ALGEBRAIC(:,13)./(ALGEBRAIC(:,13)+ALGEBRAIC(:,30)); ALGEBRAIC(:,42) = 6.65000./(ALGEBRAIC(:,13)+ALGEBRAIC(:,30)); ALGEBRAIC(:,1) = 1.00000./(1.00000+exp( - (STATES(:,1)+13.5000)./6.00000)); ALGEBRAIC(:,17) = piecewise({STATES(:,1)== - 35.0000, - 35.0000 , STATES(:,1)==0.00000, 1.00000e-05 }, STATES(:,1)); ALGEBRAIC(:,33) = ( - 0.0283900.*(ALGEBRAIC(:,17)+35.0000))./(exp( - (ALGEBRAIC(:,17)+35.0000)./2.50000) - 1.00000) - ( 0.0849000.*ALGEBRAIC(:,17))./(exp( - ALGEBRAIC(:,17)./4.80000) - 1.00000); ALGEBRAIC(:,39) = piecewise({STATES(:,1)==5.00000, 5.00001 }, STATES(:,1)); ALGEBRAIC(:,44) = ( 0.0114300.*(ALGEBRAIC(:,39) - 5.00000))./(exp((ALGEBRAIC(:,39) - 5.00000)./2.50000) - 1.00000); ALGEBRAIC(:,46) = 1.00000./(ALGEBRAIC(:,33)+ALGEBRAIC(:,44)); ALGEBRAIC(:,32) = CONSTANTS(:,1).*CONSTANTS(:,13).*(STATES(:,1) - CONSTANTS(:,14)).*STATES(:,6).*STATES(:,7); ALGEBRAIC(:,15) = CONSTANTS(:,1).*CONSTANTS(:,10).*(STATES(:,1) - CONSTANTS(:,9)).*STATES(:,3).*STATES(:,4).*STATES(:,5); ALGEBRAIC(:,48) = CONSTANTS(:,1).*0.383300.*CONSTANTS(:,19).*(STATES(:,1) - CONSTANTS(:,76)).*power(STATES(:,14), 2.00000); ALGEBRAIC(:,49) = CONSTANTS(:,1).*0.616700.*CONSTANTS(:,19).*(STATES(:,1) - CONSTANTS(:,77)).*power(STATES(:,14), 2.00000); ALGEBRAIC(:,50) = ALGEBRAIC(:,48)+ALGEBRAIC(:,49); ALGEBRAIC(:,51) = CONSTANTS(:,1).*CONSTANTS(:,21).*(STATES(:,1) - CONSTANTS(:,22)).*STATES(:,15).*STATES(:,16); ALGEBRAIC(:,38) = CONSTANTS(:,1).*CONSTANTS(:,15).*(STATES(:,1) - CONSTANTS(:,77)).*( 0.600000.*STATES(:,9)+ 0.400000.*STATES(:,8)).*STATES(:,10); ALGEBRAIC(:,43) = CONSTANTS(:,1).*CONSTANTS(:,16).*(STATES(:,1) - CONSTANTS(:,78)).*power(STATES(:,11), 2.00000); ALGEBRAIC(:,45) = CONSTANTS(:,1).*CONSTANTS(:,17).*(STATES(:,1) - CONSTANTS(:,77)).*STATES(:,12).*STATES(:,13); ALGEBRAIC(:,47) = CONSTANTS(:,1).*CONSTANTS(:,18).*(STATES(:,1) - CONSTANTS(:,77)).*STATES(:,13); ALGEBRAIC(:,53) = ( CONSTANTS(:,1).*CONSTANTS(:,26))./( (1.00000+power(CONSTANTS(:,24)./CONSTANTS(:,8), 1.20000)).*(1.00000+power(CONSTANTS(:,25)./CONSTANTS(:,5), 1.30000)).*(1.00000+exp( - ((STATES(:,1) - CONSTANTS(:,76))+120.000)./30.0000))); ALGEBRAIC(:,55) = exp(( - CONSTANTS(:,30).*STATES(:,1))./( 2.00000.*CONSTANTS(:,79))); ALGEBRAIC(:,61) = 1.00000+ (CONSTANTS(:,41)./CONSTANTS(:,40)).*(1.00000+exp(( CONSTANTS(:,31).*STATES(:,1))./CONSTANTS(:,79)))+ (CONSTANTS(:,6)./CONSTANTS(:,38)).*(1.00000+ (CONSTANTS(:,6)./CONSTANTS(:,39)).*(1.00000+CONSTANTS(:,6)./CONSTANTS(:,37))); ALGEBRAIC(:,63) = ( (( (CONSTANTS(:,6)./CONSTANTS(:,38)).*CONSTANTS(:,6))./CONSTANTS(:,39)).*(1.00000+CONSTANTS(:,6)./CONSTANTS(:,37)).*exp(( - CONSTANTS(:,30).*STATES(:,1))./( 2.00000.*CONSTANTS(:,79))))./ALGEBRAIC(:,61); ALGEBRAIC(:,62) = ( (CONSTANTS(:,41)./CONSTANTS(:,40)).*exp(( CONSTANTS(:,31).*STATES(:,1))./CONSTANTS(:,79)))./ALGEBRAIC(:,61); ALGEBRAIC(:,59) = exp(( CONSTANTS(:,30).*STATES(:,1))./( 2.00000.*CONSTANTS(:,79))); ALGEBRAIC(:,64) = ALGEBRAIC(:,55).*CONSTANTS(:,81).*(ALGEBRAIC(:,63)+ALGEBRAIC(:,62))+ ALGEBRAIC(:,62).*ALGEBRAIC(:,59).*(CONSTANTS(:,80)+ALGEBRAIC(:,55)); ALGEBRAIC(:,56) = 1.00000+ (STATES(:,2)./CONSTANTS(:,33)).*(1.00000+exp(( - CONSTANTS(:,29).*STATES(:,1))./CONSTANTS(:,79))+CONSTANTS(:,5)./CONSTANTS(:,36))+ (CONSTANTS(:,5)./CONSTANTS(:,34)).*(1.00000+ (CONSTANTS(:,5)./CONSTANTS(:,35)).*(1.00000+CONSTANTS(:,5)./CONSTANTS(:,32))); ALGEBRAIC(:,57) = ( (STATES(:,2)./CONSTANTS(:,33)).*exp(( - CONSTANTS(:,29).*STATES(:,1))./CONSTANTS(:,79)))./ALGEBRAIC(:,56); ALGEBRAIC(:,58) = ( (( (CONSTANTS(:,5)./CONSTANTS(:,34)).*CONSTANTS(:,5))./CONSTANTS(:,35)).*(1.00000+CONSTANTS(:,5)./CONSTANTS(:,32)).*exp(( CONSTANTS(:,30).*STATES(:,1))./( 2.00000.*CONSTANTS(:,79))))./ALGEBRAIC(:,56); ALGEBRAIC(:,60) = ALGEBRAIC(:,59).*CONSTANTS(:,80).*(ALGEBRAIC(:,58)+ALGEBRAIC(:,57))+ ALGEBRAIC(:,55).*ALGEBRAIC(:,57).*(CONSTANTS(:,81)+ALGEBRAIC(:,59)); ALGEBRAIC(:,65) = ALGEBRAIC(:,58).*CONSTANTS(:,80).*(ALGEBRAIC(:,63)+ALGEBRAIC(:,62))+ ALGEBRAIC(:,57).*ALGEBRAIC(:,63).*(CONSTANTS(:,80)+ALGEBRAIC(:,55)); ALGEBRAIC(:,66) = ALGEBRAIC(:,63).*CONSTANTS(:,81).*(ALGEBRAIC(:,58)+ALGEBRAIC(:,57))+ ALGEBRAIC(:,58).*ALGEBRAIC(:,62).*(CONSTANTS(:,81)+ALGEBRAIC(:,59)); ALGEBRAIC(:,67) = ( CONSTANTS(:,1).*CONSTANTS(:,28).*( ALGEBRAIC(:,60).*ALGEBRAIC(:,62) - ALGEBRAIC(:,64).*ALGEBRAIC(:,57)))./(ALGEBRAIC(:,64)+ALGEBRAIC(:,60)+ALGEBRAIC(:,65)+ALGEBRAIC(:,66)); ALGEBRAIC(:,54) = CONSTANTS(:,1).*CONSTANTS(:,27).*(STATES(:,1) - CONSTANTS(:,9)); ALGEBRAIC(:,52) = CONSTANTS(:,1).*CONSTANTS(:,23).*(STATES(:,1) - CONSTANTS(:,76)); ALGEBRAIC(:,70) = CONSTANTS(:,62).*STATES(:,2).*(1.00000 - STATES(:,26)) - CONSTANTS(:,67).*STATES(:,26); ALGEBRAIC(:,68) = CONSTANTS(:,42).*STATES(:,18).*(STATES(:,21) - STATES(:,2)); ALGEBRAIC(:,69) = (STATES(:,2) - STATES(:,23))./CONSTANTS(:,51); ALGEBRAIC(:,72) = CONSTANTS(:,59).*STATES(:,23).*(1.00000 - STATES(:,27)) - CONSTANTS(:,64).*STATES(:,27); ALGEBRAIC(:,71) = CONSTANTS(:,53)./(1.00000+CONSTANTS(:,54)./STATES(:,23)); ALGEBRAIC(:,73) = (STATES(:,22) - STATES(:,21))./CONSTANTS(:,52); ALGEBRAIC(:,74) = CONSTANTS(:,61).*STATES(:,23).*(1.00000 - (STATES(:,28)+STATES(:,24))) - CONSTANTS(:,65).*STATES(:,28); ALGEBRAIC(:,75) = CONSTANTS(:,63).*STATES(:,21).*(1.00000 - STATES(:,29)) - CONSTANTS(:,68).*STATES(:,29); ALGEBRAIC(:,76) = CONSTANTS(:,62).*STATES(:,23).*(1.00000 - STATES(:,25)) - CONSTANTS(:,67).*STATES(:,25); 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