# 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 =75;
end
% There are a total of 27 entries in each of the rate and state variable arrays.
% There are a total of 66 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('V in component membrane (millivolt)');
LEGEND_CONSTANTS(:,1) = strpad('R in component membrane (attojoule_per_millimole_kelvin)');
LEGEND_CONSTANTS(:,2) = strpad('T in component membrane (kelvin)');
LEGEND_CONSTANTS(:,3) = strpad('F in component membrane (femtocoulomb_per_millimole)');
LEGEND_CONSTANTS(:,4) = strpad('Cm in component membrane (picoF)');
LEGEND_ALGEBRAIC(:,40) = strpad('i_CaT in component T_type_calcium_channel_current (picoA)');
LEGEND_ALGEBRAIC(:,35) = strpad('i_CaL in component L_type_calcium_channel_current (picoA)');
LEGEND_ALGEBRAIC(:,41) = strpad('i_Kr in component rapidly_activating_delayed_rectifier_potassium_current (picoA)');
LEGEND_ALGEBRAIC(:,43) = strpad('i_Ks in component slowly_activating_delayed_rectifier_potassium_current (picoA)');
LEGEND_ALGEBRAIC(:,44) = strpad('i_to in component AP_sensitive_currents (picoA)');
LEGEND_ALGEBRAIC(:,45) = strpad('i_sus in component AP_sensitive_currents (picoA)');
LEGEND_ALGEBRAIC(:,48) = strpad('i_h in component hyperpolarisation_activated_current (picoA)');
LEGEND_ALGEBRAIC(:,49) = strpad('i_st in component sustained_inward_current (picoA)');
LEGEND_ALGEBRAIC(:,50) = strpad('i_b_Na in component sodium_dependent_background_current (picoA)');
LEGEND_ALGEBRAIC(:,66) = strpad('i_NaCa in component sodium_calcium_exchange_current (picoA)');
LEGEND_ALGEBRAIC(:,52) = strpad('i_NaK in component sodium_potassium_pump_current (picoA)');
LEGEND_ALGEBRAIC(:,51) = strpad('i_K_ACh in component background_muscarinic_potassium_channel_current (picoA)');
LEGEND_ALGEBRAIC(:,1) = strpad('E_Na in component reversal_potentials (millivolt)');
LEGEND_ALGEBRAIC(:,30) = strpad('E_K in component reversal_potentials (millivolt)');
LEGEND_STATES(:,2) = strpad('Nai in component intracellular_ion_concentrations (millimolar)');
LEGEND_CONSTANTS(:,5) = strpad('Nao in component intracellular_ion_concentrations (millimolar)');
LEGEND_STATES(:,3) = strpad('Ki in component intracellular_ion_concentrations (millimolar)');
LEGEND_CONSTANTS(:,6) = strpad('Ko in component intracellular_ion_concentrations (millimolar)');
LEGEND_CONSTANTS(:,7) = strpad('g_CaL in component L_type_calcium_channel_current (nanoS)');
LEGEND_CONSTANTS(:,8) = strpad('E_CaL in component L_type_calcium_channel_current (millivolt)');
LEGEND_STATES(:,4) = strpad('Ca_sub in component intracellular_ion_concentrations (millimolar)');
LEGEND_STATES(:,5) = strpad('d in component L_type_calcium_channel_current_d_gate (dimensionless)');
LEGEND_STATES(:,6) = strpad('f in component L_type_calcium_channel_current_f_gate (dimensionless)');
LEGEND_STATES(:,7) = strpad('fCa in component L_type_calcium_channel_current_fCa_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,2) = strpad('d_infinity in component L_type_calcium_channel_current_d_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,36) = strpad('tau_d in component L_type_calcium_channel_current_d_gate (millisecond)');
LEGEND_ALGEBRAIC(:,16) = strpad('alpha_d in component L_type_calcium_channel_current_d_gate (per_millisecond)');
LEGEND_ALGEBRAIC(:,31) = strpad('beta_d in component L_type_calcium_channel_current_d_gate (per_millisecond)');
LEGEND_ALGEBRAIC(:,3) = strpad('f_infinity in component L_type_calcium_channel_current_f_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,17) = strpad('tau_f in component L_type_calcium_channel_current_f_gate (millisecond)');
LEGEND_CONSTANTS(:,63) = strpad('alpha_fCa in component L_type_calcium_channel_current_fCa_gate (per_millisecond)');
LEGEND_CONSTANTS(:,9) = strpad('beta_fCa in component L_type_calcium_channel_current_fCa_gate (per_millimolar_millisecond)');
LEGEND_ALGEBRAIC(:,4) = strpad('fCa_infinity in component L_type_calcium_channel_current_fCa_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,18) = strpad('tau_fCa in component L_type_calcium_channel_current_fCa_gate (millisecond)');
LEGEND_CONSTANTS(:,10) = strpad('Km_fCa in component L_type_calcium_channel_current_fCa_gate (millimolar)');
LEGEND_CONSTANTS(:,11) = strpad('g_CaT in component T_type_calcium_channel_current (nanoS)');
LEGEND_CONSTANTS(:,12) = strpad('E_CaT in component T_type_calcium_channel_current (millivolt)');
LEGEND_STATES(:,8) = strpad('d in component T_type_calcium_channel_current_d_gate (dimensionless)');
LEGEND_STATES(:,9) = strpad('f in component T_type_calcium_channel_current_f_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,5) = strpad('d_infinity in component T_type_calcium_channel_current_d_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,19) = strpad('tau_d in component T_type_calcium_channel_current_d_gate (millisecond)');
LEGEND_ALGEBRAIC(:,6) = strpad('f_infinity in component T_type_calcium_channel_current_f_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,20) = strpad('tau_f in component T_type_calcium_channel_current_f_gate (millisecond)');
LEGEND_CONSTANTS(:,64) = strpad('g_Kr in component rapidly_activating_delayed_rectifier_potassium_current (nanoS)');
LEGEND_STATES(:,10) = strpad('paS in component rapidly_activating_delayed_rectifier_potassium_current_pa_gate (dimensionless)');
LEGEND_STATES(:,11) = strpad('paF in component rapidly_activating_delayed_rectifier_potassium_current_pa_gate (dimensionless)');
LEGEND_STATES(:,12) = strpad('piy in component rapidly_activating_delayed_rectifier_potassium_current_pi_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,7) = strpad('pa_infinity in component rapidly_activating_delayed_rectifier_potassium_current_pa_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,21) = strpad('tau_paS in component rapidly_activating_delayed_rectifier_potassium_current_pa_gate (millisecond)');
LEGEND_ALGEBRAIC(:,22) = strpad('tau_paF in component rapidly_activating_delayed_rectifier_potassium_current_pa_gate (millisecond)');
LEGEND_ALGEBRAIC(:,8) = strpad('pi_infinity in component rapidly_activating_delayed_rectifier_potassium_current_pi_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,23) = strpad('tau_pi in component rapidly_activating_delayed_rectifier_potassium_current_pi_gate (millisecond)');
LEGEND_CONSTANTS(:,13) = strpad('g_Ks in component slowly_activating_delayed_rectifier_potassium_current (nanoS)');
LEGEND_ALGEBRAIC(:,42) = strpad('E_Ks in component slowly_activating_delayed_rectifier_potassium_current (millivolt)');
LEGEND_STATES(:,13) = strpad('n in component slowly_activating_delayed_rectifier_potassium_current_n_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,32) = strpad('n_infinity in component slowly_activating_delayed_rectifier_potassium_current_n_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,37) = strpad('tau_n in component slowly_activating_delayed_rectifier_potassium_current_n_gate (millisecond)');
LEGEND_ALGEBRAIC(:,9) = strpad('alpha_n in component slowly_activating_delayed_rectifier_potassium_current_n_gate (per_millisecond)');
LEGEND_ALGEBRAIC(:,24) = strpad('beta_n in component slowly_activating_delayed_rectifier_potassium_current_n_gate (per_millisecond)');
LEGEND_CONSTANTS(:,14) = strpad('g_to in component AP_sensitive_currents (nanoS)');
LEGEND_CONSTANTS(:,15) = strpad('g_sus in component AP_sensitive_currents (nanoS)');
LEGEND_STATES(:,14) = strpad('q in component AP_sensitive_currents_q_gate (dimensionless)');
LEGEND_STATES(:,15) = strpad('r in component AP_sensitive_currents_r_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,10) = strpad('q_infinity in component AP_sensitive_currents_q_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,25) = strpad('tau_q in component AP_sensitive_currents_q_gate (millisecond)');
LEGEND_ALGEBRAIC(:,11) = strpad('r_infinity in component AP_sensitive_currents_r_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,26) = strpad('tau_r in component AP_sensitive_currents_r_gate (millisecond)');
LEGEND_ALGEBRAIC(:,46) = strpad('i_h_Na in component hyperpolarisation_activated_current (picoA)');
LEGEND_ALGEBRAIC(:,47) = strpad('i_h_K in component hyperpolarisation_activated_current (picoA)');
LEGEND_CONSTANTS(:,16) = strpad('g_h_Na in component hyperpolarisation_activated_current (nanoS)');
LEGEND_CONSTANTS(:,17) = strpad('g_h_K in component hyperpolarisation_activated_current (nanoS)');
LEGEND_STATES(:,16) = strpad('y in component hyperpolarisation_activated_current_y_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,12) = strpad('y_infinity in component hyperpolarisation_activated_current_y_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,27) = strpad('tau_y in component hyperpolarisation_activated_current_y_gate (millisecond)');
LEGEND_CONSTANTS(:,18) = strpad('g_st in component sustained_inward_current (nanoS)');
LEGEND_CONSTANTS(:,19) = strpad('E_st in component sustained_inward_current (millivolt)');
LEGEND_STATES(:,17) = strpad('qa in component sustained_inward_current_qa_gate (dimensionless)');
LEGEND_STATES(:,18) = strpad('qi in component sustained_inward_current_qi_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,13) = strpad('qa_infinity in component sustained_inward_current_qa_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,38) = strpad('tau_qa in component sustained_inward_current_qa_gate (millisecond)');
LEGEND_ALGEBRAIC(:,28) = strpad('alpha_qa in component sustained_inward_current_qa_gate (per_millisecond)');
LEGEND_ALGEBRAIC(:,33) = strpad('beta_qa in component sustained_inward_current_qa_gate (per_millisecond)');
LEGEND_ALGEBRAIC(:,34) = strpad('qi_infinity in component sustained_inward_current_qi_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,39) = strpad('tau_qi in component sustained_inward_current_qi_gate (millisecond)');
LEGEND_ALGEBRAIC(:,14) = strpad('alpha_qi in component sustained_inward_current_qi_gate (per_millisecond)');
LEGEND_ALGEBRAIC(:,29) = strpad('beta_qi in component sustained_inward_current_qi_gate (per_millisecond)');
LEGEND_CONSTANTS(:,20) = strpad('g_b_Na in component sodium_dependent_background_current (nanoS)');
LEGEND_CONSTANTS(:,65) = strpad('g_K_ACh in component background_muscarinic_potassium_channel_current (picoA)');
LEGEND_CONSTANTS(:,21) = strpad('Km_Kp in component sodium_potassium_pump_current (millimolar)');
LEGEND_CONSTANTS(:,22) = strpad('Km_Nap in component sodium_potassium_pump_current (millimolar)');
LEGEND_CONSTANTS(:,23) = strpad('i_NaK_max in component sodium_potassium_pump_current (picoA)');
LEGEND_CONSTANTS(:,24) = strpad('kNaCa in component sodium_calcium_exchange_current (picoA)');
LEGEND_ALGEBRAIC(:,63) = strpad('x1 in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_ALGEBRAIC(:,59) = strpad('x2 in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_ALGEBRAIC(:,64) = strpad('x3 in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_ALGEBRAIC(:,65) = strpad('x4 in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_ALGEBRAIC(:,54) = strpad('k41 in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_CONSTANTS(:,66) = strpad('k34 in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_ALGEBRAIC(:,62) = strpad('k23 in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_ALGEBRAIC(:,61) = strpad('k21 in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_ALGEBRAIC(:,58) = strpad('k32 in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_ALGEBRAIC(:,53) = strpad('k43 in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_ALGEBRAIC(:,56) = strpad('k12 in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_ALGEBRAIC(:,57) = strpad('k14 in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_CONSTANTS(:,25) = strpad('Qci in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_CONSTANTS(:,26) = strpad('Qn in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_CONSTANTS(:,27) = strpad('Qco in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_CONSTANTS(:,28) = strpad('K3ni in component sodium_calcium_exchange_current (millimolar)');
LEGEND_CONSTANTS(:,29) = strpad('Kci in component sodium_calcium_exchange_current (millimolar)');
LEGEND_CONSTANTS(:,30) = strpad('K1ni in component sodium_calcium_exchange_current (millimolar)');
LEGEND_CONSTANTS(:,31) = strpad('K2ni in component sodium_calcium_exchange_current (millimolar)');
LEGEND_CONSTANTS(:,32) = strpad('Kcni in component sodium_calcium_exchange_current (millimolar)');
LEGEND_CONSTANTS(:,33) = strpad('K3no in component sodium_calcium_exchange_current (millimolar)');
LEGEND_CONSTANTS(:,34) = strpad('K1no in component sodium_calcium_exchange_current (millimolar)');
LEGEND_CONSTANTS(:,35) = strpad('K2no in component sodium_calcium_exchange_current (millimolar)');
LEGEND_CONSTANTS(:,36) = strpad('Kco in component sodium_calcium_exchange_current (millimolar)');
LEGEND_ALGEBRAIC(:,60) = strpad('do in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_ALGEBRAIC(:,55) = strpad('di in component sodium_calcium_exchange_current (dimensionless)');
LEGEND_CONSTANTS(:,37) = strpad('Cao in component intracellular_ion_concentrations (millimolar)');
LEGEND_ALGEBRAIC(:,67) = strpad('j_Ca_dif in component intracellular_calcium_dynamics (millimolar_per_millisecond)');
LEGEND_ALGEBRAIC(:,68) = strpad('j_rel in component intracellular_calcium_dynamics (millimolar_per_millisecond)');
LEGEND_ALGEBRAIC(:,69) = strpad('j_up in component intracellular_calcium_dynamics (millimolar_per_millisecond)');
LEGEND_ALGEBRAIC(:,71) = strpad('j_tr in component intracellular_calcium_dynamics (millimolar_per_millisecond)');
LEGEND_CONSTANTS(:,38) = strpad('tau_dif_Ca in component intracellular_calcium_dynamics (millisecond)');
LEGEND_CONSTANTS(:,39) = strpad('tau_tr in component intracellular_calcium_dynamics (millisecond)');
LEGEND_CONSTANTS(:,40) = strpad('K_rel in component intracellular_calcium_dynamics (millimolar)');
LEGEND_CONSTANTS(:,41) = strpad('P_up in component intracellular_calcium_dynamics (millimolar_per_millisecond)');
LEGEND_CONSTANTS(:,42) = strpad('P_rel in component intracellular_calcium_dynamics (per_millisecond)');
LEGEND_CONSTANTS(:,43) = strpad('K_up in component intracellular_calcium_dynamics (millimolar)');
LEGEND_STATES(:,19) = strpad('Ca_up in component intracellular_ion_concentrations (millimolar)');
LEGEND_STATES(:,20) = strpad('Cai in component intracellular_ion_concentrations (millimolar)');
LEGEND_STATES(:,21) = strpad('Ca_rel in component intracellular_ion_concentrations (millimolar)');
LEGEND_CONSTANTS(:,44) = strpad('Mgi in component intracellular_ion_concentrations (millimolar)');
LEGEND_CONSTANTS(:,45) = strpad('V_i in component intracellular_ion_concentrations (litre)');
LEGEND_CONSTANTS(:,46) = strpad('V_rel in component intracellular_ion_concentrations (litre)');
LEGEND_CONSTANTS(:,47) = strpad('V_up in component intracellular_ion_concentrations (litre)');
LEGEND_CONSTANTS(:,48) = strpad('V_sub in component intracellular_ion_concentrations (litre)');
LEGEND_CONSTANTS(:,49) = strpad('TMC_tot in component calcium_buffering (dimensionless)');
LEGEND_CONSTANTS(:,50) = strpad('CM_tot in component calcium_buffering (dimensionless)');
LEGEND_CONSTANTS(:,51) = strpad('TC_tot in component calcium_buffering (dimensionless)');
LEGEND_CONSTANTS(:,52) = strpad('CQ_tot in component calcium_buffering (dimensionless)');
LEGEND_ALGEBRAIC(:,73) = strpad('delta_fTMC in component calcium_buffering (millimolar_per_millisecond)');
LEGEND_ALGEBRAIC(:,75) = strpad('delta_fCMi in component calcium_buffering (millimolar_per_millisecond)');
LEGEND_ALGEBRAIC(:,70) = strpad('delta_fCMs in component calcium_buffering (millimolar_per_millisecond)');
LEGEND_ALGEBRAIC(:,72) = strpad('delta_fTC in component calcium_buffering (millimolar_per_millisecond)');
LEGEND_ALGEBRAIC(:,74) = strpad('delta_fCQ in component calcium_buffering (millimolar_per_millisecond)');
LEGEND_ALGEBRAIC(:,15) = strpad('delta_fTMM in component calcium_buffering (millimolar_per_millisecond)');
LEGEND_STATES(:,22) = strpad('fTMM in component calcium_buffering (millimolar)');
LEGEND_STATES(:,23) = strpad('fCMi in component calcium_buffering (millimolar)');
LEGEND_STATES(:,24) = strpad('fCMs in component calcium_buffering (millimolar)');
LEGEND_STATES(:,25) = strpad('fTC in component calcium_buffering (millimolar)');
LEGEND_STATES(:,26) = strpad('fTMC in component calcium_buffering (millimolar)');
LEGEND_STATES(:,27) = strpad('fCQ in component calcium_buffering (millimolar)');
LEGEND_CONSTANTS(:,53) = strpad('kf_TC in component calcium_buffering (per_millimolar_millisecond)');
LEGEND_CONSTANTS(:,54) = strpad('kf_TMM in component calcium_buffering (per_millimolar_millisecond)');
LEGEND_CONSTANTS(:,55) = strpad('kf_TMC in component calcium_buffering (per_millimolar_millisecond)');
LEGEND_CONSTANTS(:,56) = strpad('kf_CM in component calcium_buffering (per_millimolar_millisecond)');
LEGEND_CONSTANTS(:,57) = strpad('kf_CQ in component calcium_buffering (per_millimolar_millisecond)');
LEGEND_CONSTANTS(:,58) = strpad('kb_TC in component calcium_buffering (per_millisecond)');
LEGEND_CONSTANTS(:,59) = strpad('kb_TMC in component calcium_buffering (per_millisecond)');
LEGEND_CONSTANTS(:,60) = strpad('kb_TMM in component calcium_buffering (per_millisecond)');
LEGEND_CONSTANTS(:,61) = strpad('kb_CM in component calcium_buffering (per_millisecond)');
LEGEND_CONSTANTS(:,62) = strpad('kb_CQ in component calcium_buffering (per_millisecond)');
LEGEND_RATES(:,1) = strpad('d/dt V in component membrane (millivolt)');
LEGEND_RATES(:,5) = strpad('d/dt d in component L_type_calcium_channel_current_d_gate (dimensionless)');
LEGEND_RATES(:,6) = strpad('d/dt f in component L_type_calcium_channel_current_f_gate (dimensionless)');
LEGEND_RATES(:,7) = strpad('d/dt fCa in component L_type_calcium_channel_current_fCa_gate (dimensionless)');
LEGEND_RATES(:,8) = strpad('d/dt d in component T_type_calcium_channel_current_d_gate (dimensionless)');
LEGEND_RATES(:,9) = strpad('d/dt f in component T_type_calcium_channel_current_f_gate (dimensionless)');
LEGEND_RATES(:,10) = strpad('d/dt paS in component rapidly_activating_delayed_rectifier_potassium_current_pa_gate (dimensionless)');
LEGEND_RATES(:,11) = strpad('d/dt paF in component rapidly_activating_delayed_rectifier_potassium_current_pa_gate (dimensionless)');
LEGEND_RATES(:,12) = strpad('d/dt piy in component rapidly_activating_delayed_rectifier_potassium_current_pi_gate (dimensionless)');
LEGEND_RATES(:,13) = strpad('d/dt n in component slowly_activating_delayed_rectifier_potassium_current_n_gate (dimensionless)');
LEGEND_RATES(:,14) = strpad('d/dt q in component AP_sensitive_currents_q_gate (dimensionless)');
LEGEND_RATES(:,15) = strpad('d/dt r in component AP_sensitive_currents_r_gate (dimensionless)');
LEGEND_RATES(:,16) = strpad('d/dt y in component hyperpolarisation_activated_current_y_gate (dimensionless)');
LEGEND_RATES(:,17) = strpad('d/dt qa in component sustained_inward_current_qa_gate (dimensionless)');
LEGEND_RATES(:,18) = strpad('d/dt qi in component sustained_inward_current_qi_gate (dimensionless)');
LEGEND_RATES(:,2) = strpad('d/dt Nai in component intracellular_ion_concentrations (millimolar)');
LEGEND_RATES(:,3) = strpad('d/dt Ki in component intracellular_ion_concentrations (millimolar)');
LEGEND_RATES(:,20) = strpad('d/dt Cai in component intracellular_ion_concentrations (millimolar)');
LEGEND_RATES(:,4) = strpad('d/dt Ca_sub in component intracellular_ion_concentrations (millimolar)');
LEGEND_RATES(:,19) = strpad('d/dt Ca_up in component intracellular_ion_concentrations (millimolar)');
LEGEND_RATES(:,21) = strpad('d/dt Ca_rel in component intracellular_ion_concentrations (millimolar)');
LEGEND_RATES(:,25) = strpad('d/dt fTC in component calcium_buffering (millimolar)');
LEGEND_RATES(:,26) = strpad('d/dt fTMC in component calcium_buffering (millimolar)');
LEGEND_RATES(:,22) = strpad('d/dt fTMM in component calcium_buffering (millimolar)');
LEGEND_RATES(:,23) = strpad('d/dt fCMi in component calcium_buffering (millimolar)');
LEGEND_RATES(:,24) = strpad('d/dt fCMs in component calcium_buffering (millimolar)');
LEGEND_RATES(:,27) = strpad('d/dt fCQ in component calcium_buffering (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) = -58.600291137693;
CONSTANTS(:,1) = 8314400000000000;
CONSTANTS(:,2) = 310.15;
CONSTANTS(:,3) = 96485000000000000;
CONSTANTS(:,4) = 32;
STATES(:,2) = 9.438646305915;
CONSTANTS(:,5) = 140;
STATES(:,3) = 139.984146485614;
CONSTANTS(:,6) = 5.4;
CONSTANTS(:,7) = 0.58;
CONSTANTS(:,8) = 45;
STATES(:,4) = 0.00019074741;
STATES(:,5) = 0.000602055134;
STATES(:,6) = 0.626999773853;
STATES(:,7) = 0.589580408056;
CONSTANTS(:,9) = 60;
CONSTANTS(:,10) = 0.00035;
CONSTANTS(:,11) = 0.458;
CONSTANTS(:,12) = 45;
STATES(:,8) = 0.004571884917;
STATES(:,9) = 0.249637570396;
STATES(:,10) = 0.629323128348;
STATES(:,11) = 0.3493633709533;
STATES(:,12) = 0.852396631172;
CONSTANTS(:,13) = 0.0259;
STATES(:,13) = 0.054409723782;
CONSTANTS(:,14) = 0.18;
CONSTANTS(:,15) = 0.02;
STATES(:,14) = 0.531446952485;
STATES(:,15) = 0.005550489445;
CONSTANTS(:,16) = 0.1437375;
CONSTANTS(:,17) = 0.2312625;
STATES(:,16) = 0.067156687129;
CONSTANTS(:,18) = 0.015;
CONSTANTS(:,19) = 37.4;
STATES(:,17) = 0.426018100136;
STATES(:,18) = 0.333330378068;
CONSTANTS(:,20) = 0.0054;
CONSTANTS(:,21) = 1.4;
CONSTANTS(:,22) = 14;
CONSTANTS(:,23) = 3.6;
CONSTANTS(:,24) = 125;
CONSTANTS(:,25) = 0.1369;
CONSTANTS(:,26) = 0.4315;
CONSTANTS(:,27) = 0;
CONSTANTS(:,28) = 26.44;
CONSTANTS(:,29) = 0.0207;
CONSTANTS(:,30) = 395.3;
CONSTANTS(:,31) = 2.289;
CONSTANTS(:,32) = 26.44;
CONSTANTS(:,33) = 4.663;
CONSTANTS(:,34) = 1628;
CONSTANTS(:,35) = 561.4;
CONSTANTS(:,36) = 3.663;
CONSTANTS(:,37) = 2;
CONSTANTS(:,38) = 0.04;
CONSTANTS(:,39) = 60;
CONSTANTS(:,40) = 0.0012;
CONSTANTS(:,41) = 0.005;
CONSTANTS(:,42) = 0.5;
CONSTANTS(:,43) = 0.0006;
STATES(:,19) = 1.462338380106;
STATES(:,20) = 0.000312494921;
STATES(:,21) = 0.296742023718;
CONSTANTS(:,44) = 2.5;
CONSTANTS(:,45) = 0.0000000000015835;
CONSTANTS(:,46) = 0.0000000000000042223;
CONSTANTS(:,47) = 0.000000000000040816;
CONSTANTS(:,48) = 0.000000000000035098;
CONSTANTS(:,49) = 0.062;
CONSTANTS(:,50) = 0.045;
CONSTANTS(:,51) = 0.031;
CONSTANTS(:,52) = 10;
STATES(:,22) = 0.350600895635;
STATES(:,23) = 0.116947220413;
STATES(:,24) = 0.074631965653;
STATES(:,25) = 0.059206293446;
STATES(:,26) = 0.602955114871;
STATES(:,27) = 0.260317260703;
CONSTANTS(:,53) = 88.8;
CONSTANTS(:,54) = 2.277;
CONSTANTS(:,55) = 227.7;
CONSTANTS(:,56) = 227.7;
CONSTANTS(:,57) = 0.534;
CONSTANTS(:,58) = 0.446;
CONSTANTS(:,59) = 0.00751;
CONSTANTS(:,60) = 0.751;
CONSTANTS(:,61) = 0.542;
CONSTANTS(:,62) = 0.445;
CONSTANTS(:,63) =  CONSTANTS(:,10).*CONSTANTS(:,9);
CONSTANTS(:,64) =  0.0250000.*power(CONSTANTS(:,6)./1.00000, 0.590000);
CONSTANTS(:,65) =  0.00110000.*power(CONSTANTS(:,6)./1.00000, 0.410000);
CONSTANTS(:,66) = CONSTANTS(:,5)./(CONSTANTS(:,33)+CONSTANTS(:,5));
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(:,15) =  CONSTANTS(:,54).*CONSTANTS(:,44).*(1.00000 - (STATES(:,26)+STATES(:,22))) -  CONSTANTS(:,60).*STATES(:,22);
RATES(:,22) = ALGEBRAIC(:,15);
ALGEBRAIC(:,3) = 1.00000./(1.00000+exp((STATES(:,1)+30.0000)./5.00000));
ALGEBRAIC(:,17) = 44.3000+ 257.100.*exp( - power((STATES(:,1)+32.5000)./13.9000, 2.00000));
RATES(:,6) = (ALGEBRAIC(:,3) - STATES(:,6))./ALGEBRAIC(:,17);
ALGEBRAIC(:,4) = CONSTANTS(:,10)./(CONSTANTS(:,10)+STATES(:,4));
ALGEBRAIC(:,18) = ALGEBRAIC(:,4)./CONSTANTS(:,63);
RATES(:,7) = (ALGEBRAIC(:,4) - STATES(:,7))./ALGEBRAIC(:,18);
ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1)+26.3000)./6.00000));
ALGEBRAIC(:,19) = 1.00000./( 1.06800.*exp((STATES(:,1)+26.3000)./30.0000)+ 1.06800.*exp( - (STATES(:,1)+26.3000)./30.0000));
RATES(:,8) = (ALGEBRAIC(:,5) - STATES(:,8))./ALGEBRAIC(:,19);
ALGEBRAIC(:,6) = 1.00000./(1.00000+exp((STATES(:,1)+61.7000)./5.60000));
ALGEBRAIC(:,20) = 1.00000./( 0.0153000.*exp( - (STATES(:,1)+61.7000)./83.3000)+ 0.0150000.*exp((STATES(:,1)+61.7000)./15.3800));
RATES(:,9) = (ALGEBRAIC(:,6) - STATES(:,9))./ALGEBRAIC(:,20);
ALGEBRAIC(:,7) = 1.00000./(1.00000+exp( - (STATES(:,1)+23.2000)./10.6000));
ALGEBRAIC(:,21) = 0.846554./( 0.00420000.*exp(STATES(:,1)./17.0000)+ 0.000150000.*exp( - STATES(:,1)./21.6000));
RATES(:,10) = (ALGEBRAIC(:,7) - STATES(:,10))./ALGEBRAIC(:,21);
ALGEBRAIC(:,22) = 0.846554./( 0.0372000.*exp(STATES(:,1)./15.9000)+ 0.000960000.*exp( - STATES(:,1)./22.5000));
RATES(:,11) = (ALGEBRAIC(:,7) - STATES(:,11))./ALGEBRAIC(:,22);
ALGEBRAIC(:,8) = 1.00000./(1.00000+exp((STATES(:,1)+28.6000)./17.1000));
ALGEBRAIC(:,23) = 1.00000./( 0.100000.*exp( - STATES(:,1)./54.6450)+ 0.656000.*exp(STATES(:,1)./106.157));
RATES(:,12) = (ALGEBRAIC(:,8) - STATES(:,12))./ALGEBRAIC(:,23);
ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,1)+49.0000)./13.0000));
ALGEBRAIC(:,25) =  0.600000.*(65.1700./( 0.570000.*exp(  - 0.0800000.*(STATES(:,1)+44.0000))+ 0.0650000.*exp( 0.100000.*(STATES(:,1)+45.9300)))+10.1000);
RATES(:,14) = (ALGEBRAIC(:,10) - STATES(:,14))./ALGEBRAIC(:,25);
ALGEBRAIC(:,11) = 1.00000./(1.00000+exp( - (STATES(:,1) - 19.3000)./15.0000));
ALGEBRAIC(:,26) =  0.660000.*1.40000.*(15.5900./( 1.03700.*exp( 0.0900000.*(STATES(:,1)+30.6100))+ 0.369000.*exp(  - 0.120000.*(STATES(:,1)+23.8400)))+2.98000);
RATES(:,15) = (ALGEBRAIC(:,11) - STATES(:,15))./ALGEBRAIC(:,26);
ALGEBRAIC(:,12) = 1.00000./(1.00000+exp((STATES(:,1)+64.0000)./13.5000));
ALGEBRAIC(:,27) = 0.716653./(exp( - (STATES(:,1)+386.900)./45.3020)+exp((STATES(:,1) - 73.0800)./19.2310));
RATES(:,16) = (ALGEBRAIC(:,12) - STATES(:,16))./ALGEBRAIC(:,27);
ALGEBRAIC(:,2) = 1.00000./(1.00000+exp( - (STATES(:,1)+14.1000)./6.00000));
ALGEBRAIC(:,16) = (  - 0.0283900.*(STATES(:,1)+35.0000))./(exp( - (STATES(:,1)+35.0000)./2.50000) - 1.00000) - ( 0.0849000.*STATES(:,1))./(exp( - STATES(:,1)./4.80800) - 1.00000);
ALGEBRAIC(:,31) = ( 0.0114300.*(STATES(:,1) - 5.00000))./(exp((STATES(:,1) - 5.00000)./2.50000) - 1.00000);
ALGEBRAIC(:,36) = 1.00000./(ALGEBRAIC(:,16)+ALGEBRAIC(:,31));
RATES(:,5) = (ALGEBRAIC(:,2) - STATES(:,5))./ALGEBRAIC(:,36);
ALGEBRAIC(:,9) = 0.0140000./(1.00000+exp( - (STATES(:,1) - 40.0000)./9.00000));
ALGEBRAIC(:,24) =  0.00100000.*exp( - STATES(:,1)./45.0000);
ALGEBRAIC(:,32) = ALGEBRAIC(:,9)./(ALGEBRAIC(:,9)+ALGEBRAIC(:,24));
ALGEBRAIC(:,37) = 1.00000./(ALGEBRAIC(:,9)+ALGEBRAIC(:,24));
RATES(:,13) = (ALGEBRAIC(:,32) - STATES(:,13))./ALGEBRAIC(:,37);
ALGEBRAIC(:,13) = 1.00000./(1.00000+exp( - (STATES(:,1)+57.0000)./5.00000));
ALGEBRAIC(:,28) = 1.00000./( 0.150000.*exp( - STATES(:,1)./11.0000)+ 0.200000.*exp( - STATES(:,1)./700.000));
ALGEBRAIC(:,33) = 1.00000./( 16.0000.*exp(STATES(:,1)./8.00000)+ 15.0000.*exp(STATES(:,1)./50.0000));
ALGEBRAIC(:,38) = 1.00000./(ALGEBRAIC(:,28)+ALGEBRAIC(:,33));
RATES(:,17) = (ALGEBRAIC(:,13) - STATES(:,17))./ALGEBRAIC(:,38);
ALGEBRAIC(:,14) = 1.00000./( 3100.00.*exp(STATES(:,1)./13.0000)+ 700.000.*exp(STATES(:,1)./70.0000));
ALGEBRAIC(:,29) = 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(:,34) = ALGEBRAIC(:,14)./(ALGEBRAIC(:,14)+ALGEBRAIC(:,29));
ALGEBRAIC(:,39) = 6.65000./(ALGEBRAIC(:,14)+ALGEBRAIC(:,29));
RATES(:,18) = (ALGEBRAIC(:,34) - STATES(:,18))./ALGEBRAIC(:,39);
ALGEBRAIC(:,30) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,6)./STATES(:,3));
ALGEBRAIC(:,41) =  CONSTANTS(:,64).*(STATES(:,1) - ALGEBRAIC(:,30)).*( 0.600000.*STATES(:,11)+ 0.400000.*STATES(:,10)).*STATES(:,12);
ALGEBRAIC(:,42) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log((CONSTANTS(:,6)+ 0.120000.*CONSTANTS(:,5))./(STATES(:,3)+ 0.120000.*STATES(:,2)));
ALGEBRAIC(:,43) =  CONSTANTS(:,13).*(STATES(:,1) - ALGEBRAIC(:,42)).*power(STATES(:,13), 2.00000);
ALGEBRAIC(:,44) =  CONSTANTS(:,14).*(STATES(:,1) - ALGEBRAIC(:,30)).*STATES(:,14).*STATES(:,15);
ALGEBRAIC(:,45) =  CONSTANTS(:,15).*(STATES(:,1) - ALGEBRAIC(:,30)).*STATES(:,15);
ALGEBRAIC(:,1) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,5)./STATES(:,2));
ALGEBRAIC(:,52) =  CONSTANTS(:,23).*power(1.00000+power(CONSTANTS(:,21)./CONSTANTS(:,6), 1.20000),  - 1.00000).*power(1.00000+power(CONSTANTS(:,22)./STATES(:,2), 1.30000),  - 1.00000).*power(1.00000+exp( - ((STATES(:,1) - ALGEBRAIC(:,1))+120.000)./30.0000),  - 1.00000);
ALGEBRAIC(:,51) = ( CONSTANTS(:,65).*(STATES(:,3) -  CONSTANTS(:,6).*exp((  - STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))))./1.00000;
ALGEBRAIC(:,47) =  CONSTANTS(:,17).*(STATES(:,1) - ALGEBRAIC(:,30)).*power(STATES(:,16), 2.00000);
RATES(:,3) = (  - (ALGEBRAIC(:,41)+ALGEBRAIC(:,43)+ALGEBRAIC(:,44)+ALGEBRAIC(:,45)+ALGEBRAIC(:,47)+ALGEBRAIC(:,51)+  - 2.00000.*ALGEBRAIC(:,52)).*CONSTANTS(:,4))./( 1.00000.*CONSTANTS(:,3).*(CONSTANTS(:,45)+CONSTANTS(:,48)));
ALGEBRAIC(:,40) =  CONSTANTS(:,11).*(STATES(:,1) - CONSTANTS(:,12)).*STATES(:,8).*STATES(:,9);
ALGEBRAIC(:,35) =  CONSTANTS(:,7).*(STATES(:,1) - CONSTANTS(:,8)).*STATES(:,5).*STATES(:,6).*STATES(:,7);
ALGEBRAIC(:,46) =  CONSTANTS(:,16).*(STATES(:,1) - ALGEBRAIC(:,1)).*power(STATES(:,16), 2.00000);
ALGEBRAIC(:,48) = ALGEBRAIC(:,46)+ALGEBRAIC(:,47);
ALGEBRAIC(:,49) =  CONSTANTS(:,18).*(STATES(:,1) - CONSTANTS(:,19)).*STATES(:,17).*STATES(:,18);
ALGEBRAIC(:,50) =  CONSTANTS(:,20).*(STATES(:,1) - ALGEBRAIC(:,1));
ALGEBRAIC(:,54) = exp((  - CONSTANTS(:,26).*STATES(:,1).*CONSTANTS(:,3))./( 2.00000.*CONSTANTS(:,1).*CONSTANTS(:,2)));
ALGEBRAIC(:,60) = 1.00000+ (CONSTANTS(:,37)./CONSTANTS(:,36)).*(1.00000+exp(( CONSTANTS(:,27).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))+ (CONSTANTS(:,5)./CONSTANTS(:,34)).*(1.00000+CONSTANTS(:,5)./CONSTANTS(:,35)).*(1.00000+CONSTANTS(:,5)./CONSTANTS(:,33));
ALGEBRAIC(:,62) = ( (( (CONSTANTS(:,5)./CONSTANTS(:,34)).*CONSTANTS(:,5))./CONSTANTS(:,35)).*(1.00000+CONSTANTS(:,5)./CONSTANTS(:,33)).*exp((  - CONSTANTS(:,26).*STATES(:,1).*CONSTANTS(:,3))./( 2.00000.*CONSTANTS(:,1).*CONSTANTS(:,2))))./ALGEBRAIC(:,60);
ALGEBRAIC(:,61) = ( (CONSTANTS(:,37)./CONSTANTS(:,36)).*exp(( CONSTANTS(:,27).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))./ALGEBRAIC(:,60);
ALGEBRAIC(:,58) = exp(( CONSTANTS(:,26).*STATES(:,1).*CONSTANTS(:,3))./( 2.00000.*CONSTANTS(:,1).*CONSTANTS(:,2)));
ALGEBRAIC(:,53) = STATES(:,2)./(CONSTANTS(:,28)+STATES(:,2));
ALGEBRAIC(:,63) =  ALGEBRAIC(:,54).*CONSTANTS(:,66).*(ALGEBRAIC(:,62)+ALGEBRAIC(:,61))+ ALGEBRAIC(:,61).*ALGEBRAIC(:,58).*(ALGEBRAIC(:,53)+ALGEBRAIC(:,54));
ALGEBRAIC(:,55) = 1.00000+ (STATES(:,4)./CONSTANTS(:,29)).*(1.00000+exp((  - CONSTANTS(:,25).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))+STATES(:,2)./CONSTANTS(:,32))+ (STATES(:,2)./CONSTANTS(:,30)).*(1.00000+ (STATES(:,2)./CONSTANTS(:,31)).*(1.00000+STATES(:,2)./CONSTANTS(:,28)));
ALGEBRAIC(:,56) = ( (STATES(:,4)./CONSTANTS(:,29)).*exp((  - CONSTANTS(:,25).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))./ALGEBRAIC(:,55);
ALGEBRAIC(:,57) = ( (( (STATES(:,2)./CONSTANTS(:,30)).*STATES(:,2))./CONSTANTS(:,31)).*(1.00000+STATES(:,2)./CONSTANTS(:,28)).*exp(( CONSTANTS(:,26).*STATES(:,1).*CONSTANTS(:,3))./( 2.00000.*CONSTANTS(:,1).*CONSTANTS(:,2))))./ALGEBRAIC(:,55);
ALGEBRAIC(:,59) =  ALGEBRAIC(:,58).*ALGEBRAIC(:,53).*(ALGEBRAIC(:,57)+ALGEBRAIC(:,56))+ ALGEBRAIC(:,54).*ALGEBRAIC(:,56).*(CONSTANTS(:,66)+ALGEBRAIC(:,58));
ALGEBRAIC(:,64) =  ALGEBRAIC(:,57).*ALGEBRAIC(:,53).*(ALGEBRAIC(:,62)+ALGEBRAIC(:,61))+ ALGEBRAIC(:,56).*ALGEBRAIC(:,62).*(ALGEBRAIC(:,53)+ALGEBRAIC(:,54));
ALGEBRAIC(:,65) =  ALGEBRAIC(:,62).*CONSTANTS(:,66).*(ALGEBRAIC(:,57)+ALGEBRAIC(:,56))+ ALGEBRAIC(:,57).*ALGEBRAIC(:,61).*(CONSTANTS(:,66)+ALGEBRAIC(:,58));
ALGEBRAIC(:,66) = ( CONSTANTS(:,24).*( ALGEBRAIC(:,59).*ALGEBRAIC(:,61) -  ALGEBRAIC(:,63).*ALGEBRAIC(:,56)))./(ALGEBRAIC(:,63)+ALGEBRAIC(:,59)+ALGEBRAIC(:,64)+ALGEBRAIC(:,65));
RATES(:,1) =  - (ALGEBRAIC(:,35)+ALGEBRAIC(:,40)+ALGEBRAIC(:,41)+ALGEBRAIC(:,43)+ALGEBRAIC(:,44)+ALGEBRAIC(:,45)+ALGEBRAIC(:,48)+ALGEBRAIC(:,49)+ALGEBRAIC(:,50)+ALGEBRAIC(:,51)+ALGEBRAIC(:,52)+ALGEBRAIC(:,66))./1.00000;
RATES(:,2) = (  - (ALGEBRAIC(:,46)+ALGEBRAIC(:,49)+ALGEBRAIC(:,50)+ 3.00000.*ALGEBRAIC(:,52)+ 3.00000.*ALGEBRAIC(:,66)).*CONSTANTS(:,4))./( 1.00000.*CONSTANTS(:,3).*(CONSTANTS(:,45)+CONSTANTS(:,48)));
ALGEBRAIC(:,67) = (STATES(:,4) - STATES(:,20))./CONSTANTS(:,38);
ALGEBRAIC(:,68) = ( CONSTANTS(:,42).*(STATES(:,21) - STATES(:,4)))./(1.00000+power(CONSTANTS(:,40)./STATES(:,4), 2.00000));
ALGEBRAIC(:,70) =  CONSTANTS(:,56).*STATES(:,4).*(1.00000 - STATES(:,24)) -  CONSTANTS(:,61).*STATES(:,24);
RATES(:,4) = ((  - ((ALGEBRAIC(:,35)+ALGEBRAIC(:,40)) -  2.00000.*ALGEBRAIC(:,66)).*CONSTANTS(:,4))./( 1.00000.*2.00000.*CONSTANTS(:,3))+ ALGEBRAIC(:,68).*CONSTANTS(:,46))./CONSTANTS(:,48) - (ALGEBRAIC(:,67)+ CONSTANTS(:,50).*ALGEBRAIC(:,70));
RATES(:,24) = ALGEBRAIC(:,70);
ALGEBRAIC(:,69) = CONSTANTS(:,41)./(1.00000+CONSTANTS(:,43)./STATES(:,20));
ALGEBRAIC(:,71) = (STATES(:,19) - STATES(:,21))./CONSTANTS(:,39);
RATES(:,19) = ALGEBRAIC(:,69) - ( ALGEBRAIC(:,71).*CONSTANTS(:,46))./CONSTANTS(:,47);
ALGEBRAIC(:,72) =  CONSTANTS(:,53).*STATES(:,20).*(1.00000 - STATES(:,25)) -  CONSTANTS(:,58).*STATES(:,25);
RATES(:,25) = ALGEBRAIC(:,72);
ALGEBRAIC(:,74) =  CONSTANTS(:,57).*STATES(:,21).*(1.00000 - STATES(:,27)) -  CONSTANTS(:,62).*STATES(:,27);
RATES(:,21) = ALGEBRAIC(:,71) - (ALGEBRAIC(:,68)+ CONSTANTS(:,52).*ALGEBRAIC(:,74));
ALGEBRAIC(:,73) =  CONSTANTS(:,55).*STATES(:,20).*(1.00000 - (STATES(:,26)+STATES(:,22))) -  CONSTANTS(:,59).*STATES(:,26);
RATES(:,26) = ALGEBRAIC(:,73);
RATES(:,27) = ALGEBRAIC(:,74);
ALGEBRAIC(:,75) =  CONSTANTS(:,56).*STATES(:,20).*(1.00000 - STATES(:,23)) -  CONSTANTS(:,61).*STATES(:,23);
RATES(:,20) = ( ALGEBRAIC(:,67).*CONSTANTS(:,48) -  ALGEBRAIC(:,69).*CONSTANTS(:,47))./CONSTANTS(:,45) - ( CONSTANTS(:,50).*ALGEBRAIC(:,75)+ CONSTANTS(:,51).*ALGEBRAIC(:,72)+ CONSTANTS(:,49).*ALGEBRAIC(:,73));
RATES(:,23) = ALGEBRAIC(:,75);
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(:,15) =  CONSTANTS(:,54).*CONSTANTS(:,44).*(1.00000 - (STATES(:,26)+STATES(:,22))) -  CONSTANTS(:,60).*STATES(:,22);
ALGEBRAIC(:,3) = 1.00000./(1.00000+exp((STATES(:,1)+30.0000)./5.00000));
ALGEBRAIC(:,17) = 44.3000+ 257.100.*exp( - power((STATES(:,1)+32.5000)./13.9000, 2.00000));
ALGEBRAIC(:,4) = CONSTANTS(:,10)./(CONSTANTS(:,10)+STATES(:,4));
ALGEBRAIC(:,18) = ALGEBRAIC(:,4)./CONSTANTS(:,63);
ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1)+26.3000)./6.00000));
ALGEBRAIC(:,19) = 1.00000./( 1.06800.*exp((STATES(:,1)+26.3000)./30.0000)+ 1.06800.*exp( - (STATES(:,1)+26.3000)./30.0000));
ALGEBRAIC(:,6) = 1.00000./(1.00000+exp((STATES(:,1)+61.7000)./5.60000));
ALGEBRAIC(:,20) = 1.00000./( 0.0153000.*exp( - (STATES(:,1)+61.7000)./83.3000)+ 0.0150000.*exp((STATES(:,1)+61.7000)./15.3800));
ALGEBRAIC(:,7) = 1.00000./(1.00000+exp( - (STATES(:,1)+23.2000)./10.6000));
ALGEBRAIC(:,21) = 0.846554./( 0.00420000.*exp(STATES(:,1)./17.0000)+ 0.000150000.*exp( - STATES(:,1)./21.6000));
ALGEBRAIC(:,22) = 0.846554./( 0.0372000.*exp(STATES(:,1)./15.9000)+ 0.000960000.*exp( - STATES(:,1)./22.5000));
ALGEBRAIC(:,8) = 1.00000./(1.00000+exp((STATES(:,1)+28.6000)./17.1000));
ALGEBRAIC(:,23) = 1.00000./( 0.100000.*exp( - STATES(:,1)./54.6450)+ 0.656000.*exp(STATES(:,1)./106.157));
ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,1)+49.0000)./13.0000));
ALGEBRAIC(:,25) =  0.600000.*(65.1700./( 0.570000.*exp(  - 0.0800000.*(STATES(:,1)+44.0000))+ 0.0650000.*exp( 0.100000.*(STATES(:,1)+45.9300)))+10.1000);
ALGEBRAIC(:,11) = 1.00000./(1.00000+exp( - (STATES(:,1) - 19.3000)./15.0000));
ALGEBRAIC(:,26) =  0.660000.*1.40000.*(15.5900./( 1.03700.*exp( 0.0900000.*(STATES(:,1)+30.6100))+ 0.369000.*exp(  - 0.120000.*(STATES(:,1)+23.8400)))+2.98000);
ALGEBRAIC(:,12) = 1.00000./(1.00000+exp((STATES(:,1)+64.0000)./13.5000));
ALGEBRAIC(:,27) = 0.716653./(exp( - (STATES(:,1)+386.900)./45.3020)+exp((STATES(:,1) - 73.0800)./19.2310));
ALGEBRAIC(:,2) = 1.00000./(1.00000+exp( - (STATES(:,1)+14.1000)./6.00000));
ALGEBRAIC(:,16) = (  - 0.0283900.*(STATES(:,1)+35.0000))./(exp( - (STATES(:,1)+35.0000)./2.50000) - 1.00000) - ( 0.0849000.*STATES(:,1))./(exp( - STATES(:,1)./4.80800) - 1.00000);
ALGEBRAIC(:,31) = ( 0.0114300.*(STATES(:,1) - 5.00000))./(exp((STATES(:,1) - 5.00000)./2.50000) - 1.00000);
ALGEBRAIC(:,36) = 1.00000./(ALGEBRAIC(:,16)+ALGEBRAIC(:,31));
ALGEBRAIC(:,9) = 0.0140000./(1.00000+exp( - (STATES(:,1) - 40.0000)./9.00000));
ALGEBRAIC(:,24) =  0.00100000.*exp( - STATES(:,1)./45.0000);
ALGEBRAIC(:,32) = ALGEBRAIC(:,9)./(ALGEBRAIC(:,9)+ALGEBRAIC(:,24));
ALGEBRAIC(:,37) = 1.00000./(ALGEBRAIC(:,9)+ALGEBRAIC(:,24));
ALGEBRAIC(:,13) = 1.00000./(1.00000+exp( - (STATES(:,1)+57.0000)./5.00000));
ALGEBRAIC(:,28) = 1.00000./( 0.150000.*exp( - STATES(:,1)./11.0000)+ 0.200000.*exp( - STATES(:,1)./700.000));
ALGEBRAIC(:,33) = 1.00000./( 16.0000.*exp(STATES(:,1)./8.00000)+ 15.0000.*exp(STATES(:,1)./50.0000));
ALGEBRAIC(:,38) = 1.00000./(ALGEBRAIC(:,28)+ALGEBRAIC(:,33));
ALGEBRAIC(:,14) = 1.00000./( 3100.00.*exp(STATES(:,1)./13.0000)+ 700.000.*exp(STATES(:,1)./70.0000));
ALGEBRAIC(:,29) = 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(:,34) = ALGEBRAIC(:,14)./(ALGEBRAIC(:,14)+ALGEBRAIC(:,29));
ALGEBRAIC(:,39) = 6.65000./(ALGEBRAIC(:,14)+ALGEBRAIC(:,29));
ALGEBRAIC(:,30) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,6)./STATES(:,3));
ALGEBRAIC(:,41) =  CONSTANTS(:,64).*(STATES(:,1) - ALGEBRAIC(:,30)).*( 0.600000.*STATES(:,11)+ 0.400000.*STATES(:,10)).*STATES(:,12);
ALGEBRAIC(:,42) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log((CONSTANTS(:,6)+ 0.120000.*CONSTANTS(:,5))./(STATES(:,3)+ 0.120000.*STATES(:,2)));
ALGEBRAIC(:,43) =  CONSTANTS(:,13).*(STATES(:,1) - ALGEBRAIC(:,42)).*power(STATES(:,13), 2.00000);
ALGEBRAIC(:,44) =  CONSTANTS(:,14).*(STATES(:,1) - ALGEBRAIC(:,30)).*STATES(:,14).*STATES(:,15);
ALGEBRAIC(:,45) =  CONSTANTS(:,15).*(STATES(:,1) - ALGEBRAIC(:,30)).*STATES(:,15);
ALGEBRAIC(:,1) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,5)./STATES(:,2));
ALGEBRAIC(:,52) =  CONSTANTS(:,23).*power(1.00000+power(CONSTANTS(:,21)./CONSTANTS(:,6), 1.20000),  - 1.00000).*power(1.00000+power(CONSTANTS(:,22)./STATES(:,2), 1.30000),  - 1.00000).*power(1.00000+exp( - ((STATES(:,1) - ALGEBRAIC(:,1))+120.000)./30.0000),  - 1.00000);
ALGEBRAIC(:,51) = ( CONSTANTS(:,65).*(STATES(:,3) -  CONSTANTS(:,6).*exp((  - STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))))./1.00000;
ALGEBRAIC(:,47) =  CONSTANTS(:,17).*(STATES(:,1) - ALGEBRAIC(:,30)).*power(STATES(:,16), 2.00000);
ALGEBRAIC(:,40) =  CONSTANTS(:,11).*(STATES(:,1) - CONSTANTS(:,12)).*STATES(:,8).*STATES(:,9);
ALGEBRAIC(:,35) =  CONSTANTS(:,7).*(STATES(:,1) - CONSTANTS(:,8)).*STATES(:,5).*STATES(:,6).*STATES(:,7);
ALGEBRAIC(:,46) =  CONSTANTS(:,16).*(STATES(:,1) - ALGEBRAIC(:,1)).*power(STATES(:,16), 2.00000);
ALGEBRAIC(:,48) = ALGEBRAIC(:,46)+ALGEBRAIC(:,47);
ALGEBRAIC(:,49) =  CONSTANTS(:,18).*(STATES(:,1) - CONSTANTS(:,19)).*STATES(:,17).*STATES(:,18);
ALGEBRAIC(:,50) =  CONSTANTS(:,20).*(STATES(:,1) - ALGEBRAIC(:,1));
ALGEBRAIC(:,54) = exp((  - CONSTANTS(:,26).*STATES(:,1).*CONSTANTS(:,3))./( 2.00000.*CONSTANTS(:,1).*CONSTANTS(:,2)));
ALGEBRAIC(:,60) = 1.00000+ (CONSTANTS(:,37)./CONSTANTS(:,36)).*(1.00000+exp(( CONSTANTS(:,27).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))+ (CONSTANTS(:,5)./CONSTANTS(:,34)).*(1.00000+CONSTANTS(:,5)./CONSTANTS(:,35)).*(1.00000+CONSTANTS(:,5)./CONSTANTS(:,33));
ALGEBRAIC(:,62) = ( (( (CONSTANTS(:,5)./CONSTANTS(:,34)).*CONSTANTS(:,5))./CONSTANTS(:,35)).*(1.00000+CONSTANTS(:,5)./CONSTANTS(:,33)).*exp((  - CONSTANTS(:,26).*STATES(:,1).*CONSTANTS(:,3))./( 2.00000.*CONSTANTS(:,1).*CONSTANTS(:,2))))./ALGEBRAIC(:,60);
ALGEBRAIC(:,61) = ( (CONSTANTS(:,37)./CONSTANTS(:,36)).*exp(( CONSTANTS(:,27).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))./ALGEBRAIC(:,60);
ALGEBRAIC(:,58) = exp(( CONSTANTS(:,26).*STATES(:,1).*CONSTANTS(:,3))./( 2.00000.*CONSTANTS(:,1).*CONSTANTS(:,2)));
ALGEBRAIC(:,53) = STATES(:,2)./(CONSTANTS(:,28)+STATES(:,2));
ALGEBRAIC(:,63) =  ALGEBRAIC(:,54).*CONSTANTS(:,66).*(ALGEBRAIC(:,62)+ALGEBRAIC(:,61))+ ALGEBRAIC(:,61).*ALGEBRAIC(:,58).*(ALGEBRAIC(:,53)+ALGEBRAIC(:,54));
ALGEBRAIC(:,55) = 1.00000+ (STATES(:,4)./CONSTANTS(:,29)).*(1.00000+exp((  - CONSTANTS(:,25).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))+STATES(:,2)./CONSTANTS(:,32))+ (STATES(:,2)./CONSTANTS(:,30)).*(1.00000+ (STATES(:,2)./CONSTANTS(:,31)).*(1.00000+STATES(:,2)./CONSTANTS(:,28)));
ALGEBRAIC(:,56) = ( (STATES(:,4)./CONSTANTS(:,29)).*exp((  - CONSTANTS(:,25).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))./ALGEBRAIC(:,55);
ALGEBRAIC(:,57) = ( (( (STATES(:,2)./CONSTANTS(:,30)).*STATES(:,2))./CONSTANTS(:,31)).*(1.00000+STATES(:,2)./CONSTANTS(:,28)).*exp(( CONSTANTS(:,26).*STATES(:,1).*CONSTANTS(:,3))./( 2.00000.*CONSTANTS(:,1).*CONSTANTS(:,2))))./ALGEBRAIC(:,55);
ALGEBRAIC(:,59) =  ALGEBRAIC(:,58).*ALGEBRAIC(:,53).*(ALGEBRAIC(:,57)+ALGEBRAIC(:,56))+ ALGEBRAIC(:,54).*ALGEBRAIC(:,56).*(CONSTANTS(:,66)+ALGEBRAIC(:,58));
ALGEBRAIC(:,64) =  ALGEBRAIC(:,57).*ALGEBRAIC(:,53).*(ALGEBRAIC(:,62)+ALGEBRAIC(:,61))+ ALGEBRAIC(:,56).*ALGEBRAIC(:,62).*(ALGEBRAIC(:,53)+ALGEBRAIC(:,54));
ALGEBRAIC(:,65) =  ALGEBRAIC(:,62).*CONSTANTS(:,66).*(ALGEBRAIC(:,57)+ALGEBRAIC(:,56))+ ALGEBRAIC(:,57).*ALGEBRAIC(:,61).*(CONSTANTS(:,66)+ALGEBRAIC(:,58));
ALGEBRAIC(:,66) = ( CONSTANTS(:,24).*( ALGEBRAIC(:,59).*ALGEBRAIC(:,61) -  ALGEBRAIC(:,63).*ALGEBRAIC(:,56)))./(ALGEBRAIC(:,63)+ALGEBRAIC(:,59)+ALGEBRAIC(:,64)+ALGEBRAIC(:,65));
ALGEBRAIC(:,67) = (STATES(:,4) - STATES(:,20))./CONSTANTS(:,38);
ALGEBRAIC(:,68) = ( CONSTANTS(:,42).*(STATES(:,21) - STATES(:,4)))./(1.00000+power(CONSTANTS(:,40)./STATES(:,4), 2.00000));
ALGEBRAIC(:,70) =  CONSTANTS(:,56).*STATES(:,4).*(1.00000 - STATES(:,24)) -  CONSTANTS(:,61).*STATES(:,24);
ALGEBRAIC(:,69) = CONSTANTS(:,41)./(1.00000+CONSTANTS(:,43)./STATES(:,20));
ALGEBRAIC(:,71) = (STATES(:,19) - STATES(:,21))./CONSTANTS(:,39);
ALGEBRAIC(:,72) =  CONSTANTS(:,53).*STATES(:,20).*(1.00000 - STATES(:,25)) -  CONSTANTS(:,58).*STATES(:,25);
ALGEBRAIC(:,74) =  CONSTANTS(:,57).*STATES(:,21).*(1.00000 - STATES(:,27)) -  CONSTANTS(:,62).*STATES(:,27);
ALGEBRAIC(:,73) =  CONSTANTS(:,55).*STATES(:,20).*(1.00000 - (STATES(:,26)+STATES(:,22))) -  CONSTANTS(:,59).*STATES(:,26);
ALGEBRAIC(:,75) =  CONSTANTS(:,56).*STATES(:,20).*(1.00000 - STATES(:,23)) -  CONSTANTS(:,61).*STATES(:,23);
end

% Pad out or shorten strings to a set length
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

```
Source
Derived from workspace Kurata, Hisatome, Imanishi, Shibamoto, 2002 at changeset 5cc3253726ef.
Collaboration
To begin collaborating on this work, please use your git client and issue this command: