# 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 =84;
end
% There are a total of 39 entries in each of the rate and state variable arrays.
% There are a total of 148 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_CONSTANTS(:,1) = strpad('t_period in component Istim_parameters (ms)');
LEGEND_CONSTANTS(:,2) = strpad('V_ICCrest in component Istim_parameters (mV)');
LEGEND_CONSTANTS(:,3) = strpad('V_ICCamp in component Istim_parameters (mV)');
LEGEND_CONSTANTS(:,4) = strpad('t_ICCpeak in component Istim_parameters (ms)');
LEGEND_CONSTANTS(:,5) = strpad('t_slope in component Istim_parameters (ms)');
LEGEND_CONSTANTS(:,6) = strpad('f_1 in component Istim_parameters (ms)');
LEGEND_CONSTANTS(:,7) = strpad('f_2 in component Istim_parameters (ms)');
LEGEND_CONSTANTS(:,8) = strpad('Gcouple in component Istim_parameters (nS)');
LEGEND_VOI = strpad('time in component time (ms)');
LEGEND_ALGEBRAIC(:,14) = strpad('I_stim in component Periodic_IStim_protocol (pA)');
LEGEND_ALGEBRAIC(:,9) = strpad('V_ICC in component Periodic_IStim_protocol (mV)');
LEGEND_STATES(:,1) = strpad('V in component Membrane_potential (mV)');
LEGEND_ALGEBRAIC(:,83) = strpad('I_ion in component Membrane_potential (pA)');
LEGEND_ALGEBRAIC(:,38) = strpad('I in component Ionic_currents (pA)');
LEGEND_ALGEBRAIC(:,46) = strpad('I in component Ionic_currents (pA)');
LEGEND_ALGEBRAIC(:,55) = strpad('I in component Ionic_currents (pA)');
LEGEND_ALGEBRAIC(:,62) = strpad('I in component Ionic_currents (pA)');
LEGEND_ALGEBRAIC(:,68) = strpad('I in component Ionic_currents (pA)');
LEGEND_ALGEBRAIC(:,26) = strpad('I_NCX in component INCX (pA)');
LEGEND_ALGEBRAIC(:,30) = strpad('I_NaK in component INaK (pA)');
LEGEND_ALGEBRAIC(:,74) = strpad('I in component Ionic_currents (pA)');
LEGEND_ALGEBRAIC(:,80) = strpad('I in component Ionic_currents (pA)');
LEGEND_STATES(:,2) = strpad('Cai in component Cai (mM)');
LEGEND_STATES(:,3) = strpad('Nai in component Nai (mM)');
LEGEND_STATES(:,4) = strpad('Ki in component Ki (mM)');
LEGEND_STATES(:,5) = strpad('O_CaL in component ICaL_channel_states (dimensionless)');
LEGEND_ALGEBRAIC(:,18) = strpad('P_CaT in component ICaT (dimensionless)');
LEGEND_STATES(:,6) = strpad('O4 in component IBK_channel_states (dimensionless)');
LEGEND_ALGEBRAIC(:,22) = strpad('P_Kv in component IKv (dimensionless)');
LEGEND_STATES(:,7) = strpad('O_Na in component INa_channel_states (dimensionless)');
LEGEND_ALGEBRAIC(:,84) = strpad('norm in component ICaL_channel_states (dimensionless)');
LEGEND_ALGEBRAIC(:,82) = strpad('norm in component IBK_channel_states (dimensionless)');
LEGEND_ALGEBRAIC(:,57) = strpad('norm in component INa_channel_states (dimensionless)');
LEGEND_STATES(:,8) = strpad('X in component gating_kinetics (dimensionless)');
LEGEND_STATES(:,9) = strpad('X in component gating_kinetics (dimensionless)');
LEGEND_STATES(:,10) = strpad('X in component gating_kinetics (dimensionless)');
LEGEND_STATES(:,11) = strpad('X in component gating_kinetics (dimensionless)');
LEGEND_CONSTANTS(:,9) = strpad('g_CaL in component g_parameters (nS)');
LEGEND_CONSTANTS(:,10) = strpad('g_Kv in component g_parameters (nS)');
LEGEND_CONSTANTS(:,11) = strpad('g_BK in component g_parameters (nS)');
LEGEND_CONSTANTS(:,12) = strpad('g_Na in component g_parameters (nS)');
LEGEND_CONSTANTS(:,13) = strpad('V_init in component initial_conditions (mV)');
LEGEND_CONSTANTS(:,14) = strpad('Cm in component model_parameters (pF)');
LEGEND_CONSTANTS(:,15) = strpad('R in component model_parameters (J_per_K_mol)');
LEGEND_CONSTANTS(:,16) = strpad('T in component model_parameters (kelvin)');
LEGEND_CONSTANTS(:,17) = strpad('F in component model_parameters (C_per_mmol)');
LEGEND_CONSTANTS(:,18) = strpad('T0CaL in component model_parameters (kelvin)');
LEGEND_CONSTANTS(:,19) = strpad('T0CaT in component model_parameters (kelvin)');
LEGEND_CONSTANTS(:,20) = strpad('Q10Ca in component model_parameters (dimensionless)');
LEGEND_CONSTANTS(:,21) = strpad('Cao in component model_parameters (mM)');
LEGEND_CONSTANTS(:,22) = strpad('C0_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,23) = strpad('C1_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,24) = strpad('C2_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,25) = strpad('C3_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,26) = strpad('C0Ca_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,27) = strpad('C1Ca_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,28) = strpad('C2Ca_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,29) = strpad('C3Ca_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,30) = strpad('ICa_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,31) = strpad('IVs_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,32) = strpad('IVf_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,33) = strpad('IVfCa_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,34) = strpad('IVsCa_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,35) = strpad('O_CaL_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,36) = strpad('g_CaT in component model_parameters (nS)');
LEGEND_CONSTANTS(:,37) = strpad('d_CaT_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,38) = strpad('f_CaT_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,39) = strpad('tau_dCaT in component model_parameters (ms)');
LEGEND_CONSTANTS(:,40) = strpad('T0K in component model_parameters (kelvin)');
LEGEND_CONSTANTS(:,41) = strpad('Q10K in component model_parameters (dimensionless)');
LEGEND_CONSTANTS(:,42) = strpad('Ko in component model_parameters (mM)');
LEGEND_CONSTANTS(:,43) = strpad('x_Kv_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,44) = strpad('y_Kv_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,45) = strpad('tau_xKv in component model_parameters (ms)');
LEGEND_CONSTANTS(:,46) = strpad('tau_yKv in component model_parameters (ms)');
LEGEND_CONSTANTS(:,47) = strpad('BK_C0_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,48) = strpad('BK_C1_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,49) = strpad('BK_C2_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,50) = strpad('BK_C3_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,51) = strpad('BK_C4_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,52) = strpad('O0_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,53) = strpad('O1_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,54) = strpad('O2_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,55) = strpad('O3_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,56) = strpad('O4_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,57) = strpad('k_on in component model_parameters (per_ms)');
LEGEND_CONSTANTS(:,58) = strpad('k_off_C in component model_parameters (per_ms)');
LEGEND_CONSTANTS(:,59) = strpad('k_off_O in component model_parameters (per_ms)');
LEGEND_CONSTANTS(:,60) = strpad('T0Na in component model_parameters (kelvin)');
LEGEND_CONSTANTS(:,61) = strpad('Q10Na in component model_parameters (dimensionless)');
LEGEND_CONSTANTS(:,62) = strpad('Nao in component model_parameters (mM)');
LEGEND_CONSTANTS(:,63) = strpad('Na_C1_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,64) = strpad('Na_C2_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,65) = strpad('Na_C3_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,66) = strpad('I1_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,67) = strpad('I2_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,68) = strpad('O_Na_init in component initial_conditions (dimensionless)');
LEGEND_CONSTANTS(:,69) = strpad('K_mCa in component model_parameters (mM)');
LEGEND_CONSTANTS(:,70) = strpad('K_mNai in component model_parameters (mM)');
LEGEND_CONSTANTS(:,71) = strpad('k_sat in component model_parameters (dimensionless)');
LEGEND_CONSTANTS(:,72) = strpad('gamma in component model_parameters (dimensionless)');
LEGEND_CONSTANTS(:,73) = strpad('P_NCX in component model_parameters (pA)');
LEGEND_CONSTANTS(:,74) = strpad('K_mK in component model_parameters (mM)');
LEGEND_CONSTANTS(:,75) = strpad('K_mNa in component model_parameters (mM)');
LEGEND_CONSTANTS(:,76) = strpad('P_NaK in component model_parameters (pA)');
LEGEND_CONSTANTS(:,77) = strpad('g_NsNa in component model_parameters (nS)');
LEGEND_CONSTANTS(:,78) = strpad('g_NsK in component model_parameters (nS)');
LEGEND_CONSTANTS(:,79) = strpad('n_CRT in component model_parameters (dimensionless)');
LEGEND_CONSTANTS(:,80) = strpad('n_CaM in component model_parameters (dimensionless)');
LEGEND_CONSTANTS(:,81) = strpad('CRT_total in component model_parameters (mM)');
LEGEND_CONSTANTS(:,82) = strpad('CaM_total in component model_parameters (mM)');
LEGEND_CONSTANTS(:,83) = strpad('K_D_CRT in component model_parameters (mM)');
LEGEND_CONSTANTS(:,84) = strpad('K_D_CaM in component model_parameters (mM4)');
LEGEND_CONSTANTS(:,85) = strpad('V_cell in component model_parameters (litre)');
LEGEND_CONSTANTS(:,86) = strpad('Cai_total_init in component initial_conditions (mM)');
LEGEND_CONSTANTS(:,87) = strpad('Cai_init in component initial_conditions (mM)');
LEGEND_CONSTANTS(:,88) = strpad('Nai_init in component initial_conditions (mM)');
LEGEND_CONSTANTS(:,89) = strpad('Ki_init in component initial_conditions (mM)');
LEGEND_ALGEBRAIC(:,1) = strpad('t in component Periodic_IStim_protocol (ms)');
LEGEND_CONSTANTS(:,90) = strpad('g_CaL in component model_parameters (nS)');
LEGEND_CONSTANTS(:,91) = strpad('g_Kv in component model_parameters (nS)');
LEGEND_CONSTANTS(:,92) = strpad('g_BK in component model_parameters (nS)');
LEGEND_CONSTANTS(:,93) = strpad('g_Na in component model_parameters (nS)');
LEGEND_CONSTANTS(:,94) = strpad('PO in component INS_Na (dimensionless)');
LEGEND_CONSTANTS(:,95) = strpad('PO in component INS_K (dimensionless)');
LEGEND_STATES(:,12) = strpad('Cai_total in component Cai (mM)');
LEGEND_ALGEBRAIC(:,53) = strpad('Cai_total_rate in component Cai (mM_per_ms)');
LEGEND_CONSTANTS(:,96) = strpad('Cvt in component Cai (fM_per_s2mM_per_ms)');
LEGEND_CONSTANTS(:,97) = strpad('Cvt in component Nai (fM_per_s2mM_per_ms)');
LEGEND_CONSTANTS(:,98) = strpad('Cvt in component Ki (fM_per_s2mM_per_ms)');
LEGEND_ALGEBRAIC(:,34) = strpad('E in component Nernst_potential (mV)');
LEGEND_STATES(:,13) = strpad('C0 in component ICaL_channel_states (dimensionless)');
LEGEND_STATES(:,14) = strpad('C1 in component ICaL_channel_states (dimensionless)');
LEGEND_STATES(:,15) = strpad('C2 in component ICaL_channel_states (dimensionless)');
LEGEND_STATES(:,16) = strpad('C3 in component ICaL_channel_states (dimensionless)');
LEGEND_STATES(:,17) = strpad('C0Ca in component ICaL_channel_states (dimensionless)');
LEGEND_STATES(:,18) = strpad('C1Ca in component ICaL_channel_states (dimensionless)');
LEGEND_STATES(:,19) = strpad('C2Ca in component ICaL_channel_states (dimensionless)');
LEGEND_STATES(:,20) = strpad('C3Ca in component ICaL_channel_states (dimensionless)');
LEGEND_STATES(:,21) = strpad('ICa in component ICaL_channel_states (dimensionless)');
LEGEND_STATES(:,22) = strpad('IVs in component ICaL_channel_states (dimensionless)');
LEGEND_STATES(:,23) = strpad('IVf in component ICaL_channel_states (dimensionless)');
LEGEND_STATES(:,24) = strpad('IVfCa in component ICaL_channel_states (dimensionless)');
LEGEND_STATES(:,25) = strpad('IVsCa in component ICaL_channel_states (dimensionless)');
LEGEND_ALGEBRAIC(:,2) = strpad('alpha in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,10) = strpad('beta in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,15) = strpad('alpha_0 in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,19) = strpad('alpha_1 in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,23) = strpad('alpha_2 in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,27) = strpad('alpha_3 in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,32) = strpad('beta_0 in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,37) = strpad('beta_1 in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,41) = strpad('beta_2 in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,45) = strpad('beta_3 in component ICaL_channel_states (per_ms)');
LEGEND_CONSTANTS(:,148) = strpad('delta in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,81) = strpad('theta in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,54) = strpad('phi_s in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,49) = strpad('phi_f in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,72) = strpad('omega_s in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,69) = strpad('omega_f in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,78) = strpad('omega_fs in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,75) = strpad('omega_sf in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,67) = strpad('psi_s in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,64) = strpad('psi_f in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,61) = strpad('xi_s in component ICaL_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,58) = strpad('xi_f in component ICaL_channel_states (per_ms)');
LEGEND_CONSTANTS(:,134) = strpad('phi in component temperature_factor (dimensionless)');
LEGEND_ALGEBRAIC(:,42) = strpad('E in component Nernst_potential (mV)');
LEGEND_ALGEBRAIC(:,3) = strpad('X_inf in component d_inf (dimensionless)');
LEGEND_CONSTANTS(:,135) = strpad('phi in component temperature_factor (dimensionless)');
LEGEND_ALGEBRAIC(:,4) = strpad('X_inf in component f_inf (dimensionless)');
LEGEND_ALGEBRAIC(:,11) = strpad('tau in component tau_f (ms)');
LEGEND_CONSTANTS(:,136) = strpad('phi in component temperature_factor (dimensionless)');
LEGEND_ALGEBRAIC(:,50) = strpad('E in component Nernst_potential (mV)');
LEGEND_ALGEBRAIC(:,5) = strpad('X_inf in component x_inf (dimensionless)');
LEGEND_CONSTANTS(:,137) = strpad('phi in component temperature_factor (dimensionless)');
LEGEND_ALGEBRAIC(:,6) = strpad('X_inf in component y_inf (dimensionless)');
LEGEND_CONSTANTS(:,138) = strpad('phi in component temperature_factor (dimensionless)');
LEGEND_ALGEBRAIC(:,59) = strpad('E in component Nernst_potential (mV)');
LEGEND_STATES(:,26) = strpad('C0 in component IBK_channel_states (dimensionless)');
LEGEND_STATES(:,27) = strpad('C1 in component IBK_channel_states (dimensionless)');
LEGEND_STATES(:,28) = strpad('C2 in component IBK_channel_states (dimensionless)');
LEGEND_STATES(:,29) = strpad('C3 in component IBK_channel_states (dimensionless)');
LEGEND_STATES(:,30) = strpad('C4 in component IBK_channel_states (dimensionless)');
LEGEND_STATES(:,31) = strpad('O0 in component IBK_channel_states (dimensionless)');
LEGEND_STATES(:,32) = strpad('O1 in component IBK_channel_states (dimensionless)');
LEGEND_STATES(:,33) = strpad('O2 in component IBK_channel_states (dimensionless)');
LEGEND_STATES(:,34) = strpad('O3 in component IBK_channel_states (dimensionless)');
LEGEND_ALGEBRAIC(:,7) = strpad('alpha in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,12) = strpad('beta in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,16) = strpad('k_C0O0 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,20) = strpad('k_C1O1 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,24) = strpad('k_C2O2 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,28) = strpad('k_C3O3 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,33) = strpad('k_C4O4 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,35) = strpad('k_O0C0 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,39) = strpad('k_O1C1 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,43) = strpad('k_O2C2 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,47) = strpad('k_O3C3 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,51) = strpad('k_O4C4 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,56) = strpad('k_C0C1 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,60) = strpad('k_C1C2 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,63) = strpad('k_C2C3 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,66) = strpad('k_C3C4 in component IBK_channel_states (per_ms)');
LEGEND_CONSTANTS(:,139) = strpad('k_C4C3 in component IBK_channel_states (per_ms)');
LEGEND_CONSTANTS(:,140) = strpad('k_C3C2 in component IBK_channel_states (per_ms)');
LEGEND_CONSTANTS(:,141) = strpad('k_C2C1 in component IBK_channel_states (per_ms)');
LEGEND_CONSTANTS(:,142) = strpad('k_C1C0 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,70) = strpad('k_O0O1 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,73) = strpad('k_O1O2 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,76) = strpad('k_O2O3 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,79) = strpad('k_O3O4 in component IBK_channel_states (per_ms)');
LEGEND_CONSTANTS(:,143) = strpad('k_O4O3 in component IBK_channel_states (per_ms)');
LEGEND_CONSTANTS(:,144) = strpad('k_O3O2 in component IBK_channel_states (per_ms)');
LEGEND_CONSTANTS(:,145) = strpad('k_O2O1 in component IBK_channel_states (per_ms)');
LEGEND_CONSTANTS(:,146) = strpad('k_O1O0 in component IBK_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,65) = strpad('E in component Nernst_potential (mV)');
LEGEND_STATES(:,35) = strpad('C1 in component INa_channel_states (dimensionless)');
LEGEND_STATES(:,36) = strpad('C2 in component INa_channel_states (dimensionless)');
LEGEND_STATES(:,37) = strpad('C3 in component INa_channel_states (dimensionless)');
LEGEND_STATES(:,38) = strpad('I1 in component INa_channel_states (dimensionless)');
LEGEND_STATES(:,39) = strpad('I2 in component INa_channel_states (dimensionless)');
LEGEND_ALGEBRAIC(:,8) = strpad('k_I2I1 in component INa_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,13) = strpad('k_I1O in component INa_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,17) = strpad('k_OC1 in component INa_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,21) = strpad('k_C1C2 in component INa_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,25) = strpad('k_C2C3 in component INa_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,29) = strpad('k_C3C2 in component INa_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,31) = strpad('k_C2C1 in component INa_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,36) = strpad('k_C1O in component INa_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,40) = strpad('k_OI1 in component INa_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,44) = strpad('k_I1I2 in component INa_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,48) = strpad('k_I1C1 in component INa_channel_states (per_ms)');
LEGEND_ALGEBRAIC(:,52) = strpad('k_C1I1 in component INa_channel_states (per_ms)');
LEGEND_CONSTANTS(:,147) = strpad('phi in component temperature_factor (dimensionless)');
LEGEND_ALGEBRAIC(:,71) = strpad('E in component Nernst_potential (mV)');
LEGEND_ALGEBRAIC(:,77) = strpad('E in component Nernst_potential (mV)');
LEGEND_CONSTANTS(:,99) = strpad('R in component constants (J_per_K_mol)');
LEGEND_CONSTANTS(:,100) = strpad('F in component constants (C_per_mmol)');
LEGEND_CONSTANTS(:,101) = strpad('z_Ca in component constants (dimensionless)');
LEGEND_CONSTANTS(:,102) = strpad('z_Na in component constants (dimensionless)');
LEGEND_CONSTANTS(:,103) = strpad('z_K in component constants (dimensionless)');
LEGEND_CONSTANTS(:,104) = strpad('R in component constants (J_per_K_mol)');
LEGEND_CONSTANTS(:,105) = strpad('F in component constants (C_per_mmol)');
LEGEND_CONSTANTS(:,106) = strpad('z_Ca in component constants (dimensionless)');
LEGEND_CONSTANTS(:,107) = strpad('z_Na in component constants (dimensionless)');
LEGEND_CONSTANTS(:,108) = strpad('z_K in component constants (dimensionless)');
LEGEND_CONSTANTS(:,109) = strpad('R in component constants (J_per_K_mol)');
LEGEND_CONSTANTS(:,110) = strpad('F in component constants (C_per_mmol)');
LEGEND_CONSTANTS(:,111) = strpad('z_K in component constants (dimensionless)');
LEGEND_CONSTANTS(:,112) = strpad('z_Na in component constants (dimensionless)');
LEGEND_CONSTANTS(:,113) = strpad('z_Ca in component constants (dimensionless)');
LEGEND_CONSTANTS(:,114) = strpad('R in component constants (J_per_K_mol)');
LEGEND_CONSTANTS(:,115) = strpad('F in component constants (C_per_mmol)');
LEGEND_CONSTANTS(:,116) = strpad('z_K in component constants (dimensionless)');
LEGEND_CONSTANTS(:,117) = strpad('z_Na in component constants (dimensionless)');
LEGEND_CONSTANTS(:,118) = strpad('z_Ca in component constants (dimensionless)');
LEGEND_CONSTANTS(:,119) = strpad('R in component constants (J_per_K_mol)');
LEGEND_CONSTANTS(:,120) = strpad('F in component constants (C_per_mmol)');
LEGEND_CONSTANTS(:,121) = strpad('z_Na in component constants (dimensionless)');
LEGEND_CONSTANTS(:,122) = strpad('z_Ca in component constants (dimensionless)');
LEGEND_CONSTANTS(:,123) = strpad('z_K in component constants (dimensionless)');
LEGEND_CONSTANTS(:,124) = strpad('R in component constants (J_per_K_mol)');
LEGEND_CONSTANTS(:,125) = strpad('F in component constants (C_per_mmol)');
LEGEND_CONSTANTS(:,126) = strpad('z_Na in component constants (dimensionless)');
LEGEND_CONSTANTS(:,127) = strpad('z_Ca in component constants (dimensionless)');
LEGEND_CONSTANTS(:,128) = strpad('z_K in component constants (dimensionless)');
LEGEND_CONSTANTS(:,129) = strpad('R in component constants (J_per_K_mol)');
LEGEND_CONSTANTS(:,130) = strpad('F in component constants (C_per_mmol)');
LEGEND_CONSTANTS(:,131) = strpad('z_K in component constants (dimensionless)');
LEGEND_CONSTANTS(:,132) = strpad('z_Na in component constants (dimensionless)');
LEGEND_CONSTANTS(:,133) = strpad('z_Ca in component constants (dimensionless)');
LEGEND_RATES(:,1) = strpad('d/dt V in component Membrane_potential (mV)');
LEGEND_RATES(:,12) = strpad('d/dt Cai_total in component Cai (mM)');
LEGEND_RATES(:,2) = strpad('d/dt Cai in component Cai (mM)');
LEGEND_RATES(:,3) = strpad('d/dt Nai in component Nai (mM)');
LEGEND_RATES(:,4) = strpad('d/dt Ki in component Ki (mM)');
LEGEND_RATES(:,16) = strpad('d/dt C3 in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,15) = strpad('d/dt C2 in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,14) = strpad('d/dt C1 in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,13) = strpad('d/dt C0 in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,20) = strpad('d/dt C3Ca in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,19) = strpad('d/dt C2Ca in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,18) = strpad('d/dt C1Ca in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,17) = strpad('d/dt C0Ca in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,5) = strpad('d/dt O_CaL in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,21) = strpad('d/dt ICa in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,22) = strpad('d/dt IVs in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,23) = strpad('d/dt IVf in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,25) = strpad('d/dt IVsCa in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,24) = strpad('d/dt IVfCa in component ICaL_channel_states (dimensionless)');
LEGEND_RATES(:,8) = strpad('d/dt X in component gating_kinetics (dimensionless)');
LEGEND_RATES(:,9) = strpad('d/dt X in component gating_kinetics (dimensionless)');
LEGEND_RATES(:,10) = strpad('d/dt X in component gating_kinetics (dimensionless)');
LEGEND_RATES(:,11) = strpad('d/dt X in component gating_kinetics (dimensionless)');
LEGEND_RATES(:,30) = strpad('d/dt C4 in component IBK_channel_states (dimensionless)');
LEGEND_RATES(:,29) = strpad('d/dt C3 in component IBK_channel_states (dimensionless)');
LEGEND_RATES(:,28) = strpad('d/dt C2 in component IBK_channel_states (dimensionless)');
LEGEND_RATES(:,27) = strpad('d/dt C1 in component IBK_channel_states (dimensionless)');
LEGEND_RATES(:,26) = strpad('d/dt C0 in component IBK_channel_states (dimensionless)');
LEGEND_RATES(:,6) = strpad('d/dt O4 in component IBK_channel_states (dimensionless)');
LEGEND_RATES(:,34) = strpad('d/dt O3 in component IBK_channel_states (dimensionless)');
LEGEND_RATES(:,33) = strpad('d/dt O2 in component IBK_channel_states (dimensionless)');
LEGEND_RATES(:,32) = strpad('d/dt O1 in component IBK_channel_states (dimensionless)');
LEGEND_RATES(:,31) = strpad('d/dt O0 in component IBK_channel_states (dimensionless)');
LEGEND_RATES(:,37) = strpad('d/dt C3 in component INa_channel_states (dimensionless)');
LEGEND_RATES(:,36) = strpad('d/dt C2 in component INa_channel_states (dimensionless)');
LEGEND_RATES(:,35) = strpad('d/dt C1 in component INa_channel_states (dimensionless)');
LEGEND_RATES(:,7) = strpad('d/dt O_Na in component INa_channel_states (dimensionless)');
LEGEND_RATES(:,39) = strpad('d/dt I2 in component INa_channel_states (dimensionless)');
LEGEND_RATES(:,38) = strpad('d/dt I1 in component INa_channel_states (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 = [];
CONSTANTS(:,1) = 10000;
CONSTANTS(:,2) = -57;
CONSTANTS(:,3) = 33.5;
CONSTANTS(:,4) = 300;
CONSTANTS(:,5) = 600;
CONSTANTS(:,6) = 12000;
CONSTANTS(:,7) = 300;
CONSTANTS(:,8) = 2.6;
CONSTANTS(:,9) = 1.44;
CONSTANTS(:,10) = 1.0217;
CONSTANTS(:,11) = 80;
CONSTANTS(:,12) = 25.1;
CONSTANTS(:,13) = -73.5049651455872;
CONSTANTS(:,14) = 50;
CONSTANTS(:,15) = 8.314;
CONSTANTS(:,16) = 310;
CONSTANTS(:,17) = 96.48534;
CONSTANTS(:,18) = 310;
CONSTANTS(:,19) = 297;
CONSTANTS(:,20) = 2.1;
CONSTANTS(:,21) = 2;
CONSTANTS(:,22) = 0.815464741971086;
CONSTANTS(:,23) = 0.152399266235657;
CONSTANTS(:,24) = 0.0106805060777161;
CONSTANTS(:,25) = 0.000332673548872087;
CONSTANTS(:,26) = 0.0175888495282545;
CONSTANTS(:,27) = 0.00328711668724504;
CONSTANTS(:,28) = 0.000230369020877669;
CONSTANTS(:,29) = 7.1754726923539e-6;
CONSTANTS(:,30) = 8.38123983500905e-8;
CONSTANTS(:,31) = 1.1193313274705e-6;
CONSTANTS(:,32) = 4.0998751301597e-6;
CONSTANTS(:,33) = 8.84306615061238e-8;
CONSTANTS(:,34) = 2.41429816075123e-8;
CONSTANTS(:,35) = 3.88576045134351e-6;
CONSTANTS(:,36) = 0.0425;
CONSTANTS(:,37) = 0.0791635737410974;
CONSTANTS(:,38) = 0.377831534375835;
CONSTANTS(:,39) = 1.9508;
CONSTANTS(:,40) = 297;
CONSTANTS(:,41) = 3.1;
CONSTANTS(:,42) = 5.4;
CONSTANTS(:,43) = 0.14714161078933;
CONSTANTS(:,44) = 0.99994773314105;
CONSTANTS(:,45) = 4.7803;
CONSTANTS(:,46) = 763.7564;
CONSTANTS(:,47) = 0.48379087935899;
CONSTANTS(:,48) = 0.385183559520031;
CONSTANTS(:,49) = 0.115002824567753;
CONSTANTS(:,50) = 0.0152602714149774;
CONSTANTS(:,51) = 0.000759264410974374;
CONSTANTS(:,52) = 6.94960798375172e-7;
CONSTANTS(:,53) = 5.55636826398253e-8;
CONSTANTS(:,54) = 2.85143702125325e-8;
CONSTANTS(:,55) = 1.59832806123435e-6;
CONSTANTS(:,56) = 1.82113764497095e-6;
CONSTANTS(:,57) = 40633;
CONSTANTS(:,58) = 11;
CONSTANTS(:,59) = 1.1;
CONSTANTS(:,60) = 297;
CONSTANTS(:,61) = 2.45;
CONSTANTS(:,62) = 140;
CONSTANTS(:,63) = 0.0119443135223679;
CONSTANTS(:,64) = 0.0109545368437155;
CONSTANTS(:,65) = 0.973782548650071;
CONSTANTS(:,66) = 0.000126882921013389;
CONSTANTS(:,67) = 0.00318975045717667;
CONSTANTS(:,68) = 1.96760342050475e-6;
CONSTANTS(:,69) = 1.38;
CONSTANTS(:,70) = 87.5;
CONSTANTS(:,71) = 0.1;
CONSTANTS(:,72) = 0.35;
CONSTANTS(:,73) = 1992.1865;
CONSTANTS(:,74) = 1;
CONSTANTS(:,75) = 40;
CONSTANTS(:,76) = 16.197;
CONSTANTS(:,77) = 0.022488;
CONSTANTS(:,78) = 0.017512;
CONSTANTS(:,79) = 1;
CONSTANTS(:,80) = 4;
CONSTANTS(:,81) = 0.034;
CONSTANTS(:,82) = 0.012;
CONSTANTS(:,83) = 0.0009;
CONSTANTS(:,84) = 0.0001;
CONSTANTS(:,85) = 3.5e-12;
CONSTANTS(:,86) = 0.004914;
CONSTANTS(:,87) = 5.38843941249284e-5;
CONSTANTS(:,88) = 10.5731241425458;
CONSTANTS(:,89) = 153.604280337996;
CONSTANTS(:,90) = 1.44;
CONSTANTS(:,91) = 1.0217;
CONSTANTS(:,92) = 80;
CONSTANTS(:,93) = 25.1;
CONSTANTS(:,94) = 1;
CONSTANTS(:,95) = 1;
CONSTANTS(:,96) = 1e-15;
CONSTANTS(:,97) = 1e-15;
CONSTANTS(:,98) = 1e-15;
CONSTANTS(:,99) = 8.314;
CONSTANTS(:,100) = 96.48534;
CONSTANTS(:,101) = 2;
CONSTANTS(:,102) = 1;
CONSTANTS(:,103) = 1;
CONSTANTS(:,104) = 8.314;
CONSTANTS(:,105) = 96.48534;
CONSTANTS(:,106) = 2;
CONSTANTS(:,107) = 1;
CONSTANTS(:,108) = 1;
CONSTANTS(:,109) = 8.314;
CONSTANTS(:,110) = 96.48534;
CONSTANTS(:,111) = 1;
CONSTANTS(:,112) = 1;
CONSTANTS(:,113) = 2;
CONSTANTS(:,114) = 8.314;
CONSTANTS(:,115) = 96.48534;
CONSTANTS(:,116) = 1;
CONSTANTS(:,117) = 1;
CONSTANTS(:,118) = 2;
CONSTANTS(:,119) = 8.314;
CONSTANTS(:,120) = 96.48534;
CONSTANTS(:,121) = 1;
CONSTANTS(:,122) = 2;
CONSTANTS(:,123) = 1;
CONSTANTS(:,124) = 8.314;
CONSTANTS(:,125) = 96.48534;
CONSTANTS(:,126) = 1;
CONSTANTS(:,127) = 2;
CONSTANTS(:,128) = 1;
CONSTANTS(:,129) = 8.314;
CONSTANTS(:,130) = 96.48534;
CONSTANTS(:,131) = 1;
CONSTANTS(:,132) = 1;
CONSTANTS(:,133) = 2;
CONSTANTS(:,134) = power(CONSTANTS(:,20), (CONSTANTS(:,16) - CONSTANTS(:,18))./10.0000);
CONSTANTS(:,135) = power(CONSTANTS(:,20), (CONSTANTS(:,16) - CONSTANTS(:,19))./10.0000);
CONSTANTS(:,136) = power(CONSTANTS(:,20), (CONSTANTS(:,16) - CONSTANTS(:,19))./10.0000);
CONSTANTS(:,137) = power(CONSTANTS(:,41), (CONSTANTS(:,16) - CONSTANTS(:,40))./10.0000);
CONSTANTS(:,138) = power(CONSTANTS(:,41), (CONSTANTS(:,16) - CONSTANTS(:,40))./10.0000);
CONSTANTS(:,139) =  4.00000.*CONSTANTS(:,58);
CONSTANTS(:,140) =  3.00000.*CONSTANTS(:,58);
CONSTANTS(:,141) =  2.00000.*CONSTANTS(:,58);
CONSTANTS(:,142) =  1.00000.*CONSTANTS(:,58);
CONSTANTS(:,143) =  4.00000.*CONSTANTS(:,59);
CONSTANTS(:,144) =  3.00000.*CONSTANTS(:,59);
CONSTANTS(:,145) =  2.00000.*CONSTANTS(:,59);
CONSTANTS(:,146) =  1.00000.*CONSTANTS(:,59);
CONSTANTS(:,147) = power(CONSTANTS(:,61), (CONSTANTS(:,16) - CONSTANTS(:,60))./10.0000);
CONSTANTS(:,148) =  CONSTANTS(:,134).*0.0100000;
STATES(:,1) = CONSTANTS(:,13);
STATES(:,2) = CONSTANTS(:,87);
STATES(:,3) = CONSTANTS(:,88);
STATES(:,4) = CONSTANTS(:,89);
STATES(:,5) = CONSTANTS(:,35);
STATES(:,6) = CONSTANTS(:,56);
STATES(:,7) = CONSTANTS(:,68);
STATES(:,8) = CONSTANTS(:,37);
STATES(:,9) = CONSTANTS(:,38);
STATES(:,10) = CONSTANTS(:,43);
STATES(:,11) = CONSTANTS(:,44);
STATES(:,12) = CONSTANTS(:,86);
STATES(:,13) = CONSTANTS(:,22);
STATES(:,14) = CONSTANTS(:,23);
STATES(:,15) = CONSTANTS(:,24);
STATES(:,16) = CONSTANTS(:,25);
STATES(:,17) = CONSTANTS(:,26);
STATES(:,18) = CONSTANTS(:,27);
STATES(:,19) = CONSTANTS(:,28);
STATES(:,20) = CONSTANTS(:,29);
STATES(:,21) = CONSTANTS(:,30);
STATES(:,22) = CONSTANTS(:,31);
STATES(:,23) = CONSTANTS(:,32);
STATES(:,24) = CONSTANTS(:,33);
STATES(:,25) = CONSTANTS(:,33);
STATES(:,26) = CONSTANTS(:,47);
STATES(:,27) = CONSTANTS(:,48);
STATES(:,28) = CONSTANTS(:,49);
STATES(:,29) = CONSTANTS(:,50);
STATES(:,30) = CONSTANTS(:,51);
STATES(:,31) = CONSTANTS(:,52);
STATES(:,32) = CONSTANTS(:,53);
STATES(:,33) = CONSTANTS(:,54);
STATES(:,34) = CONSTANTS(:,55);
STATES(:,35) = CONSTANTS(:,63);
STATES(:,36) = CONSTANTS(:,64);
STATES(:,37) = CONSTANTS(:,65);
STATES(:,38) = CONSTANTS(:,66);
STATES(:,39) = CONSTANTS(:,67);
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(:,3) = 1.00000./(1.00000+exp( - (STATES(:,1)+60.5000)./5.30000));
RATES(:,8) =  ((ALGEBRAIC(:,3) - STATES(:,8))./CONSTANTS(:,39)).*CONSTANTS(:,135);
ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1)+43.0000)./17.3600));
RATES(:,10) =  ((ALGEBRAIC(:,5) - STATES(:,10))./CONSTANTS(:,45)).*CONSTANTS(:,137);
ALGEBRAIC(:,6) = 1.00000./(1.00000+exp((STATES(:,1) - 44.9000)./12.0096));
RATES(:,11) =  ((ALGEBRAIC(:,6) - STATES(:,11))./CONSTANTS(:,46)).*CONSTANTS(:,138);
ALGEBRAIC(:,4) = 1.00000./(1.00000+exp((STATES(:,1)+75.5000)./4.00000));
ALGEBRAIC(:,11) =  0.381170.*(8.60000+ 14.7000.*exp( - power(STATES(:,1)+50.0000, 2.00000)./( 900.000.*1.00000)));
RATES(:,9) =  ((ALGEBRAIC(:,4) - STATES(:,9))./ALGEBRAIC(:,11)).*CONSTANTS(:,136);
ALGEBRAIC(:,34) =  (( CONSTANTS(:,99).*CONSTANTS(:,16))./( CONSTANTS(:,101).*CONSTANTS(:,100))).*log(CONSTANTS(:,21)./STATES(:,2));
ALGEBRAIC(:,38) =  CONSTANTS(:,9).*STATES(:,5).*(STATES(:,1) - ALGEBRAIC(:,34));
ALGEBRAIC(:,18) =  STATES(:,8).*STATES(:,9);
ALGEBRAIC(:,42) =  (( CONSTANTS(:,104).*CONSTANTS(:,16))./( CONSTANTS(:,106).*CONSTANTS(:,105))).*log(CONSTANTS(:,21)./STATES(:,2));
ALGEBRAIC(:,46) =  CONSTANTS(:,36).*ALGEBRAIC(:,18).*(STATES(:,1) - ALGEBRAIC(:,42));
ALGEBRAIC(:,26) = ( CONSTANTS(:,73).*( exp(( CONSTANTS(:,72).*STATES(:,1).*CONSTANTS(:,17))./( CONSTANTS(:,15).*CONSTANTS(:,16))).*power(STATES(:,3), 3.00000).*CONSTANTS(:,21) -  2.50000.*exp(( (CONSTANTS(:,72) - 1.00000).*STATES(:,1).*CONSTANTS(:,17))./( CONSTANTS(:,15).*CONSTANTS(:,16))).*power(CONSTANTS(:,62), 3.00000).*STATES(:,2)))./( (power(CONSTANTS(:,70), 3.00000)+power(CONSTANTS(:,62), 3.00000)).*(CONSTANTS(:,69)+CONSTANTS(:,21)).*(1.00000+ CONSTANTS(:,71).*exp(( (CONSTANTS(:,72) - 1.00000).*STATES(:,1).*CONSTANTS(:,17))./( CONSTANTS(:,15).*CONSTANTS(:,16)))));
RATES(:,12) = (  - ((ALGEBRAIC(:,38)+ALGEBRAIC(:,46)) -  2.00000.*ALGEBRAIC(:,26)).*CONSTANTS(:,96))./( 2.00000.*CONSTANTS(:,17).*CONSTANTS(:,85));
ALGEBRAIC(:,53) = (  - ((ALGEBRAIC(:,38)+ALGEBRAIC(:,46)) -  2.00000.*ALGEBRAIC(:,26)).*CONSTANTS(:,96))./( 2.00000.*CONSTANTS(:,17).*CONSTANTS(:,85));
RATES(:,2) = ALGEBRAIC(:,53)./(1.00000+( CONSTANTS(:,79).*CONSTANTS(:,81).*CONSTANTS(:,83).*power(STATES(:,2), CONSTANTS(:,79) - 1.00000))./power(power(STATES(:,2), CONSTANTS(:,79))+CONSTANTS(:,83), 2.00000)+( CONSTANTS(:,80).*CONSTANTS(:,82).*CONSTANTS(:,84).*power(STATES(:,2), CONSTANTS(:,80) - 1.00000))./power(power(STATES(:,2), CONSTANTS(:,80))+CONSTANTS(:,84), 2.00000));
ALGEBRAIC(:,57) = STATES(:,7)+STATES(:,35)+STATES(:,36)+STATES(:,37)+STATES(:,38)+STATES(:,39);
ALGEBRAIC(:,25) =  CONSTANTS(:,147).*0.554320.*exp( - 0.0990740+ 0.0364410.*STATES(:,1));
ALGEBRAIC(:,29) =  CONSTANTS(:,147).*0.000525480.*exp( - 0.0691020+ 0.00319450.*STATES(:,1));
RATES(:,37) = (  - ALGEBRAIC(:,29).*STATES(:,37))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,25).*STATES(:,36))./ALGEBRAIC(:,57);
ALGEBRAIC(:,21) =  CONSTANTS(:,147).*3.15660.*exp(0.363520+ 0.0771930.*STATES(:,1));
ALGEBRAIC(:,31) =  CONSTANTS(:,147).*1.44960.*exp( - 0.156600+ 0.0583530.*STATES(:,1));
RATES(:,36) = (  - (ALGEBRAIC(:,31)+ALGEBRAIC(:,25)).*STATES(:,36))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,21).*STATES(:,35))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,29).*STATES(:,37))./ALGEBRAIC(:,57);
ALGEBRAIC(:,17) =  CONSTANTS(:,147).*2.39100.*exp( - 13.3350 -  0.252890.*STATES(:,1));
ALGEBRAIC(:,36) =  CONSTANTS(:,147).*1.53290.*exp(0.00931930+ 0.0410750.*STATES(:,1));
ALGEBRAIC(:,48) =  CONSTANTS(:,147).*1.90460.*exp( - 2.48400+ 0.0204060.*STATES(:,1));
ALGEBRAIC(:,52) =  CONSTANTS(:,147).*0.000216880.*exp( - 0.0634380+ 0.00466830.*STATES(:,1));
RATES(:,35) = (  - (ALGEBRAIC(:,21)+ALGEBRAIC(:,36)+ALGEBRAIC(:,52)).*STATES(:,35))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,17).*STATES(:,7))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,31).*STATES(:,36))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,48).*STATES(:,38))./ALGEBRAIC(:,57);
ALGEBRAIC(:,13) =  CONSTANTS(:,147).*0.120520.*exp( - 9.60280+ 0.0830250.*STATES(:,1));
ALGEBRAIC(:,40) =  CONSTANTS(:,147).*1.61640.*exp(0.307630+ 0.00605350.*STATES(:,1));
RATES(:,7) = (  - (ALGEBRAIC(:,17)+ALGEBRAIC(:,40)).*STATES(:,7))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,36).*STATES(:,35))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,13).*STATES(:,38))./ALGEBRAIC(:,57);
ALGEBRAIC(:,8) =  CONSTANTS(:,147).*0.00392390.*exp(2.67930+ 0.00614680.*STATES(:,1));
ALGEBRAIC(:,44) =  CONSTANTS(:,147).*0.0277350.*exp(0.0514900 -  0.0468650.*STATES(:,1));
RATES(:,39) = (  - ALGEBRAIC(:,8).*STATES(:,39))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,44).*STATES(:,38))./ALGEBRAIC(:,57);
RATES(:,38) = (  - (ALGEBRAIC(:,13)+ALGEBRAIC(:,44)+ALGEBRAIC(:,48)).*STATES(:,38))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,8).*STATES(:,39))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,52).*STATES(:,35))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,40).*STATES(:,7))./ALGEBRAIC(:,57);
ALGEBRAIC(:,65) =  (( CONSTANTS(:,119).*CONSTANTS(:,16))./( CONSTANTS(:,121).*CONSTANTS(:,120))).*log(CONSTANTS(:,62)./STATES(:,3));
ALGEBRAIC(:,68) =  CONSTANTS(:,12).*STATES(:,7).*(STATES(:,1) - ALGEBRAIC(:,65));
ALGEBRAIC(:,30) = ( CONSTANTS(:,76).*CONSTANTS(:,42).*STATES(:,3))./( (CONSTANTS(:,42)+CONSTANTS(:,74)).*(CONSTANTS(:,75)+STATES(:,3)).*(1.00000+ 0.124500.*exp((  - 0.100000.*STATES(:,1).*CONSTANTS(:,17))./( CONSTANTS(:,15).*CONSTANTS(:,16)))+ 0.0353000.*exp((  - STATES(:,1).*CONSTANTS(:,17))./( CONSTANTS(:,15).*CONSTANTS(:,16)))));
ALGEBRAIC(:,71) =  (( CONSTANTS(:,124).*CONSTANTS(:,16))./( CONSTANTS(:,126).*CONSTANTS(:,125))).*log(CONSTANTS(:,62)./STATES(:,3));
ALGEBRAIC(:,74) =  CONSTANTS(:,77).*CONSTANTS(:,94).*(STATES(:,1) - ALGEBRAIC(:,71));
RATES(:,3) = (  - (ALGEBRAIC(:,68)+ 3.00000.*ALGEBRAIC(:,30)+ 3.00000.*ALGEBRAIC(:,26)+ALGEBRAIC(:,74)).*CONSTANTS(:,97))./( CONSTANTS(:,17).*CONSTANTS(:,85));
ALGEBRAIC(:,1) =  rem(VOI, CONSTANTS(:,1));
ALGEBRAIC(:,9) = piecewise({ALGEBRAIC(:,1)<CONSTANTS(:,4), CONSTANTS(:,2)+( CONSTANTS(:,3).*ALGEBRAIC(:,1))./CONSTANTS(:,7) }, CONSTANTS(:,2)+( CONSTANTS(:,3).*(1.00000+exp( - CONSTANTS(:,6)./( 2.00000.*CONSTANTS(:,5)))))./(1.00000+exp(((ALGEBRAIC(:,1) - CONSTANTS(:,7)) -  0.500000.*CONSTANTS(:,6))./CONSTANTS(:,5))));
ALGEBRAIC(:,14) =  CONSTANTS(:,8).*(STATES(:,1) - ALGEBRAIC(:,9));
ALGEBRAIC(:,22) =  STATES(:,10).*STATES(:,11);
ALGEBRAIC(:,50) =  (( CONSTANTS(:,109).*CONSTANTS(:,16))./( CONSTANTS(:,111).*CONSTANTS(:,110))).*log(CONSTANTS(:,42)./STATES(:,4));
ALGEBRAIC(:,55) =  CONSTANTS(:,10).*ALGEBRAIC(:,22).*(STATES(:,1) - ALGEBRAIC(:,50));
ALGEBRAIC(:,59) =  (( CONSTANTS(:,114).*CONSTANTS(:,16))./( CONSTANTS(:,116).*CONSTANTS(:,115))).*log(CONSTANTS(:,42)./STATES(:,4));
ALGEBRAIC(:,62) =  CONSTANTS(:,11).*STATES(:,6).*(STATES(:,1) - ALGEBRAIC(:,59));
ALGEBRAIC(:,77) =  (( CONSTANTS(:,129).*CONSTANTS(:,16))./( CONSTANTS(:,131).*CONSTANTS(:,130))).*log(CONSTANTS(:,42)./STATES(:,4));
ALGEBRAIC(:,80) =  CONSTANTS(:,78).*CONSTANTS(:,95).*(STATES(:,1) - ALGEBRAIC(:,77));
RATES(:,4) = (  - (((ALGEBRAIC(:,55)+ALGEBRAIC(:,62)+ALGEBRAIC(:,14)) -  2.00000.*ALGEBRAIC(:,30))+ALGEBRAIC(:,80)).*CONSTANTS(:,98))./( CONSTANTS(:,17).*CONSTANTS(:,85));
ALGEBRAIC(:,82) = STATES(:,26)+STATES(:,27)+STATES(:,28)+STATES(:,29)+STATES(:,30)+STATES(:,31)+STATES(:,32)+STATES(:,33)+STATES(:,34)+STATES(:,6);
ALGEBRAIC(:,7) =  1.00000.*exp(( 8.47188.*STATES(:,1))./( 1.00000.*CONSTANTS(:,16)));
ALGEBRAIC(:,33) =  0.0443240.*ALGEBRAIC(:,7);
ALGEBRAIC(:,12) =  1.00000.*exp((  - 7.77556.*STATES(:,1))./( 1.00000.*CONSTANTS(:,16)));
ALGEBRAIC(:,51) =  0.000106000.*ALGEBRAIC(:,12);
ALGEBRAIC(:,66) =  1.00000.*CONSTANTS(:,57).*STATES(:,2);
RATES(:,30) = (  - (CONSTANTS(:,139)+ALGEBRAIC(:,33)).*STATES(:,30))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,66).*STATES(:,29))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,51).*STATES(:,6))./ALGEBRAIC(:,82);
ALGEBRAIC(:,28) =  0.000781000.*ALGEBRAIC(:,7);
ALGEBRAIC(:,47) =  0.0953120.*ALGEBRAIC(:,12);
ALGEBRAIC(:,63) =  2.00000.*CONSTANTS(:,57).*STATES(:,2);
RATES(:,29) = (  - (CONSTANTS(:,140)+ALGEBRAIC(:,28)+ALGEBRAIC(:,66)).*STATES(:,29))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,63).*STATES(:,28))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,47).*STATES(:,34))./ALGEBRAIC(:,82)+( CONSTANTS(:,139).*STATES(:,30))./ALGEBRAIC(:,82);
ALGEBRAIC(:,24) =  2.81000e-05.*ALGEBRAIC(:,7);
ALGEBRAIC(:,43) =  32.6594.*ALGEBRAIC(:,12);
ALGEBRAIC(:,60) =  3.00000.*CONSTANTS(:,57).*STATES(:,2);
RATES(:,28) = (  - (CONSTANTS(:,141)+ALGEBRAIC(:,24)+ALGEBRAIC(:,63)).*STATES(:,28))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,60).*STATES(:,27))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,43).*STATES(:,33))./ALGEBRAIC(:,82)+( CONSTANTS(:,140).*STATES(:,29))./ALGEBRAIC(:,82);
ALGEBRAIC(:,20) =  0.000869000.*ALGEBRAIC(:,7);
ALGEBRAIC(:,39) =  144.174.*ALGEBRAIC(:,12);
ALGEBRAIC(:,56) =  4.00000.*CONSTANTS(:,57).*STATES(:,2);
RATES(:,27) = (  - (CONSTANTS(:,142)+ALGEBRAIC(:,20)+ALGEBRAIC(:,60)).*STATES(:,27))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,56).*STATES(:,26))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,39).*STATES(:,32))./ALGEBRAIC(:,82)+( CONSTANTS(:,141).*STATES(:,28))./ALGEBRAIC(:,82);
ALGEBRAIC(:,16) =  0.0216200.*ALGEBRAIC(:,7);
ALGEBRAIC(:,35) =  318.108.*ALGEBRAIC(:,12);
RATES(:,26) = (  - (ALGEBRAIC(:,56)+ALGEBRAIC(:,16)).*STATES(:,26))./ALGEBRAIC(:,82)+( CONSTANTS(:,142).*STATES(:,27))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,35).*STATES(:,31))./ALGEBRAIC(:,82);
ALGEBRAIC(:,79) =  1.00000.*CONSTANTS(:,57).*STATES(:,2);
RATES(:,6) = (  - (CONSTANTS(:,143)+ALGEBRAIC(:,51)).*STATES(:,6))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,79).*STATES(:,34))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,33).*STATES(:,30))./ALGEBRAIC(:,82);
ALGEBRAIC(:,76) =  2.00000.*CONSTANTS(:,57).*STATES(:,2);
RATES(:,34) = (  - (CONSTANTS(:,144)+ALGEBRAIC(:,47)+ALGEBRAIC(:,79)).*STATES(:,34))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,76).*STATES(:,33))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,28).*STATES(:,29))./ALGEBRAIC(:,82)+( CONSTANTS(:,143).*STATES(:,6))./ALGEBRAIC(:,82);
ALGEBRAIC(:,73) =  3.00000.*CONSTANTS(:,57).*STATES(:,2);
RATES(:,33) = (  - (CONSTANTS(:,145)+ALGEBRAIC(:,43)+ALGEBRAIC(:,76)).*STATES(:,33))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,73).*STATES(:,32))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,24).*STATES(:,28))./ALGEBRAIC(:,82)+( CONSTANTS(:,144).*STATES(:,34))./ALGEBRAIC(:,82);
ALGEBRAIC(:,70) =  4.00000.*CONSTANTS(:,57).*STATES(:,2);
RATES(:,32) = (  - (CONSTANTS(:,146)+ALGEBRAIC(:,39)+ALGEBRAIC(:,73)).*STATES(:,32))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,70).*STATES(:,31))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,20).*STATES(:,27))./ALGEBRAIC(:,82)+( CONSTANTS(:,145).*STATES(:,33))./ALGEBRAIC(:,82);
RATES(:,31) = (  - (ALGEBRAIC(:,70)+ALGEBRAIC(:,35)).*STATES(:,31))./ALGEBRAIC(:,82)+( CONSTANTS(:,146).*STATES(:,32))./ALGEBRAIC(:,82)+( ALGEBRAIC(:,16).*STATES(:,26))./ALGEBRAIC(:,82);
ALGEBRAIC(:,83) = ALGEBRAIC(:,38)+ALGEBRAIC(:,46)+ALGEBRAIC(:,55)+ALGEBRAIC(:,62)+ALGEBRAIC(:,68)+ALGEBRAIC(:,26)+ALGEBRAIC(:,30)+ALGEBRAIC(:,74)+ALGEBRAIC(:,80);
RATES(:,1) =  - (ALGEBRAIC(:,14)+ALGEBRAIC(:,83))./CONSTANTS(:,14);
ALGEBRAIC(:,84) = STATES(:,16)+STATES(:,15)+STATES(:,14)+STATES(:,13)+STATES(:,20)+STATES(:,19)+STATES(:,18)+STATES(:,17)+STATES(:,5)+STATES(:,21)+STATES(:,22)+STATES(:,23)+STATES(:,25)+STATES(:,24);
ALGEBRAIC(:,2) =  CONSTANTS(:,134).*0.731000.*exp(STATES(:,1)./30.0000);
ALGEBRAIC(:,23) =  2.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,27) =  1.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,10) =  CONSTANTS(:,134).*0.214900.*exp( - STATES(:,1)./40.0000);
ALGEBRAIC(:,41) =  3.00000.*ALGEBRAIC(:,10);
ALGEBRAIC(:,45) =  4.00000.*ALGEBRAIC(:,10);
ALGEBRAIC(:,81) = ( CONSTANTS(:,134).*4.00000)./(1.00000+1.00000./STATES(:,2));
ALGEBRAIC(:,54) =  CONSTANTS(:,134).*0.00595600.*exp( - STATES(:,1)./40.0000);
ALGEBRAIC(:,49) =  CONSTANTS(:,134).*0.474200.*exp(STATES(:,1)./10.0000);
ALGEBRAIC(:,67) =  CONSTANTS(:,134).*0.00232000.*exp( - STATES(:,1)./280.000);
ALGEBRAIC(:,61) =  CONSTANTS(:,134).*0.0121300.*exp(STATES(:,1)./500.000);
ALGEBRAIC(:,72) = ( ALGEBRAIC(:,45).*ALGEBRAIC(:,61).*ALGEBRAIC(:,54))./( ALGEBRAIC(:,27).*ALGEBRAIC(:,67));
ALGEBRAIC(:,64) =  CONSTANTS(:,134).*0.0219700.*exp(STATES(:,1)./500.000);
ALGEBRAIC(:,58) =  CONSTANTS(:,134).*0.0140700.*exp( - STATES(:,1)./300.000);
ALGEBRAIC(:,69) = ( ALGEBRAIC(:,45).*ALGEBRAIC(:,58).*ALGEBRAIC(:,49))./( ALGEBRAIC(:,27).*ALGEBRAIC(:,64));
RATES(:,16) = (( ALGEBRAIC(:,23).*STATES(:,15))./ALGEBRAIC(:,84) - ( (ALGEBRAIC(:,27)+ALGEBRAIC(:,41)+ALGEBRAIC(:,54)+ALGEBRAIC(:,49)+ALGEBRAIC(:,81)).*STATES(:,16))./ALGEBRAIC(:,84))+( ALGEBRAIC(:,45).*STATES(:,5))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,69).*STATES(:,23))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,72).*STATES(:,22))./ALGEBRAIC(:,84)+( CONSTANTS(:,148).*STATES(:,20))./ALGEBRAIC(:,84);
ALGEBRAIC(:,19) =  3.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,37) =  2.00000.*ALGEBRAIC(:,10);
RATES(:,15) = (( ALGEBRAIC(:,19).*STATES(:,14))./ALGEBRAIC(:,84) - ( (ALGEBRAIC(:,23)+ALGEBRAIC(:,37)+ALGEBRAIC(:,81)).*STATES(:,15))./ALGEBRAIC(:,84))+( ALGEBRAIC(:,41).*STATES(:,16))./ALGEBRAIC(:,84)+( CONSTANTS(:,148).*STATES(:,19))./ALGEBRAIC(:,84);
ALGEBRAIC(:,15) =  4.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,32) =  1.00000.*ALGEBRAIC(:,10);
RATES(:,14) = (( ALGEBRAIC(:,15).*STATES(:,13))./ALGEBRAIC(:,84) - ( (ALGEBRAIC(:,19)+ALGEBRAIC(:,32)+ALGEBRAIC(:,81)).*STATES(:,14))./ALGEBRAIC(:,84))+( ALGEBRAIC(:,37).*STATES(:,15))./ALGEBRAIC(:,84)+( CONSTANTS(:,148).*STATES(:,18))./ALGEBRAIC(:,84);
RATES(:,13) = (  - (ALGEBRAIC(:,15)+ALGEBRAIC(:,81)).*STATES(:,13))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,32).*STATES(:,14))./ALGEBRAIC(:,84)+( CONSTANTS(:,148).*STATES(:,17))./ALGEBRAIC(:,84);
RATES(:,20) = ((( ALGEBRAIC(:,81).*STATES(:,16))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,23).*STATES(:,19))./ALGEBRAIC(:,84)) - ( (ALGEBRAIC(:,27)+ALGEBRAIC(:,41)+ALGEBRAIC(:,49)+ALGEBRAIC(:,54)+CONSTANTS(:,148)).*STATES(:,20))./ALGEBRAIC(:,84))+( ALGEBRAIC(:,45).*STATES(:,21))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,69).*STATES(:,24))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,72).*STATES(:,25))./ALGEBRAIC(:,84);
RATES(:,19) = ((( ALGEBRAIC(:,81).*STATES(:,15))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,19).*STATES(:,18))./ALGEBRAIC(:,84)) - ( (ALGEBRAIC(:,23)+ALGEBRAIC(:,37)+CONSTANTS(:,148)).*STATES(:,19))./ALGEBRAIC(:,84))+( ALGEBRAIC(:,41).*STATES(:,20))./ALGEBRAIC(:,84);
RATES(:,18) = ((( ALGEBRAIC(:,81).*STATES(:,14))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,15).*STATES(:,17))./ALGEBRAIC(:,84)) - ( (ALGEBRAIC(:,19)+ALGEBRAIC(:,32)+CONSTANTS(:,148)).*STATES(:,18))./ALGEBRAIC(:,84))+( ALGEBRAIC(:,37).*STATES(:,19))./ALGEBRAIC(:,84);
RATES(:,17) = (( ALGEBRAIC(:,81).*STATES(:,13))./ALGEBRAIC(:,84) - ( (ALGEBRAIC(:,15)+CONSTANTS(:,148)).*STATES(:,17))./ALGEBRAIC(:,84))+( ALGEBRAIC(:,32).*STATES(:,18))./ALGEBRAIC(:,84);
RATES(:,5) = (( ALGEBRAIC(:,27).*STATES(:,16))./ALGEBRAIC(:,84) - ( (ALGEBRAIC(:,45)+ALGEBRAIC(:,64)+ALGEBRAIC(:,67)+ALGEBRAIC(:,81)).*STATES(:,5))./ALGEBRAIC(:,84))+( ALGEBRAIC(:,58).*STATES(:,23))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,61).*STATES(:,22))./ALGEBRAIC(:,84)+( CONSTANTS(:,148).*STATES(:,21))./ALGEBRAIC(:,84);
RATES(:,21) = ((( ALGEBRAIC(:,81).*STATES(:,5))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,27).*STATES(:,20))./ALGEBRAIC(:,84)) - ( (ALGEBRAIC(:,45)+ALGEBRAIC(:,64)+ALGEBRAIC(:,67)+CONSTANTS(:,148)).*STATES(:,21))./ALGEBRAIC(:,84))+( ALGEBRAIC(:,58).*STATES(:,24))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,61).*STATES(:,25))./ALGEBRAIC(:,84);
ALGEBRAIC(:,78) = ALGEBRAIC(:,67);
ALGEBRAIC(:,75) = ( ALGEBRAIC(:,61).*ALGEBRAIC(:,64))./ALGEBRAIC(:,58);
RATES(:,22) = ((( ALGEBRAIC(:,54).*STATES(:,16))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,67).*STATES(:,5))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,78).*STATES(:,23))./ALGEBRAIC(:,84)) - ( (ALGEBRAIC(:,72)+ALGEBRAIC(:,61)+ALGEBRAIC(:,75)+ALGEBRAIC(:,81)).*STATES(:,22))./ALGEBRAIC(:,84))+( CONSTANTS(:,148).*STATES(:,25))./ALGEBRAIC(:,84);
RATES(:,23) = ((( ALGEBRAIC(:,49).*STATES(:,16))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,64).*STATES(:,5))./ALGEBRAIC(:,84)) - ( (ALGEBRAIC(:,69)+ALGEBRAIC(:,58)+ALGEBRAIC(:,78)+ALGEBRAIC(:,81)).*STATES(:,23))./ALGEBRAIC(:,84))+( ALGEBRAIC(:,75).*STATES(:,22))./ALGEBRAIC(:,84)+( CONSTANTS(:,148).*STATES(:,24))./ALGEBRAIC(:,84);
RATES(:,25) = (( ALGEBRAIC(:,81).*STATES(:,22))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,54).*STATES(:,20))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,67).*STATES(:,21))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,78).*STATES(:,24))./ALGEBRAIC(:,84)) - ( (ALGEBRAIC(:,72)+ALGEBRAIC(:,61)+ALGEBRAIC(:,75)+CONSTANTS(:,148)).*STATES(:,25))./ALGEBRAIC(:,84);
RATES(:,24) = ((( ALGEBRAIC(:,81).*STATES(:,23))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,49).*STATES(:,20))./ALGEBRAIC(:,84)+( ALGEBRAIC(:,64).*STATES(:,21))./ALGEBRAIC(:,84)) - ( (ALGEBRAIC(:,69)+ALGEBRAIC(:,58)+ALGEBRAIC(:,78)+CONSTANTS(:,148)).*STATES(:,24))./ALGEBRAIC(:,84))+( ALGEBRAIC(:,75).*STATES(:,25))./ALGEBRAIC(:,84);
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(:,3) = 1.00000./(1.00000+exp( - (STATES(:,1)+60.5000)./5.30000));
ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1)+43.0000)./17.3600));
ALGEBRAIC(:,6) = 1.00000./(1.00000+exp((STATES(:,1) - 44.9000)./12.0096));
ALGEBRAIC(:,4) = 1.00000./(1.00000+exp((STATES(:,1)+75.5000)./4.00000));
ALGEBRAIC(:,11) =  0.381170.*(8.60000+ 14.7000.*exp( - power(STATES(:,1)+50.0000, 2.00000)./( 900.000.*1.00000)));
ALGEBRAIC(:,34) =  (( CONSTANTS(:,99).*CONSTANTS(:,16))./( CONSTANTS(:,101).*CONSTANTS(:,100))).*log(CONSTANTS(:,21)./STATES(:,2));
ALGEBRAIC(:,38) =  CONSTANTS(:,9).*STATES(:,5).*(STATES(:,1) - ALGEBRAIC(:,34));
ALGEBRAIC(:,18) =  STATES(:,8).*STATES(:,9);
ALGEBRAIC(:,42) =  (( CONSTANTS(:,104).*CONSTANTS(:,16))./( CONSTANTS(:,106).*CONSTANTS(:,105))).*log(CONSTANTS(:,21)./STATES(:,2));
ALGEBRAIC(:,46) =  CONSTANTS(:,36).*ALGEBRAIC(:,18).*(STATES(:,1) - ALGEBRAIC(:,42));
ALGEBRAIC(:,26) = ( CONSTANTS(:,73).*( exp(( CONSTANTS(:,72).*STATES(:,1).*CONSTANTS(:,17))./( CONSTANTS(:,15).*CONSTANTS(:,16))).*power(STATES(:,3), 3.00000).*CONSTANTS(:,21) -  2.50000.*exp(( (CONSTANTS(:,72) - 1.00000).*STATES(:,1).*CONSTANTS(:,17))./( CONSTANTS(:,15).*CONSTANTS(:,16))).*power(CONSTANTS(:,62), 3.00000).*STATES(:,2)))./( (power(CONSTANTS(:,70), 3.00000)+power(CONSTANTS(:,62), 3.00000)).*(CONSTANTS(:,69)+CONSTANTS(:,21)).*(1.00000+ CONSTANTS(:,71).*exp(( (CONSTANTS(:,72) - 1.00000).*STATES(:,1).*CONSTANTS(:,17))./( CONSTANTS(:,15).*CONSTANTS(:,16)))));
ALGEBRAIC(:,53) = (  - ((ALGEBRAIC(:,38)+ALGEBRAIC(:,46)) -  2.00000.*ALGEBRAIC(:,26)).*CONSTANTS(:,96))./( 2.00000.*CONSTANTS(:,17).*CONSTANTS(:,85));
ALGEBRAIC(:,57) = STATES(:,7)+STATES(:,35)+STATES(:,36)+STATES(:,37)+STATES(:,38)+STATES(:,39);
ALGEBRAIC(:,25) =  CONSTANTS(:,147).*0.554320.*exp( - 0.0990740+ 0.0364410.*STATES(:,1));
ALGEBRAIC(:,29) =  CONSTANTS(:,147).*0.000525480.*exp( - 0.0691020+ 0.00319450.*STATES(:,1));
ALGEBRAIC(:,21) =  CONSTANTS(:,147).*3.15660.*exp(0.363520+ 0.0771930.*STATES(:,1));
ALGEBRAIC(:,31) =  CONSTANTS(:,147).*1.44960.*exp( - 0.156600+ 0.0583530.*STATES(:,1));
ALGEBRAIC(:,17) =  CONSTANTS(:,147).*2.39100.*exp( - 13.3350 -  0.252890.*STATES(:,1));
ALGEBRAIC(:,36) =  CONSTANTS(:,147).*1.53290.*exp(0.00931930+ 0.0410750.*STATES(:,1));
ALGEBRAIC(:,48) =  CONSTANTS(:,147).*1.90460.*exp( - 2.48400+ 0.0204060.*STATES(:,1));
ALGEBRAIC(:,52) =  CONSTANTS(:,147).*0.000216880.*exp( - 0.0634380+ 0.00466830.*STATES(:,1));
ALGEBRAIC(:,13) =  CONSTANTS(:,147).*0.120520.*exp( - 9.60280+ 0.0830250.*STATES(:,1));
ALGEBRAIC(:,40) =  CONSTANTS(:,147).*1.61640.*exp(0.307630+ 0.00605350.*STATES(:,1));
ALGEBRAIC(:,8) =  CONSTANTS(:,147).*0.00392390.*exp(2.67930+ 0.00614680.*STATES(:,1));
ALGEBRAIC(:,44) =  CONSTANTS(:,147).*0.0277350.*exp(0.0514900 -  0.0468650.*STATES(:,1));
ALGEBRAIC(:,65) =  (( CONSTANTS(:,119).*CONSTANTS(:,16))./( CONSTANTS(:,121).*CONSTANTS(:,120))).*log(CONSTANTS(:,62)./STATES(:,3));
ALGEBRAIC(:,68) =  CONSTANTS(:,12).*STATES(:,7).*(STATES(:,1) - ALGEBRAIC(:,65));
ALGEBRAIC(:,30) = ( CONSTANTS(:,76).*CONSTANTS(:,42).*STATES(:,3))./( (CONSTANTS(:,42)+CONSTANTS(:,74)).*(CONSTANTS(:,75)+STATES(:,3)).*(1.00000+ 0.124500.*exp((  - 0.100000.*STATES(:,1).*CONSTANTS(:,17))./( CONSTANTS(:,15).*CONSTANTS(:,16)))+ 0.0353000.*exp((  - STATES(:,1).*CONSTANTS(:,17))./( CONSTANTS(:,15).*CONSTANTS(:,16)))));
ALGEBRAIC(:,71) =  (( CONSTANTS(:,124).*CONSTANTS(:,16))./( CONSTANTS(:,126).*CONSTANTS(:,125))).*log(CONSTANTS(:,62)./STATES(:,3));
ALGEBRAIC(:,74) =  CONSTANTS(:,77).*CONSTANTS(:,94).*(STATES(:,1) - ALGEBRAIC(:,71));
ALGEBRAIC(:,1) =  rem(VOI, CONSTANTS(:,1));
ALGEBRAIC(:,9) = piecewise({ALGEBRAIC(:,1)<CONSTANTS(:,4), CONSTANTS(:,2)+( CONSTANTS(:,3).*ALGEBRAIC(:,1))./CONSTANTS(:,7) }, CONSTANTS(:,2)+( CONSTANTS(:,3).*(1.00000+exp( - CONSTANTS(:,6)./( 2.00000.*CONSTANTS(:,5)))))./(1.00000+exp(((ALGEBRAIC(:,1) - CONSTANTS(:,7)) -  0.500000.*CONSTANTS(:,6))./CONSTANTS(:,5))));
ALGEBRAIC(:,14) =  CONSTANTS(:,8).*(STATES(:,1) - ALGEBRAIC(:,9));
ALGEBRAIC(:,22) =  STATES(:,10).*STATES(:,11);
ALGEBRAIC(:,50) =  (( CONSTANTS(:,109).*CONSTANTS(:,16))./( CONSTANTS(:,111).*CONSTANTS(:,110))).*log(CONSTANTS(:,42)./STATES(:,4));
ALGEBRAIC(:,55) =  CONSTANTS(:,10).*ALGEBRAIC(:,22).*(STATES(:,1) - ALGEBRAIC(:,50));
ALGEBRAIC(:,59) =  (( CONSTANTS(:,114).*CONSTANTS(:,16))./( CONSTANTS(:,116).*CONSTANTS(:,115))).*log(CONSTANTS(:,42)./STATES(:,4));
ALGEBRAIC(:,62) =  CONSTANTS(:,11).*STATES(:,6).*(STATES(:,1) - ALGEBRAIC(:,59));
ALGEBRAIC(:,77) =  (( CONSTANTS(:,129).*CONSTANTS(:,16))./( CONSTANTS(:,131).*CONSTANTS(:,130))).*log(CONSTANTS(:,42)./STATES(:,4));
ALGEBRAIC(:,80) =  CONSTANTS(:,78).*CONSTANTS(:,95).*(STATES(:,1) - ALGEBRAIC(:,77));
ALGEBRAIC(:,82) = STATES(:,26)+STATES(:,27)+STATES(:,28)+STATES(:,29)+STATES(:,30)+STATES(:,31)+STATES(:,32)+STATES(:,33)+STATES(:,34)+STATES(:,6);
ALGEBRAIC(:,7) =  1.00000.*exp(( 8.47188.*STATES(:,1))./( 1.00000.*CONSTANTS(:,16)));
ALGEBRAIC(:,33) =  0.0443240.*ALGEBRAIC(:,7);
ALGEBRAIC(:,12) =  1.00000.*exp((  - 7.77556.*STATES(:,1))./( 1.00000.*CONSTANTS(:,16)));
ALGEBRAIC(:,51) =  0.000106000.*ALGEBRAIC(:,12);
ALGEBRAIC(:,66) =  1.00000.*CONSTANTS(:,57).*STATES(:,2);
ALGEBRAIC(:,28) =  0.000781000.*ALGEBRAIC(:,7);
ALGEBRAIC(:,47) =  0.0953120.*ALGEBRAIC(:,12);
ALGEBRAIC(:,63) =  2.00000.*CONSTANTS(:,57).*STATES(:,2);
ALGEBRAIC(:,24) =  2.81000e-05.*ALGEBRAIC(:,7);
ALGEBRAIC(:,43) =  32.6594.*ALGEBRAIC(:,12);
ALGEBRAIC(:,60) =  3.00000.*CONSTANTS(:,57).*STATES(:,2);
ALGEBRAIC(:,20) =  0.000869000.*ALGEBRAIC(:,7);
ALGEBRAIC(:,39) =  144.174.*ALGEBRAIC(:,12);
ALGEBRAIC(:,56) =  4.00000.*CONSTANTS(:,57).*STATES(:,2);
ALGEBRAIC(:,16) =  0.0216200.*ALGEBRAIC(:,7);
ALGEBRAIC(:,35) =  318.108.*ALGEBRAIC(:,12);
ALGEBRAIC(:,79) =  1.00000.*CONSTANTS(:,57).*STATES(:,2);
ALGEBRAIC(:,76) =  2.00000.*CONSTANTS(:,57).*STATES(:,2);
ALGEBRAIC(:,73) =  3.00000.*CONSTANTS(:,57).*STATES(:,2);
ALGEBRAIC(:,70) =  4.00000.*CONSTANTS(:,57).*STATES(:,2);
ALGEBRAIC(:,83) = ALGEBRAIC(:,38)+ALGEBRAIC(:,46)+ALGEBRAIC(:,55)+ALGEBRAIC(:,62)+ALGEBRAIC(:,68)+ALGEBRAIC(:,26)+ALGEBRAIC(:,30)+ALGEBRAIC(:,74)+ALGEBRAIC(:,80);
ALGEBRAIC(:,84) = STATES(:,16)+STATES(:,15)+STATES(:,14)+STATES(:,13)+STATES(:,20)+STATES(:,19)+STATES(:,18)+STATES(:,17)+STATES(:,5)+STATES(:,21)+STATES(:,22)+STATES(:,23)+STATES(:,25)+STATES(:,24);
ALGEBRAIC(:,2) =  CONSTANTS(:,134).*0.731000.*exp(STATES(:,1)./30.0000);
ALGEBRAIC(:,23) =  2.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,27) =  1.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,10) =  CONSTANTS(:,134).*0.214900.*exp( - STATES(:,1)./40.0000);
ALGEBRAIC(:,41) =  3.00000.*ALGEBRAIC(:,10);
ALGEBRAIC(:,45) =  4.00000.*ALGEBRAIC(:,10);
ALGEBRAIC(:,81) = ( CONSTANTS(:,134).*4.00000)./(1.00000+1.00000./STATES(:,2));
ALGEBRAIC(:,54) =  CONSTANTS(:,134).*0.00595600.*exp( - STATES(:,1)./40.0000);
ALGEBRAIC(:,49) =  CONSTANTS(:,134).*0.474200.*exp(STATES(:,1)./10.0000);
ALGEBRAIC(:,67) =  CONSTANTS(:,134).*0.00232000.*exp( - STATES(:,1)./280.000);
ALGEBRAIC(:,61) =  CONSTANTS(:,134).*0.0121300.*exp(STATES(:,1)./500.000);
ALGEBRAIC(:,72) = ( ALGEBRAIC(:,45).*ALGEBRAIC(:,61).*ALGEBRAIC(:,54))./( ALGEBRAIC(:,27).*ALGEBRAIC(:,67));
ALGEBRAIC(:,64) =  CONSTANTS(:,134).*0.0219700.*exp(STATES(:,1)./500.000);
ALGEBRAIC(:,58) =  CONSTANTS(:,134).*0.0140700.*exp( - STATES(:,1)./300.000);
ALGEBRAIC(:,69) = ( ALGEBRAIC(:,45).*ALGEBRAIC(:,58).*ALGEBRAIC(:,49))./( ALGEBRAIC(:,27).*ALGEBRAIC(:,64));
ALGEBRAIC(:,19) =  3.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,37) =  2.00000.*ALGEBRAIC(:,10);
ALGEBRAIC(:,15) =  4.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,32) =  1.00000.*ALGEBRAIC(:,10);
ALGEBRAIC(:,78) = ALGEBRAIC(:,67);
ALGEBRAIC(:,75) = ( ALGEBRAIC(:,61).*ALGEBRAIC(:,64))./ALGEBRAIC(:,58);
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
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 Model of Human Jejunal Smooth Muscle Cell Electrophysiology at changeset 4de8d2594e8e.
This exposure was expired. A more up-to-date exposure is available, or view related resources.
Collaboration
To begin collaborating on this work, please use your git client and issue this command: