# 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 =80;
end
% There are a total of 38 entries in each of the rate and state variable arrays.
% There are a total of 65 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 (joule_per_mole_kelvin)');
LEGEND_CONSTANTS(:,2) = strpad('T in component membrane (kelvin)');
LEGEND_CONSTANTS(:,3) = strpad('F in component membrane (coulomb_per_millimole)');
LEGEND_CONSTANTS(:,4) = strpad('Cm in component membrane (picoF)');
LEGEND_ALGEBRAIC(:,14) = strpad('I_stim in component I_stim (picoA)');
LEGEND_ALGEBRAIC(:,54) = strpad('i_Na in component sodium_current (picoA)');
LEGEND_ALGEBRAIC(:,22) = strpad('i_Ca_L in component L_type_Ca_channel (picoA)');
LEGEND_ALGEBRAIC(:,30) = strpad('i_Ca_T in component T_type_Ca_channel (picoA)');
LEGEND_ALGEBRAIC(:,38) = strpad('i_Kv in component voltage_dep_K_channel (picoA)');
LEGEND_ALGEBRAIC(:,46) = strpad('i_BK in component Calcium_voltage_activated_potassium_channel (picoA)');
LEGEND_ALGEBRAIC(:,58) = strpad('i_NCX in component Na_Ca_exchanger (picoA)');
LEGEND_ALGEBRAIC(:,61) = strpad('i_NaK in component sodium_potassium_pump (picoA)');
LEGEND_ALGEBRAIC(:,73) = strpad('i_NsK in component non_specific_K_current (picoA)');
LEGEND_ALGEBRAIC(:,67) = strpad('i_NsNa in component non_specific_Na_current (picoA)');
LEGEND_ALGEBRAIC(:,9) = strpad('local_time in component I_stim (millisecond)');
LEGEND_CONSTANTS(:,5) = strpad('period in component I_stim (millisecond)');
LEGEND_ALGEBRAIC(:,1) = strpad('stim_start in component I_stim (millisecond)');
LEGEND_CONSTANTS(:,6) = strpad('Gcouple in component I_stim (nanoS)');
LEGEND_CONSTANTS(:,7) = strpad('t_ICCpeak in component I_stim (millisecond)');
LEGEND_CONSTANTS(:,8) = strpad('t_ICCplateau in component I_stim (millisecond)');
LEGEND_CONSTANTS(:,9) = strpad('t_slope in component I_stim (millisecond)');
LEGEND_CONSTANTS(:,10) = strpad('f_1 in component I_stim (millisecond)');
LEGEND_CONSTANTS(:,11) = strpad('f_2 in component I_stim (millisecond)');
LEGEND_CONSTANTS(:,12) = strpad('V_ICCrest in component I_stim (millivolt)');
LEGEND_CONSTANTS(:,13) = strpad('V_ICCamp in component I_stim (millivolt)');
LEGEND_ALGEBRAIC(:,18) = strpad('E_Ca in component L_type_Ca_channel (millivolt)');
LEGEND_CONSTANTS(:,14) = strpad('g_CaL in component L_type_Ca_channel (nanoS)');
LEGEND_CONSTANTS(:,15) = strpad('Cao in component ionic_concentrations (millimolar)');
LEGEND_STATES(:,2) = strpad('Cai in component ionic_concentrations (millimolar)');
LEGEND_STATES(:,3) = strpad('O_CaL in component L_type_Ca_channel_states (dimensionless)');
LEGEND_STATES(:,4) = strpad('C0 in component L_type_Ca_channel_states (dimensionless)');
LEGEND_STATES(:,5) = strpad('C1 in component L_type_Ca_channel_states (dimensionless)');
LEGEND_STATES(:,6) = strpad('C2 in component L_type_Ca_channel_states (dimensionless)');
LEGEND_STATES(:,7) = strpad('C3 in component L_type_Ca_channel_states (dimensionless)');
LEGEND_STATES(:,8) = strpad('C0Ca in component L_type_Ca_channel_states (dimensionless)');
LEGEND_STATES(:,9) = strpad('C1Ca in component L_type_Ca_channel_states (dimensionless)');
LEGEND_STATES(:,10) = strpad('C2Ca in component L_type_Ca_channel_states (dimensionless)');
LEGEND_STATES(:,11) = strpad('C3Ca in component L_type_Ca_channel_states (dimensionless)');
LEGEND_STATES(:,12) = strpad('ICa in component L_type_Ca_channel_states (dimensionless)');
LEGEND_STATES(:,13) = strpad('IVs in component L_type_Ca_channel_states (dimensionless)');
LEGEND_STATES(:,14) = strpad('IVf in component L_type_Ca_channel_states (dimensionless)');
LEGEND_STATES(:,15) = strpad('IVfCa in component L_type_Ca_channel_states (dimensionless)');
LEGEND_STATES(:,16) = strpad('IVsCa in component L_type_Ca_channel_states (dimensionless)');
LEGEND_ALGEBRAIC(:,2) = strpad('alpha in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,10) = strpad('beta in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,15) = strpad('alpha_0 in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,19) = strpad('alpha_1 in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,23) = strpad('alpha_2 in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,27) = strpad('alpha_3 in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,31) = strpad('beta_0 in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,35) = strpad('beta_1 in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,39) = strpad('beta_2 in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,43) = strpad('beta_3 in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_CONSTANTS(:,54) = strpad('delta in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,78) = strpad('theta in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,51) = strpad('phi_s in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,47) = strpad('phi_f in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,71) = strpad('omega_s in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,68) = strpad('omega_f in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,76) = strpad('omega_fs in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,74) = strpad('omega_sf in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,65) = strpad('psi_s in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,62) = strpad('psi_f in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,59) = strpad('xi_s in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,55) = strpad('xi_f in component L_type_Ca_channel_states (per_millisecond)');
LEGEND_CONSTANTS(:,45) = strpad('T_correction_Ca in component L_type_Ca_channel_states (dimensionless)');
LEGEND_CONSTANTS(:,16) = strpad('Q10Ca in component L_type_Ca_channel_states (dimensionless)');
LEGEND_ALGEBRAIC(:,80) = strpad('norm in component L_type_Ca_channel_states (dimensionless)');
LEGEND_CONSTANTS(:,17) = strpad('g_CaT in component T_type_Ca_channel (nanoS)');
LEGEND_ALGEBRAIC(:,26) = strpad('E_Ca in component T_type_Ca_channel (millivolt)');
LEGEND_STATES(:,17) = strpad('d_CaT in component T_type_Ca_channel_d_gate (dimensionless)');
LEGEND_STATES(:,18) = strpad('f_CaT in component T_type_Ca_channel_f_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,3) = strpad('d_CaT_inf in component T_type_Ca_channel_d_gate (dimensionless)');
LEGEND_CONSTANTS(:,55) = strpad('tau_d_CaT in component T_type_Ca_channel_d_gate (millisecond)');
LEGEND_CONSTANTS(:,46) = strpad('T_correction_Ca in component T_type_Ca_channel_d_gate (dimensionless)');
LEGEND_CONSTANTS(:,18) = strpad('Q10Ca in component T_type_Ca_channel_d_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,4) = strpad('f_CaT_inf in component T_type_Ca_channel_f_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,11) = strpad('tau_f_CaT in component T_type_Ca_channel_f_gate (millisecond)');
LEGEND_CONSTANTS(:,47) = strpad('T_correction_Ca in component T_type_Ca_channel_f_gate (dimensionless)');
LEGEND_CONSTANTS(:,19) = strpad('Q10Ca in component T_type_Ca_channel_f_gate (dimensionless)');
LEGEND_CONSTANTS(:,20) = strpad('g_Kv in component voltage_dep_K_channel (nanoS)');
LEGEND_ALGEBRAIC(:,34) = strpad('E_K in component voltage_dep_K_channel (millivolt)');
LEGEND_STATES(:,19) = strpad('x_Kv in component voltage_dep_K_channel_x_gate (dimensionless)');
LEGEND_STATES(:,20) = strpad('y_Kv in component voltage_dep_K_channel_y_gate (dimensionless)');
LEGEND_CONSTANTS(:,21) = strpad('Ko in component ionic_concentrations (millimolar)');
LEGEND_STATES(:,21) = strpad('Ki in component ionic_concentrations (millimolar)');
LEGEND_ALGEBRAIC(:,5) = strpad('x_Kv_inf in component voltage_dep_K_channel_x_gate (dimensionless)');
LEGEND_CONSTANTS(:,56) = strpad('tau_x_Kv in component voltage_dep_K_channel_x_gate (millisecond)');
LEGEND_CONSTANTS(:,48) = strpad('T_correction_K in component voltage_dep_K_channel_x_gate (dimensionless)');
LEGEND_CONSTANTS(:,22) = strpad('Q10K in component voltage_dep_K_channel_x_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,6) = strpad('y_Kv_inf in component voltage_dep_K_channel_y_gate (dimensionless)');
LEGEND_CONSTANTS(:,57) = strpad('tau_y_Kv in component voltage_dep_K_channel_y_gate (millisecond)');
LEGEND_CONSTANTS(:,49) = strpad('T_correction_K in component voltage_dep_K_channel_y_gate (dimensionless)');
LEGEND_CONSTANTS(:,23) = strpad('Q10K in component voltage_dep_K_channel_y_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,42) = strpad('E_K in component Calcium_voltage_activated_potassium_channel (millivolt)');
LEGEND_CONSTANTS(:,24) = strpad('g_BK in component Calcium_voltage_activated_potassium_channel (nanoS)');
LEGEND_STATES(:,22) = strpad('O4 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_STATES(:,23) = strpad('C0 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_STATES(:,24) = strpad('C1 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_STATES(:,25) = strpad('C2 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_STATES(:,26) = strpad('C3 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_STATES(:,27) = strpad('C4 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_STATES(:,28) = strpad('O0 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_STATES(:,29) = strpad('O1 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_STATES(:,30) = strpad('O2 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_STATES(:,31) = strpad('O3 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_ALGEBRAIC(:,7) = strpad('alpha in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,12) = strpad('beta in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_CONSTANTS(:,50) = strpad('k_on in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_CONSTANTS(:,51) = strpad('k_off_C in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_CONSTANTS(:,52) = strpad('k_off_O in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,16) = strpad('k_C0O0 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,20) = strpad('k_C1O1 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,24) = strpad('k_C2O2 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,28) = strpad('k_C3O3 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,32) = strpad('k_C4O4 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,36) = strpad('k_O0C0 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,40) = strpad('k_O1C1 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,44) = strpad('k_O2C2 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,48) = strpad('k_O3C3 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,52) = strpad('k_O4C4 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,56) = strpad('k_C0C1 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,60) = strpad('k_C1C2 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,63) = strpad('k_C2C3 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,66) = strpad('k_C3C4 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_CONSTANTS(:,58) = strpad('k_C4C3 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_CONSTANTS(:,59) = strpad('k_C3C2 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_CONSTANTS(:,60) = strpad('k_C2C1 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_CONSTANTS(:,61) = strpad('k_C1C0 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,69) = strpad('k_O0O1 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,72) = strpad('k_O1O2 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,75) = strpad('k_O2O3 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,77) = strpad('k_O3O4 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_CONSTANTS(:,62) = strpad('k_O4O3 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_CONSTANTS(:,63) = strpad('k_O3O2 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_CONSTANTS(:,64) = strpad('k_O2O1 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_CONSTANTS(:,65) = strpad('k_O1O0 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,79) = strpad('norm in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_ALGEBRAIC(:,50) = strpad('E_Na in component sodium_current (millivolt)');
LEGEND_CONSTANTS(:,25) = strpad('g_Na in component sodium_current (nanoS)');
LEGEND_CONSTANTS(:,26) = strpad('Nao in component ionic_concentrations (millimolar)');
LEGEND_STATES(:,32) = strpad('Nai in component ionic_concentrations (millimolar)');
LEGEND_STATES(:,33) = strpad('O_Na in component Na_channel_states (dimensionless)');
LEGEND_STATES(:,34) = strpad('C1 in component Na_channel_states (dimensionless)');
LEGEND_STATES(:,35) = strpad('C2 in component Na_channel_states (dimensionless)');
LEGEND_STATES(:,36) = strpad('C3 in component Na_channel_states (dimensionless)');
LEGEND_STATES(:,37) = strpad('I1 in component Na_channel_states (dimensionless)');
LEGEND_STATES(:,38) = strpad('I2 in component Na_channel_states (dimensionless)');
LEGEND_ALGEBRAIC(:,8) = strpad('k_I2I1 in component Na_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,13) = strpad('k_I1O in component Na_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,17) = strpad('k_OC1 in component Na_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,21) = strpad('k_C1C2 in component Na_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,25) = strpad('k_C2C3 in component Na_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,29) = strpad('k_C3C2 in component Na_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,33) = strpad('k_C2C1 in component Na_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,37) = strpad('k_C1O in component Na_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,41) = strpad('k_OI1 in component Na_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,45) = strpad('k_I1I2 in component Na_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,49) = strpad('k_I1C1 in component Na_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,53) = strpad('k_C1I1 in component Na_channel_states (per_millisecond)');
LEGEND_ALGEBRAIC(:,57) = strpad('norm in component Na_channel_states (dimensionless)');
LEGEND_CONSTANTS(:,53) = strpad('T_correction_Na in component Na_channel_states (dimensionless)');
LEGEND_CONSTANTS(:,27) = strpad('Q10Na in component Na_channel_states (dimensionless)');
LEGEND_CONSTANTS(:,28) = strpad('P_NCX in component Na_Ca_exchanger (picoA)');
LEGEND_CONSTANTS(:,29) = strpad('K_mCa in component Na_Ca_exchanger (millimolar)');
LEGEND_CONSTANTS(:,30) = strpad('K_mNai in component Na_Ca_exchanger (millimolar)');
LEGEND_CONSTANTS(:,31) = strpad('k_sat in component Na_Ca_exchanger (dimensionless)');
LEGEND_CONSTANTS(:,32) = strpad('gamma in component Na_Ca_exchanger (dimensionless)');
LEGEND_CONSTANTS(:,33) = strpad('P_NaK in component sodium_potassium_pump (picoA)');
LEGEND_CONSTANTS(:,34) = strpad('K_mK in component sodium_potassium_pump (millimolar)');
LEGEND_CONSTANTS(:,35) = strpad('K_mNa in component sodium_potassium_pump (millimolar)');
LEGEND_CONSTANTS(:,36) = strpad('g_NsNa in component non_specific_Na_current (nanoS)');
LEGEND_ALGEBRAIC(:,64) = strpad('E_Na in component non_specific_Na_current (millivolt)');
LEGEND_CONSTANTS(:,37) = strpad('g_NsK in component non_specific_K_current (nanoS)');
LEGEND_ALGEBRAIC(:,70) = strpad('E_K in component non_specific_K_current (millivolt)');
LEGEND_CONSTANTS(:,38) = strpad('CRT_total in component ionic_concentrations (millimolar)');
LEGEND_CONSTANTS(:,39) = strpad('CaM_total in component ionic_concentrations (millimolar)');
LEGEND_CONSTANTS(:,40) = strpad('K_D_CRT in component ionic_concentrations (millimolar)');
LEGEND_CONSTANTS(:,41) = strpad('K_D_CaM in component ionic_concentrations (millimolar4)');
LEGEND_CONSTANTS(:,42) = strpad('n_CRT in component ionic_concentrations (dimensionless)');
LEGEND_CONSTANTS(:,43) = strpad('n_CaM in component ionic_concentrations (dimensionless)');
LEGEND_CONSTANTS(:,44) = strpad('V_myo in component ionic_concentrations (litre)');
LEGEND_RATES(:,1) = strpad('d/dt V in component membrane (millivolt)');
LEGEND_RATES(:,7) = strpad('d/dt C3 in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,6) = strpad('d/dt C2 in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,5) = strpad('d/dt C1 in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,4) = strpad('d/dt C0 in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,11) = strpad('d/dt C3Ca in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,10) = strpad('d/dt C2Ca in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,9) = strpad('d/dt C1Ca in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,8) = strpad('d/dt C0Ca in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,3) = strpad('d/dt O_CaL in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,12) = strpad('d/dt ICa in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,13) = strpad('d/dt IVs in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,14) = strpad('d/dt IVf in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,16) = strpad('d/dt IVsCa in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,15) = strpad('d/dt IVfCa in component L_type_Ca_channel_states (dimensionless)');
LEGEND_RATES(:,17) = strpad('d/dt d_CaT in component T_type_Ca_channel_d_gate (dimensionless)');
LEGEND_RATES(:,18) = strpad('d/dt f_CaT in component T_type_Ca_channel_f_gate (dimensionless)');
LEGEND_RATES(:,19) = strpad('d/dt x_Kv in component voltage_dep_K_channel_x_gate (dimensionless)');
LEGEND_RATES(:,20) = strpad('d/dt y_Kv in component voltage_dep_K_channel_y_gate (dimensionless)');
LEGEND_RATES(:,27) = strpad('d/dt C4 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_RATES(:,26) = strpad('d/dt C3 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_RATES(:,25) = strpad('d/dt C2 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_RATES(:,24) = strpad('d/dt C1 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_RATES(:,23) = strpad('d/dt C0 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_RATES(:,22) = strpad('d/dt O4 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_RATES(:,31) = strpad('d/dt O3 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_RATES(:,30) = strpad('d/dt O2 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_RATES(:,29) = strpad('d/dt O1 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_RATES(:,28) = strpad('d/dt O0 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)');
LEGEND_RATES(:,36) = strpad('d/dt C3 in component Na_channel_states (dimensionless)');
LEGEND_RATES(:,35) = strpad('d/dt C2 in component Na_channel_states (dimensionless)');
LEGEND_RATES(:,34) = strpad('d/dt C1 in component Na_channel_states (dimensionless)');
LEGEND_RATES(:,33) = strpad('d/dt O_Na in component Na_channel_states (dimensionless)');
LEGEND_RATES(:,38) = strpad('d/dt I2 in component Na_channel_states (dimensionless)');
LEGEND_RATES(:,37) = strpad('d/dt I1 in component Na_channel_states (dimensionless)');
LEGEND_RATES(:,32) = strpad('d/dt Nai in component ionic_concentrations (millimolar)');
LEGEND_RATES(:,21) = strpad('d/dt Ki in component ionic_concentrations (millimolar)');
LEGEND_RATES(:,2) = strpad('d/dt Cai in component ionic_concentrations (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) = -73.5049651455872;
CONSTANTS(:,1) = 8.314;
CONSTANTS(:,2) = 310;
CONSTANTS(:,3) = 96.48534;
CONSTANTS(:,4) = 50;
CONSTANTS(:,5) = 10000;
CONSTANTS(:,6) = 2.6;
CONSTANTS(:,7) = 300;
CONSTANTS(:,8) = 9700;
CONSTANTS(:,9) = 600;
CONSTANTS(:,10) = 12000;
CONSTANTS(:,11) = 300;
CONSTANTS(:,12) = -57;
CONSTANTS(:,13) = 33.5;
CONSTANTS(:,14) = 1.44;
CONSTANTS(:,15) = 2;
STATES(:,2) = 5.38843941249284e-5;
STATES(:,3) = 3.88576045134351e-6;
STATES(:,4) = 0.815464741971086;
STATES(:,5) = 0.152399266235657;
STATES(:,6) = 0.0106805060777161;
STATES(:,7) = 0.000332673548872087;
STATES(:,8) = 0.0175888495282545;
STATES(:,9) = 0.00328711668724504;
STATES(:,10) = 0.000230369020877669;
STATES(:,11) = 7.1754726923539e-6;
STATES(:,12) = 8.38123983500905e-8;
STATES(:,13) = 1.1193313274705e-6;
STATES(:,14) = 4.0998751301597e-6;
STATES(:,15) = 8.84306615061238e-8;
STATES(:,16) = 2.41429816075123e-8;
CONSTANTS(:,16) = 2.1;
CONSTANTS(:,17) = 0.0425;
STATES(:,17) = 0.0791635737410974;
STATES(:,18) = 0.377831534375835;
CONSTANTS(:,18) = 2.1;
CONSTANTS(:,19) = 2.1;
CONSTANTS(:,20) = 1.0217;
STATES(:,19) = 0.14714161078933;
STATES(:,20) = 0.99994773314105;
CONSTANTS(:,21) = 5.4;
STATES(:,21) = 153.604280337996;
CONSTANTS(:,22) = 3.1;
CONSTANTS(:,23) = 3.1;
CONSTANTS(:,24) = 80;
STATES(:,22) = 1.82113764497095e-6;
STATES(:,23) = 0.48379087935899;
STATES(:,24) = 0.385183559520031;
STATES(:,25) = 0.115002824567753;
STATES(:,26) = 0.0152602714149774;
STATES(:,27) = 0.000759264410974374;
STATES(:,28) = 6.94960798375172e-7;
STATES(:,29) = 5.55636826398253e-8;
STATES(:,30) = 2.85143702125325e-8;
STATES(:,31) = 1.59832806123435e-6;
CONSTANTS(:,25) = 25.1;
CONSTANTS(:,26) = 140;
STATES(:,32) = 10.5731241425458;
STATES(:,33) = 1.96760342050475e-6;
STATES(:,34) = 0.0119443135223679;
STATES(:,35) = 0.0109545368437155;
STATES(:,36) = 0.973782548650071;
STATES(:,37) = 0.000126882921013389;
STATES(:,38) = 0.00318975045717667;
CONSTANTS(:,27) = 2.45;
CONSTANTS(:,28) = 1992.335;
CONSTANTS(:,29) = 1.38;
CONSTANTS(:,30) = 87.5;
CONSTANTS(:,31) = 0.1;
CONSTANTS(:,32) = 0.35;
CONSTANTS(:,33) = 9.26;
CONSTANTS(:,34) = 1;
CONSTANTS(:,35) = 40;
CONSTANTS(:,36) = 0.022488;
CONSTANTS(:,37) = 0.017512;
CONSTANTS(:,38) = 0.034;
CONSTANTS(:,39) = 0.012;
CONSTANTS(:,40) = 0.0009;
CONSTANTS(:,41) = 0.0001;
CONSTANTS(:,42) = 1;
CONSTANTS(:,43) = 4;
CONSTANTS(:,44) = 3.50000e-12;
CONSTANTS(:,45) = power(CONSTANTS(:,16), (CONSTANTS(:,2) - 310.000)./10.0000);
CONSTANTS(:,46) = power(CONSTANTS(:,18), (CONSTANTS(:,2) - 297.000)./10.0000);
CONSTANTS(:,47) = power(CONSTANTS(:,19), (CONSTANTS(:,2) - 297.000)./10.0000);
CONSTANTS(:,48) = power(CONSTANTS(:,22), (CONSTANTS(:,2) - 297.000)./10.0000);
CONSTANTS(:,49) = power(CONSTANTS(:,23), (CONSTANTS(:,2) - 297.000)./10.0000);
CONSTANTS(:,50) = 40633.0;
CONSTANTS(:,51) = 11.0000;
CONSTANTS(:,52) = 1.10000;
CONSTANTS(:,53) =  1.00000.*power(CONSTANTS(:,27), (CONSTANTS(:,2) - 297.000)./10.0000);
CONSTANTS(:,54) =  CONSTANTS(:,45).*0.0100000;
CONSTANTS(:,55) = 1.90580./CONSTANTS(:,46);
CONSTANTS(:,56) = 4.78030./CONSTANTS(:,48);
CONSTANTS(:,57) = 763.756./CONSTANTS(:,49);
CONSTANTS(:,58) =  4.00000.*CONSTANTS(:,51);
CONSTANTS(:,59) =  3.00000.*CONSTANTS(:,51);
CONSTANTS(:,60) =  2.00000.*CONSTANTS(:,51);
CONSTANTS(:,61) =  1.00000.*CONSTANTS(:,51);
CONSTANTS(:,62) =  4.00000.*CONSTANTS(:,52);
CONSTANTS(:,63) =  3.00000.*CONSTANTS(:,52);
CONSTANTS(:,64) =  2.00000.*CONSTANTS(:,52);
CONSTANTS(:,65) =  1.00000.*CONSTANTS(:,52);
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);
else
statesRowCount = statesSize(1);
ALGEBRAIC = zeros(statesRowCount, algebraicVariableCount);
RATES = zeros(statesRowCount, statesColumnCount);
end
ALGEBRAIC(:,3) = 1.00000./(1.00000+exp( - (STATES(:,1)+60.5000)./5.30000));
RATES(:,17) = (ALGEBRAIC(:,3) - STATES(:,17))./CONSTANTS(:,55);
ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1)+43.0000)./17.3600));
RATES(:,19) = (ALGEBRAIC(:,5) - STATES(:,19))./CONSTANTS(:,56);
ALGEBRAIC(:,6) = 1.00000./(1.00000+exp((STATES(:,1) - 44.9000)./12.0096));
RATES(:,20) = (ALGEBRAIC(:,6) - STATES(:,20))./CONSTANTS(:,57);
ALGEBRAIC(:,4) = 1.00000./(1.00000+exp((STATES(:,1)+75.5000)./4.00000));
ALGEBRAIC(:,11) = ( 0.381170.*(8.60000+ 14.7000.*exp((  - (STATES(:,1)+50.0000).*(STATES(:,1)+50.0000))./900.000)))./CONSTANTS(:,47);
RATES(:,18) = (ALGEBRAIC(:,4) - STATES(:,18))./ALGEBRAIC(:,11);
ALGEBRAIC(:,25) =  CONSTANTS(:,53).*0.554320.*exp( - 0.0990740+ 0.0364410.*STATES(:,1));
ALGEBRAIC(:,29) =  CONSTANTS(:,53).*0.000525480.*exp( - 0.0691020+ 0.00319450.*STATES(:,1));
ALGEBRAIC(:,57) = STATES(:,33)+STATES(:,34)+STATES(:,35)+STATES(:,36)+STATES(:,37)+STATES(:,38);
RATES(:,36) = (  - ALGEBRAIC(:,29).*STATES(:,36))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,25).*STATES(:,35))./ALGEBRAIC(:,57);
ALGEBRAIC(:,21) =  CONSTANTS(:,53).*3.15660.*exp(0.363520+ 0.0771930.*STATES(:,1));
ALGEBRAIC(:,33) =  CONSTANTS(:,53).*1.44960.*exp( - 0.156600+ 0.0583530.*STATES(:,1));
RATES(:,35) = (  - (ALGEBRAIC(:,33)+ALGEBRAIC(:,25)).*STATES(:,35))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,21).*STATES(:,34))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,29).*STATES(:,36))./ALGEBRAIC(:,57);
ALGEBRAIC(:,17) =  CONSTANTS(:,53).*2.39100.*exp( - 13.3350 -  0.252890.*STATES(:,1));
ALGEBRAIC(:,37) =  CONSTANTS(:,53).*1.53290.*exp(0.00931930+ 0.0410750.*STATES(:,1));
ALGEBRAIC(:,49) =  CONSTANTS(:,53).*1.90460.*exp( - 2.48400+ 0.0204060.*STATES(:,1));
ALGEBRAIC(:,53) =  CONSTANTS(:,53).*0.000216880.*exp( - 0.0634380+ 0.00466830.*STATES(:,1));
RATES(:,34) = (  - (ALGEBRAIC(:,21)+ALGEBRAIC(:,37)+ALGEBRAIC(:,53)).*STATES(:,34))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,17).*STATES(:,33))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,33).*STATES(:,35))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,49).*STATES(:,37))./ALGEBRAIC(:,57);
ALGEBRAIC(:,13) =  CONSTANTS(:,53).*0.120520.*exp( - 9.60280+ 0.0830250.*STATES(:,1));
ALGEBRAIC(:,41) =  CONSTANTS(:,53).*1.61640.*exp(0.307630+ 0.00605350.*STATES(:,1));
RATES(:,33) = (  - (ALGEBRAIC(:,17)+ALGEBRAIC(:,41)).*STATES(:,33))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,37).*STATES(:,34))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,13).*STATES(:,37))./ALGEBRAIC(:,57);
ALGEBRAIC(:,8) =  CONSTANTS(:,53).*0.00392390.*exp(2.67930+ 0.00614680.*STATES(:,1));
ALGEBRAIC(:,45) =  CONSTANTS(:,53).*0.0277350.*exp(0.0514900 -  0.0468650.*STATES(:,1));
RATES(:,38) = (  - ALGEBRAIC(:,8).*STATES(:,38))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,45).*STATES(:,37))./ALGEBRAIC(:,57);
RATES(:,37) = (  - (ALGEBRAIC(:,13)+ALGEBRAIC(:,45)+ALGEBRAIC(:,49)).*STATES(:,37))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,8).*STATES(:,38))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,53).*STATES(:,34))./ALGEBRAIC(:,57)+( ALGEBRAIC(:,41).*STATES(:,33))./ALGEBRAIC(:,57);
ALGEBRAIC(:,18) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./( 2.00000.*CONSTANTS(:,3))).*log(CONSTANTS(:,15)./STATES(:,2));
ALGEBRAIC(:,22) =  CONSTANTS(:,14).*STATES(:,3).*(STATES(:,1) - ALGEBRAIC(:,18));
ALGEBRAIC(:,26) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./( 2.00000.*CONSTANTS(:,3))).*log(CONSTANTS(:,15)./STATES(:,2));
ALGEBRAIC(:,30) =  CONSTANTS(:,17).*STATES(:,17).*STATES(:,18).*(STATES(:,1) - ALGEBRAIC(:,26));
ALGEBRAIC(:,58) = ( CONSTANTS(:,28).*( exp(( CONSTANTS(:,32).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,32), 3.00000).*CONSTANTS(:,15) -  2.50000.*exp(( (CONSTANTS(:,32) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(CONSTANTS(:,26), 3.00000).*STATES(:,2)))./( (power(CONSTANTS(:,30), 3.00000)+power(CONSTANTS(:,26), 3.00000)).*(CONSTANTS(:,29)+CONSTANTS(:,15)).*(1.00000+ CONSTANTS(:,31).*exp(( (CONSTANTS(:,32) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))));
RATES(:,2) = ((  - 1.00000e-15.*((ALGEBRAIC(:,22)+ALGEBRAIC(:,30)) -  ALGEBRAIC(:,58).*2.00000))./( 2.00000.*CONSTANTS(:,44).*CONSTANTS(:,3)))./(1.00000+( CONSTANTS(:,42).*CONSTANTS(:,38).*CONSTANTS(:,40).*power(STATES(:,2), CONSTANTS(:,42) - 1.00000))./power(power(STATES(:,2), CONSTANTS(:,42))+CONSTANTS(:,40), 2.00000)+( CONSTANTS(:,43).*CONSTANTS(:,39).*CONSTANTS(:,41).*power(STATES(:,2), CONSTANTS(:,43) - 1.00000))./power(power(STATES(:,2), CONSTANTS(:,43))+CONSTANTS(:,41), 2.00000));
ALGEBRAIC(:,50) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,26)./STATES(:,32));
ALGEBRAIC(:,54) =  CONSTANTS(:,25).*STATES(:,33).*(STATES(:,1) - ALGEBRAIC(:,50));
ALGEBRAIC(:,61) = ( CONSTANTS(:,33).*CONSTANTS(:,21).*STATES(:,32))./( (CONSTANTS(:,21)+CONSTANTS(:,34)).*(CONSTANTS(:,35)+STATES(:,32)).*(1.00000+ 0.124500.*exp((  - 0.100000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))+ 0.0353000.*exp((  - STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))));
ALGEBRAIC(:,64) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,26)./STATES(:,32));
ALGEBRAIC(:,67) =  CONSTANTS(:,36).*(STATES(:,1) - ALGEBRAIC(:,64));
RATES(:,32) = ( ( - 1.00000./1.00000e+15).*(ALGEBRAIC(:,54)+ALGEBRAIC(:,67)+ ALGEBRAIC(:,58).*3.00000+ ALGEBRAIC(:,61).*3.00000))./( CONSTANTS(:,44).*CONSTANTS(:,3));
ALGEBRAIC(:,1) = piecewise({VOI>= CONSTANTS(:,5).*0.00000&VOI<= CONSTANTS(:,5).*1.00000,  CONSTANTS(:,5).*0.00000 , VOI>= CONSTANTS(:,5).*1.00000&VOI<= CONSTANTS(:,5).*2.00000,  CONSTANTS(:,5).*1.00000 , VOI>= CONSTANTS(:,5).*2.00000&VOI< CONSTANTS(:,5).*3.00000,  CONSTANTS(:,5).*2.00000 , VOI>= CONSTANTS(:,5).*3.00000&VOI< CONSTANTS(:,5).*4.00000,  CONSTANTS(:,5).*3.00000 }, 0.00000);
ALGEBRAIC(:,9) = VOI - ALGEBRAIC(:,1);
ALGEBRAIC(:,14) = piecewise({ALGEBRAIC(:,9)<CONSTANTS(:,7),  CONSTANTS(:,6).*(STATES(:,1) - (CONSTANTS(:,12)+( CONSTANTS(:,13).*ALGEBRAIC(:,9))./CONSTANTS(:,11))) },  CONSTANTS(:,6).*(STATES(:,1) - (CONSTANTS(:,12)+( CONSTANTS(:,13).*(1.00000+exp( - CONSTANTS(:,10)./( 2.00000.*CONSTANTS(:,9)))).*1.00000)./(1.00000+exp(((ALGEBRAIC(:,9) - CONSTANTS(:,11)) -  0.500000.*CONSTANTS(:,10))./CONSTANTS(:,9))))));
ALGEBRAIC(:,34) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,21)./STATES(:,21));
ALGEBRAIC(:,38) =  CONSTANTS(:,20).*STATES(:,19).*STATES(:,20).*(STATES(:,1) - ALGEBRAIC(:,34));
ALGEBRAIC(:,42) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,21)./STATES(:,21));
ALGEBRAIC(:,46) =  CONSTANTS(:,24).*STATES(:,22).*(STATES(:,1) - ALGEBRAIC(:,42));
ALGEBRAIC(:,70) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,21)./STATES(:,21));
ALGEBRAIC(:,73) =  CONSTANTS(:,37).*(STATES(:,1) - ALGEBRAIC(:,70));
RATES(:,1) =  ( - 1.00000./CONSTANTS(:,4)).*(ALGEBRAIC(:,54)+ALGEBRAIC(:,22)+ALGEBRAIC(:,30)+ALGEBRAIC(:,38)+ALGEBRAIC(:,46)+ALGEBRAIC(:,58)+ALGEBRAIC(:,61)+ALGEBRAIC(:,73)+ALGEBRAIC(:,67)+ALGEBRAIC(:,14));
RATES(:,21) = (  - 1.00000e-15.*((ALGEBRAIC(:,38)+ALGEBRAIC(:,46)+ALGEBRAIC(:,73)+ALGEBRAIC(:,14)) -  ALGEBRAIC(:,61).*2.00000))./( CONSTANTS(:,44).*CONSTANTS(:,3));
ALGEBRAIC(:,7) =  1.00000.*exp(( 8.47188.*STATES(:,1))./( 1.00000.*CONSTANTS(:,2)));
ALGEBRAIC(:,32) =  0.0443240.*ALGEBRAIC(:,7);
ALGEBRAIC(:,12) =  1.00000.*exp((  - 7.77556.*STATES(:,1))./( 1.00000.*CONSTANTS(:,2)));
ALGEBRAIC(:,52) =  0.000106000.*ALGEBRAIC(:,12);
ALGEBRAIC(:,66) =  1.00000.*CONSTANTS(:,50).*STATES(:,2);
ALGEBRAIC(:,79) = STATES(:,23)+STATES(:,24)+STATES(:,25)+STATES(:,26)+STATES(:,27)+STATES(:,28)+STATES(:,29)+STATES(:,30)+STATES(:,31)+STATES(:,22);
RATES(:,27) = (  - (CONSTANTS(:,58)+ALGEBRAIC(:,32)).*STATES(:,27))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,66).*STATES(:,26))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,52).*STATES(:,22))./ALGEBRAIC(:,79);
ALGEBRAIC(:,28) =  0.000781000.*ALGEBRAIC(:,7);
ALGEBRAIC(:,48) =  0.0953120.*ALGEBRAIC(:,12);
ALGEBRAIC(:,63) =  2.00000.*CONSTANTS(:,50).*STATES(:,2);
RATES(:,26) = (  - (CONSTANTS(:,59)+ALGEBRAIC(:,28)+ALGEBRAIC(:,66)).*STATES(:,26))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,63).*STATES(:,25))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,48).*STATES(:,31))./ALGEBRAIC(:,79)+( CONSTANTS(:,58).*STATES(:,27))./ALGEBRAIC(:,79);
ALGEBRAIC(:,24) =  2.81000e-05.*ALGEBRAIC(:,7);
ALGEBRAIC(:,44) =  32.6594.*ALGEBRAIC(:,12);
ALGEBRAIC(:,60) =  3.00000.*CONSTANTS(:,50).*STATES(:,2);
RATES(:,25) = (  - (CONSTANTS(:,60)+ALGEBRAIC(:,24)+ALGEBRAIC(:,63)).*STATES(:,25))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,60).*STATES(:,24))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,44).*STATES(:,30))./ALGEBRAIC(:,79)+( CONSTANTS(:,59).*STATES(:,26))./ALGEBRAIC(:,79);
ALGEBRAIC(:,20) =  0.000869000.*ALGEBRAIC(:,7);
ALGEBRAIC(:,40) =  144.174.*ALGEBRAIC(:,12);
ALGEBRAIC(:,56) =  4.00000.*CONSTANTS(:,50).*STATES(:,2);
RATES(:,24) = (  - (CONSTANTS(:,61)+ALGEBRAIC(:,20)+ALGEBRAIC(:,60)).*STATES(:,24))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,56).*STATES(:,23))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,40).*STATES(:,29))./ALGEBRAIC(:,79)+( CONSTANTS(:,60).*STATES(:,25))./ALGEBRAIC(:,79);
ALGEBRAIC(:,16) =  0.0216200.*ALGEBRAIC(:,7);
ALGEBRAIC(:,36) =  318.108.*ALGEBRAIC(:,12);
RATES(:,23) = (  - (ALGEBRAIC(:,56)+ALGEBRAIC(:,16)).*STATES(:,23))./ALGEBRAIC(:,79)+( CONSTANTS(:,61).*STATES(:,24))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,36).*STATES(:,28))./ALGEBRAIC(:,79);
ALGEBRAIC(:,77) =  1.00000.*CONSTANTS(:,50).*STATES(:,2);
RATES(:,22) = (  - (CONSTANTS(:,62)+ALGEBRAIC(:,52)).*STATES(:,22))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,77).*STATES(:,31))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,32).*STATES(:,27))./ALGEBRAIC(:,79);
ALGEBRAIC(:,75) =  2.00000.*CONSTANTS(:,50).*STATES(:,2);
RATES(:,31) = (  - (CONSTANTS(:,63)+ALGEBRAIC(:,48)+ALGEBRAIC(:,77)).*STATES(:,31))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,75).*STATES(:,30))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,28).*STATES(:,26))./ALGEBRAIC(:,79)+( CONSTANTS(:,62).*STATES(:,22))./ALGEBRAIC(:,79);
ALGEBRAIC(:,72) =  3.00000.*CONSTANTS(:,50).*STATES(:,2);
RATES(:,30) = (  - (CONSTANTS(:,64)+ALGEBRAIC(:,44)+ALGEBRAIC(:,75)).*STATES(:,30))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,72).*STATES(:,29))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,24).*STATES(:,25))./ALGEBRAIC(:,79)+( CONSTANTS(:,63).*STATES(:,31))./ALGEBRAIC(:,79);
ALGEBRAIC(:,69) =  4.00000.*CONSTANTS(:,50).*STATES(:,2);
RATES(:,29) = (  - (CONSTANTS(:,65)+ALGEBRAIC(:,40)+ALGEBRAIC(:,72)).*STATES(:,29))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,69).*STATES(:,28))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,20).*STATES(:,24))./ALGEBRAIC(:,79)+( CONSTANTS(:,64).*STATES(:,30))./ALGEBRAIC(:,79);
RATES(:,28) = (  - (ALGEBRAIC(:,69)+ALGEBRAIC(:,36)).*STATES(:,28))./ALGEBRAIC(:,79)+( CONSTANTS(:,65).*STATES(:,29))./ALGEBRAIC(:,79)+( ALGEBRAIC(:,16).*STATES(:,23))./ALGEBRAIC(:,79);
ALGEBRAIC(:,2) =  CONSTANTS(:,45).*0.731000.*exp(STATES(:,1)./30.0000);
ALGEBRAIC(:,23) =  2.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,27) =  1.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,10) =  CONSTANTS(:,45).*0.214900.*exp( - STATES(:,1)./40.0000);
ALGEBRAIC(:,39) =  3.00000.*ALGEBRAIC(:,10);
ALGEBRAIC(:,43) =  4.00000.*ALGEBRAIC(:,10);
ALGEBRAIC(:,78) = ( CONSTANTS(:,45).*4.00000)./(1.00000+1.00000./STATES(:,2));
ALGEBRAIC(:,51) =  CONSTANTS(:,45).*0.0595600.*exp( - STATES(:,1)./40.0000);
ALGEBRAIC(:,47) =  CONSTANTS(:,45).*0.474200.*exp(STATES(:,1)./10.0000);
ALGEBRAIC(:,65) =  CONSTANTS(:,45).*0.00232000.*exp( - STATES(:,1)./280.000);
ALGEBRAIC(:,59) =  CONSTANTS(:,45).*0.0121300.*exp(STATES(:,1)./500.000);
ALGEBRAIC(:,71) = ( ALGEBRAIC(:,43).*ALGEBRAIC(:,59).*ALGEBRAIC(:,51))./( ALGEBRAIC(:,27).*ALGEBRAIC(:,65));
ALGEBRAIC(:,62) =  CONSTANTS(:,45).*0.0219700.*exp(STATES(:,1)./500.000);
ALGEBRAIC(:,55) =  CONSTANTS(:,45).*0.0140700.*exp( - STATES(:,1)./300.000);
ALGEBRAIC(:,68) = ( ALGEBRAIC(:,43).*ALGEBRAIC(:,55).*ALGEBRAIC(:,47))./( ALGEBRAIC(:,27).*ALGEBRAIC(:,62));
ALGEBRAIC(:,80) = STATES(:,7)+STATES(:,6)+STATES(:,5)+STATES(:,4)+STATES(:,11)+STATES(:,10)+STATES(:,9)+STATES(:,8)+STATES(:,3)+STATES(:,12)+STATES(:,13)+STATES(:,14)+STATES(:,16)+STATES(:,15);
RATES(:,7) = (( ALGEBRAIC(:,23).*STATES(:,6))./ALGEBRAIC(:,80) - ( (ALGEBRAIC(:,27)+ALGEBRAIC(:,39)+ALGEBRAIC(:,51)+ALGEBRAIC(:,47)+ALGEBRAIC(:,78)).*STATES(:,7))./ALGEBRAIC(:,80))+( ALGEBRAIC(:,43).*STATES(:,3))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,68).*STATES(:,14))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,71).*STATES(:,13))./ALGEBRAIC(:,80)+( CONSTANTS(:,54).*STATES(:,11))./ALGEBRAIC(:,80);
ALGEBRAIC(:,19) =  3.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,35) =  2.00000.*ALGEBRAIC(:,10);
RATES(:,6) = (( ALGEBRAIC(:,19).*STATES(:,5))./ALGEBRAIC(:,80) - ( (ALGEBRAIC(:,23)+ALGEBRAIC(:,35)+ALGEBRAIC(:,78)).*STATES(:,6))./ALGEBRAIC(:,80))+( ALGEBRAIC(:,39).*STATES(:,7))./ALGEBRAIC(:,80)+( CONSTANTS(:,54).*STATES(:,10))./ALGEBRAIC(:,80);
ALGEBRAIC(:,15) =  4.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,31) =  1.00000.*ALGEBRAIC(:,10);
RATES(:,5) = (( ALGEBRAIC(:,15).*STATES(:,4))./ALGEBRAIC(:,80) - ( (ALGEBRAIC(:,19)+ALGEBRAIC(:,31)+ALGEBRAIC(:,78)).*STATES(:,5))./ALGEBRAIC(:,80))+( ALGEBRAIC(:,35).*STATES(:,6))./ALGEBRAIC(:,80)+( CONSTANTS(:,54).*STATES(:,9))./ALGEBRAIC(:,80);
RATES(:,4) = (  - (ALGEBRAIC(:,15)+ALGEBRAIC(:,78)).*STATES(:,4))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,31).*STATES(:,5))./ALGEBRAIC(:,80)+( CONSTANTS(:,54).*STATES(:,8))./ALGEBRAIC(:,80);
RATES(:,11) = ((( ALGEBRAIC(:,78).*STATES(:,7))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,23).*STATES(:,10))./ALGEBRAIC(:,80)) - ( (ALGEBRAIC(:,27)+ALGEBRAIC(:,39)+ALGEBRAIC(:,47)+ALGEBRAIC(:,51)+CONSTANTS(:,54)).*STATES(:,11))./ALGEBRAIC(:,80))+( ALGEBRAIC(:,43).*STATES(:,12))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,68).*STATES(:,15))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,71).*STATES(:,16))./ALGEBRAIC(:,80);
RATES(:,10) = ((( ALGEBRAIC(:,78).*STATES(:,6))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,19).*STATES(:,9))./ALGEBRAIC(:,80)) - ( (ALGEBRAIC(:,23)+ALGEBRAIC(:,35)+CONSTANTS(:,54)).*STATES(:,10))./ALGEBRAIC(:,80))+( ALGEBRAIC(:,39).*STATES(:,11))./ALGEBRAIC(:,80);
RATES(:,9) = ((( ALGEBRAIC(:,78).*STATES(:,5))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,15).*STATES(:,8))./ALGEBRAIC(:,80)) - ( (ALGEBRAIC(:,19)+ALGEBRAIC(:,31)+CONSTANTS(:,54)).*STATES(:,9))./ALGEBRAIC(:,80))+( ALGEBRAIC(:,35).*STATES(:,10))./ALGEBRAIC(:,80);
RATES(:,8) = (( ALGEBRAIC(:,78).*STATES(:,4))./ALGEBRAIC(:,80) - ( (ALGEBRAIC(:,15)+CONSTANTS(:,54)).*STATES(:,8))./ALGEBRAIC(:,80))+( ALGEBRAIC(:,31).*STATES(:,9))./ALGEBRAIC(:,80);
RATES(:,3) = (( ALGEBRAIC(:,27).*STATES(:,7))./ALGEBRAIC(:,80) - ( (ALGEBRAIC(:,43)+ALGEBRAIC(:,62)+ALGEBRAIC(:,65)+ALGEBRAIC(:,78)).*STATES(:,3))./ALGEBRAIC(:,80))+( ALGEBRAIC(:,55).*STATES(:,14))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,59).*STATES(:,13))./ALGEBRAIC(:,80)+( CONSTANTS(:,54).*STATES(:,12))./ALGEBRAIC(:,80);
RATES(:,12) = ((( ALGEBRAIC(:,78).*STATES(:,3))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,27).*STATES(:,11))./ALGEBRAIC(:,80)) - ( (ALGEBRAIC(:,43)+ALGEBRAIC(:,62)+ALGEBRAIC(:,65)+CONSTANTS(:,54)).*STATES(:,12))./ALGEBRAIC(:,80))+( ALGEBRAIC(:,55).*STATES(:,15))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,59).*STATES(:,16))./ALGEBRAIC(:,80);
ALGEBRAIC(:,76) = ALGEBRAIC(:,65);
ALGEBRAIC(:,74) = ( ALGEBRAIC(:,59).*ALGEBRAIC(:,62))./ALGEBRAIC(:,55);
RATES(:,13) = ((( ALGEBRAIC(:,51).*STATES(:,7))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,65).*STATES(:,3))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,76).*STATES(:,14))./ALGEBRAIC(:,80)) - ( (ALGEBRAIC(:,71)+ALGEBRAIC(:,59)+ALGEBRAIC(:,74)+ALGEBRAIC(:,78)).*STATES(:,13))./ALGEBRAIC(:,80))+( CONSTANTS(:,54).*STATES(:,16))./ALGEBRAIC(:,80);
RATES(:,14) = ((( ALGEBRAIC(:,47).*STATES(:,7))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,62).*STATES(:,3))./ALGEBRAIC(:,80)) - ( (ALGEBRAIC(:,68)+ALGEBRAIC(:,55)+ALGEBRAIC(:,76)+ALGEBRAIC(:,78)).*STATES(:,14))./ALGEBRAIC(:,80))+( ALGEBRAIC(:,74).*STATES(:,13))./ALGEBRAIC(:,80)+( CONSTANTS(:,54).*STATES(:,15))./ALGEBRAIC(:,80);
RATES(:,16) = (( ALGEBRAIC(:,78).*STATES(:,13))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,51).*STATES(:,11))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,65).*STATES(:,12))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,76).*STATES(:,15))./ALGEBRAIC(:,80)) - ( (ALGEBRAIC(:,71)+ALGEBRAIC(:,59)+ALGEBRAIC(:,74)+CONSTANTS(:,54)).*STATES(:,16))./ALGEBRAIC(:,80);
RATES(:,15) = ((( ALGEBRAIC(:,78).*STATES(:,14))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,47).*STATES(:,11))./ALGEBRAIC(:,80)+( ALGEBRAIC(:,62).*STATES(:,12))./ALGEBRAIC(:,80)) - ( (ALGEBRAIC(:,68)+ALGEBRAIC(:,55)+ALGEBRAIC(:,76)+CONSTANTS(:,54)).*STATES(:,15))./ALGEBRAIC(:,80))+( ALGEBRAIC(:,74).*STATES(:,16))./ALGEBRAIC(:,80);
RATES = RATES';
end

% Calculate algebraic variables
function ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI)
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((  - (STATES(:,1)+50.0000).*(STATES(:,1)+50.0000))./900.000)))./CONSTANTS(:,47);
ALGEBRAIC(:,25) =  CONSTANTS(:,53).*0.554320.*exp( - 0.0990740+ 0.0364410.*STATES(:,1));
ALGEBRAIC(:,29) =  CONSTANTS(:,53).*0.000525480.*exp( - 0.0691020+ 0.00319450.*STATES(:,1));
ALGEBRAIC(:,57) = STATES(:,33)+STATES(:,34)+STATES(:,35)+STATES(:,36)+STATES(:,37)+STATES(:,38);
ALGEBRAIC(:,21) =  CONSTANTS(:,53).*3.15660.*exp(0.363520+ 0.0771930.*STATES(:,1));
ALGEBRAIC(:,33) =  CONSTANTS(:,53).*1.44960.*exp( - 0.156600+ 0.0583530.*STATES(:,1));
ALGEBRAIC(:,17) =  CONSTANTS(:,53).*2.39100.*exp( - 13.3350 -  0.252890.*STATES(:,1));
ALGEBRAIC(:,37) =  CONSTANTS(:,53).*1.53290.*exp(0.00931930+ 0.0410750.*STATES(:,1));
ALGEBRAIC(:,49) =  CONSTANTS(:,53).*1.90460.*exp( - 2.48400+ 0.0204060.*STATES(:,1));
ALGEBRAIC(:,53) =  CONSTANTS(:,53).*0.000216880.*exp( - 0.0634380+ 0.00466830.*STATES(:,1));
ALGEBRAIC(:,13) =  CONSTANTS(:,53).*0.120520.*exp( - 9.60280+ 0.0830250.*STATES(:,1));
ALGEBRAIC(:,41) =  CONSTANTS(:,53).*1.61640.*exp(0.307630+ 0.00605350.*STATES(:,1));
ALGEBRAIC(:,8) =  CONSTANTS(:,53).*0.00392390.*exp(2.67930+ 0.00614680.*STATES(:,1));
ALGEBRAIC(:,45) =  CONSTANTS(:,53).*0.0277350.*exp(0.0514900 -  0.0468650.*STATES(:,1));
ALGEBRAIC(:,18) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./( 2.00000.*CONSTANTS(:,3))).*log(CONSTANTS(:,15)./STATES(:,2));
ALGEBRAIC(:,22) =  CONSTANTS(:,14).*STATES(:,3).*(STATES(:,1) - ALGEBRAIC(:,18));
ALGEBRAIC(:,26) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./( 2.00000.*CONSTANTS(:,3))).*log(CONSTANTS(:,15)./STATES(:,2));
ALGEBRAIC(:,30) =  CONSTANTS(:,17).*STATES(:,17).*STATES(:,18).*(STATES(:,1) - ALGEBRAIC(:,26));
ALGEBRAIC(:,58) = ( CONSTANTS(:,28).*( exp(( CONSTANTS(:,32).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,32), 3.00000).*CONSTANTS(:,15) -  2.50000.*exp(( (CONSTANTS(:,32) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(CONSTANTS(:,26), 3.00000).*STATES(:,2)))./( (power(CONSTANTS(:,30), 3.00000)+power(CONSTANTS(:,26), 3.00000)).*(CONSTANTS(:,29)+CONSTANTS(:,15)).*(1.00000+ CONSTANTS(:,31).*exp(( (CONSTANTS(:,32) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))));
ALGEBRAIC(:,50) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,26)./STATES(:,32));
ALGEBRAIC(:,54) =  CONSTANTS(:,25).*STATES(:,33).*(STATES(:,1) - ALGEBRAIC(:,50));
ALGEBRAIC(:,61) = ( CONSTANTS(:,33).*CONSTANTS(:,21).*STATES(:,32))./( (CONSTANTS(:,21)+CONSTANTS(:,34)).*(CONSTANTS(:,35)+STATES(:,32)).*(1.00000+ 0.124500.*exp((  - 0.100000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))+ 0.0353000.*exp((  - STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))));
ALGEBRAIC(:,64) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,26)./STATES(:,32));
ALGEBRAIC(:,67) =  CONSTANTS(:,36).*(STATES(:,1) - ALGEBRAIC(:,64));
ALGEBRAIC(:,1) = piecewise({VOI>= CONSTANTS(:,5).*0.00000&VOI<= CONSTANTS(:,5).*1.00000,  CONSTANTS(:,5).*0.00000 , VOI>= CONSTANTS(:,5).*1.00000&VOI<= CONSTANTS(:,5).*2.00000,  CONSTANTS(:,5).*1.00000 , VOI>= CONSTANTS(:,5).*2.00000&VOI< CONSTANTS(:,5).*3.00000,  CONSTANTS(:,5).*2.00000 , VOI>= CONSTANTS(:,5).*3.00000&VOI< CONSTANTS(:,5).*4.00000,  CONSTANTS(:,5).*3.00000 }, 0.00000);
ALGEBRAIC(:,9) = VOI - ALGEBRAIC(:,1);
ALGEBRAIC(:,14) = piecewise({ALGEBRAIC(:,9)<CONSTANTS(:,7),  CONSTANTS(:,6).*(STATES(:,1) - (CONSTANTS(:,12)+( CONSTANTS(:,13).*ALGEBRAIC(:,9))./CONSTANTS(:,11))) },  CONSTANTS(:,6).*(STATES(:,1) - (CONSTANTS(:,12)+( CONSTANTS(:,13).*(1.00000+exp( - CONSTANTS(:,10)./( 2.00000.*CONSTANTS(:,9)))).*1.00000)./(1.00000+exp(((ALGEBRAIC(:,9) - CONSTANTS(:,11)) -  0.500000.*CONSTANTS(:,10))./CONSTANTS(:,9))))));
ALGEBRAIC(:,34) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,21)./STATES(:,21));
ALGEBRAIC(:,38) =  CONSTANTS(:,20).*STATES(:,19).*STATES(:,20).*(STATES(:,1) - ALGEBRAIC(:,34));
ALGEBRAIC(:,42) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,21)./STATES(:,21));
ALGEBRAIC(:,46) =  CONSTANTS(:,24).*STATES(:,22).*(STATES(:,1) - ALGEBRAIC(:,42));
ALGEBRAIC(:,70) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,21)./STATES(:,21));
ALGEBRAIC(:,73) =  CONSTANTS(:,37).*(STATES(:,1) - ALGEBRAIC(:,70));
ALGEBRAIC(:,7) =  1.00000.*exp(( 8.47188.*STATES(:,1))./( 1.00000.*CONSTANTS(:,2)));
ALGEBRAIC(:,32) =  0.0443240.*ALGEBRAIC(:,7);
ALGEBRAIC(:,12) =  1.00000.*exp((  - 7.77556.*STATES(:,1))./( 1.00000.*CONSTANTS(:,2)));
ALGEBRAIC(:,52) =  0.000106000.*ALGEBRAIC(:,12);
ALGEBRAIC(:,66) =  1.00000.*CONSTANTS(:,50).*STATES(:,2);
ALGEBRAIC(:,79) = STATES(:,23)+STATES(:,24)+STATES(:,25)+STATES(:,26)+STATES(:,27)+STATES(:,28)+STATES(:,29)+STATES(:,30)+STATES(:,31)+STATES(:,22);
ALGEBRAIC(:,28) =  0.000781000.*ALGEBRAIC(:,7);
ALGEBRAIC(:,48) =  0.0953120.*ALGEBRAIC(:,12);
ALGEBRAIC(:,63) =  2.00000.*CONSTANTS(:,50).*STATES(:,2);
ALGEBRAIC(:,24) =  2.81000e-05.*ALGEBRAIC(:,7);
ALGEBRAIC(:,44) =  32.6594.*ALGEBRAIC(:,12);
ALGEBRAIC(:,60) =  3.00000.*CONSTANTS(:,50).*STATES(:,2);
ALGEBRAIC(:,20) =  0.000869000.*ALGEBRAIC(:,7);
ALGEBRAIC(:,40) =  144.174.*ALGEBRAIC(:,12);
ALGEBRAIC(:,56) =  4.00000.*CONSTANTS(:,50).*STATES(:,2);
ALGEBRAIC(:,16) =  0.0216200.*ALGEBRAIC(:,7);
ALGEBRAIC(:,36) =  318.108.*ALGEBRAIC(:,12);
ALGEBRAIC(:,77) =  1.00000.*CONSTANTS(:,50).*STATES(:,2);
ALGEBRAIC(:,75) =  2.00000.*CONSTANTS(:,50).*STATES(:,2);
ALGEBRAIC(:,72) =  3.00000.*CONSTANTS(:,50).*STATES(:,2);
ALGEBRAIC(:,69) =  4.00000.*CONSTANTS(:,50).*STATES(:,2);
ALGEBRAIC(:,2) =  CONSTANTS(:,45).*0.731000.*exp(STATES(:,1)./30.0000);
ALGEBRAIC(:,23) =  2.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,27) =  1.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,10) =  CONSTANTS(:,45).*0.214900.*exp( - STATES(:,1)./40.0000);
ALGEBRAIC(:,39) =  3.00000.*ALGEBRAIC(:,10);
ALGEBRAIC(:,43) =  4.00000.*ALGEBRAIC(:,10);
ALGEBRAIC(:,78) = ( CONSTANTS(:,45).*4.00000)./(1.00000+1.00000./STATES(:,2));
ALGEBRAIC(:,51) =  CONSTANTS(:,45).*0.0595600.*exp( - STATES(:,1)./40.0000);
ALGEBRAIC(:,47) =  CONSTANTS(:,45).*0.474200.*exp(STATES(:,1)./10.0000);
ALGEBRAIC(:,65) =  CONSTANTS(:,45).*0.00232000.*exp( - STATES(:,1)./280.000);
ALGEBRAIC(:,59) =  CONSTANTS(:,45).*0.0121300.*exp(STATES(:,1)./500.000);
ALGEBRAIC(:,71) = ( ALGEBRAIC(:,43).*ALGEBRAIC(:,59).*ALGEBRAIC(:,51))./( ALGEBRAIC(:,27).*ALGEBRAIC(:,65));
ALGEBRAIC(:,62) =  CONSTANTS(:,45).*0.0219700.*exp(STATES(:,1)./500.000);
ALGEBRAIC(:,55) =  CONSTANTS(:,45).*0.0140700.*exp( - STATES(:,1)./300.000);
ALGEBRAIC(:,68) = ( ALGEBRAIC(:,43).*ALGEBRAIC(:,55).*ALGEBRAIC(:,47))./( ALGEBRAIC(:,27).*ALGEBRAIC(:,62));
ALGEBRAIC(:,80) = STATES(:,7)+STATES(:,6)+STATES(:,5)+STATES(:,4)+STATES(:,11)+STATES(:,10)+STATES(:,9)+STATES(:,8)+STATES(:,3)+STATES(:,12)+STATES(:,13)+STATES(:,14)+STATES(:,16)+STATES(:,15);
ALGEBRAIC(:,19) =  3.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,35) =  2.00000.*ALGEBRAIC(:,10);
ALGEBRAIC(:,15) =  4.00000.*ALGEBRAIC(:,2);
ALGEBRAIC(:,31) =  1.00000.*ALGEBRAIC(:,10);
ALGEBRAIC(:,76) = ALGEBRAIC(:,65);
ALGEBRAIC(:,74) = ( ALGEBRAIC(:,59).*ALGEBRAIC(:,62))./ALGEBRAIC(:,55);
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 Poh, 2012 at changeset 713cd2940e5d.
Collaboration
To begin collaborating on this work, please use your git client and issue this command: