# 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 34 entries in each of the rate and state variable arrays.
% There are a total of 102 entries in the constant variable array.
%

function [VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel()
% Create ALGEBRAIC of correct size
global algebraicVariableCount;  algebraicVariableCount = getAlgebraicVariableCount();
% Initialise constants and state variables
[INIT_STATES, CONSTANTS] = initConsts;

% Set timespan to solve over
tspan = [0, 10];

% Set numerical accuracy options for ODE solver
options = odeset('RelTol', 1e-06, 'AbsTol', 1e-06, 'MaxStep', 1);

% Solve model with ODE solver
[VOI, STATES] = ode15s(@(VOI, STATES)computeRates(VOI, STATES, CONSTANTS), tspan, INIT_STATES, options);

% Compute algebraic variables
[RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS);
ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI);

% Plot state variables against variable of integration
[LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends();
figure();
plot(VOI, STATES);
xlabel(LEGEND_VOI);
l = legend(LEGEND_STATES);
set(l,'Interpreter','none');
end

function [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends()
LEGEND_STATES = ''; LEGEND_ALGEBRAIC = ''; LEGEND_VOI = ''; LEGEND_CONSTANTS = '';
LEGEND_VOI = strpad('time in component environment (second)');
LEGEND_STATES(:,1) = strpad('V in component membrane (millivolt)');
LEGEND_CONSTANTS(:,1) = strpad('R in component membrane (joule_per_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('C_sc in component membrane (microF_per_cm2)');
LEGEND_ALGEBRAIC(:,11) = strpad('i_Stim in component membrane (microA_per_microF)');
LEGEND_ALGEBRAIC(:,27) = strpad('i_Na in component fast_sodium_current (microA_per_microF)');
LEGEND_ALGEBRAIC(:,50) = strpad('i_Ca in component L_type_Ca_current (microA_per_microF)');
LEGEND_ALGEBRAIC(:,51) = strpad('i_Ca_K in component L_type_Ca_current (microA_per_microF)');
LEGEND_ALGEBRAIC(:,32) = strpad('i_Kr in component rapid_activating_delayed_rectifiyer_K_current (microA_per_microF)');
LEGEND_ALGEBRAIC(:,34) = strpad('i_Ks in component slow_activating_delayed_rectifiyer_K_current (microA_per_microF)');
LEGEND_ALGEBRAIC(:,35) = strpad('i_to1 in component transient_outward_potassium_current (microA_per_microF)');
LEGEND_ALGEBRAIC(:,37) = strpad('i_K1 in component time_independent_potassium_current (microA_per_microF)');
LEGEND_ALGEBRAIC(:,39) = strpad('i_Kp in component plateau_potassium_current (microA_per_microF)');
LEGEND_ALGEBRAIC(:,40) = strpad('i_NaCa in component Na_Ca_exchanger (microA_per_microF)');
LEGEND_ALGEBRAIC(:,42) = strpad('i_NaK in component sodium_potassium_pump (microA_per_microF)');
LEGEND_ALGEBRAIC(:,44) = strpad('i_p_Ca in component sarcolemmal_calcium_pump (microA_per_microF)');
LEGEND_ALGEBRAIC(:,46) = strpad('i_Ca_b in component calcium_background_current (microA_per_microF)');
LEGEND_ALGEBRAIC(:,47) = strpad('i_Na_b in component sodium_background_current (microA_per_microF)');
LEGEND_ALGEBRAIC(:,80) = strpad('i_K_ATP in component ATP_sensitive_potassium_current (microA_per_microF)');
LEGEND_CONSTANTS(:,5) = strpad('stim_start in component membrane (second)');
LEGEND_CONSTANTS(:,6) = strpad('stim_end in component membrane (second)');
LEGEND_CONSTANTS(:,7) = strpad('stim_period in component membrane (second)');
LEGEND_CONSTANTS(:,8) = strpad('stim_duration in component membrane (second)');
LEGEND_CONSTANTS(:,9) = strpad('stim_amplitude in component membrane (microA_per_microF)');
LEGEND_ALGEBRAIC(:,22) = strpad('E_Na in component fast_sodium_current (millivolt)');
LEGEND_CONSTANTS(:,10) = strpad('g_Na in component fast_sodium_current (milliS_per_microF)');
LEGEND_CONSTANTS(:,11) = strpad('Na_o in component extracellular_ion_concentrations (millimolar)');
LEGEND_STATES(:,2) = strpad('Na_i in component intracellular_ion_concentrations (millimolar)');
LEGEND_STATES(:,3) = strpad('m in component fast_sodium_current_m_gate (dimensionless)');
LEGEND_STATES(:,4) = strpad('h in component fast_sodium_current_h_gate (dimensionless)');
LEGEND_STATES(:,5) = strpad('j in component fast_sodium_current_j_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,12) = strpad('alpha_m in component fast_sodium_current_m_gate (per_second)');
LEGEND_ALGEBRAIC(:,23) = strpad('beta_m in component fast_sodium_current_m_gate (per_second)');
LEGEND_ALGEBRAIC(:,1) = strpad('E0_m in component fast_sodium_current_m_gate (millivolt)');
LEGEND_ALGEBRAIC(:,2) = strpad('alpha_h in component fast_sodium_current_h_gate (per_second)');
LEGEND_ALGEBRAIC(:,13) = strpad('beta_h in component fast_sodium_current_h_gate (per_second)');
LEGEND_ALGEBRAIC(:,3) = strpad('alpha_j in component fast_sodium_current_j_gate (per_second)');
LEGEND_ALGEBRAIC(:,14) = strpad('beta_j in component fast_sodium_current_j_gate (per_second)');
LEGEND_ALGEBRAIC(:,30) = strpad('E_K in component rapid_activating_delayed_rectifiyer_K_current (millivolt)');
LEGEND_CONSTANTS(:,12) = strpad('g_Kr in component rapid_activating_delayed_rectifiyer_K_current (milliS_per_microF)');
LEGEND_CONSTANTS(:,100) = strpad('f_K_o in component rapid_activating_delayed_rectifiyer_K_current (dimensionless)');
LEGEND_ALGEBRAIC(:,31) = strpad('R_V in component rapid_activating_delayed_rectifiyer_K_current (dimensionless)');
LEGEND_CONSTANTS(:,13) = strpad('K_o in component extracellular_ion_concentrations (millimolar)');
LEGEND_STATES(:,6) = strpad('K_i in component intracellular_ion_concentrations (millimolar)');
LEGEND_STATES(:,7) = strpad('X_kr in component rapid_activating_delayed_rectifiyer_K_current_X_kr_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,4) = strpad('K12 in component rapid_activating_delayed_rectifiyer_K_current_X_kr_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,15) = strpad('K21 in component rapid_activating_delayed_rectifiyer_K_current_X_kr_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,24) = strpad('X_kr_inf in component rapid_activating_delayed_rectifiyer_K_current_X_kr_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,28) = strpad('tau_X_kr in component rapid_activating_delayed_rectifiyer_K_current_X_kr_gate (second)');
LEGEND_CONSTANTS(:,14) = strpad('tau_factor in component rapid_activating_delayed_rectifiyer_K_current_X_kr_gate (dimensionless)');
LEGEND_CONSTANTS(:,15) = strpad('g_Ks in component slow_activating_delayed_rectifiyer_K_current (milliS_per_microF)');
LEGEND_ALGEBRAIC(:,33) = strpad('E_Ks in component slow_activating_delayed_rectifiyer_K_current (millivolt)');
LEGEND_STATES(:,8) = strpad('X_ks in component slow_activating_delayed_rectifiyer_K_current_X_ks_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,16) = strpad('tau_X_ks in component slow_activating_delayed_rectifiyer_K_current_X_ks_gate (second)');
LEGEND_ALGEBRAIC(:,5) = strpad('X_ks_infinity in component slow_activating_delayed_rectifiyer_K_current_X_ks_gate (dimensionless)');
LEGEND_CONSTANTS(:,16) = strpad('g_to1 in component transient_outward_potassium_current (milliS_per_microF)');
LEGEND_STATES(:,9) = strpad('X_to1 in component transient_outward_potassium_current_X_to1_gate (dimensionless)');
LEGEND_STATES(:,10) = strpad('Y_to1 in component transient_outward_potassium_current_Y_to1_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,6) = strpad('alpha_X_to1 in component transient_outward_potassium_current_X_to1_gate (per_second)');
LEGEND_ALGEBRAIC(:,17) = strpad('beta_X_to1 in component transient_outward_potassium_current_X_to1_gate (per_second)');
LEGEND_ALGEBRAIC(:,7) = strpad('alpha_Y_to1 in component transient_outward_potassium_current_Y_to1_gate (per_second)');
LEGEND_ALGEBRAIC(:,18) = strpad('beta_Y_to1 in component transient_outward_potassium_current_Y_to1_gate (per_second)');
LEGEND_CONSTANTS(:,17) = strpad('g_K1 in component time_independent_potassium_current (milliS_per_microF)');
LEGEND_CONSTANTS(:,18) = strpad('K_mK1 in component time_independent_potassium_current (millimolar)');
LEGEND_ALGEBRAIC(:,36) = strpad('K1_infinity_V in component time_independent_potassium_current_K1_gate (dimensionless)');
LEGEND_CONSTANTS(:,19) = strpad('g_Kp in component plateau_potassium_current (milliS_per_microF)');
LEGEND_ALGEBRAIC(:,38) = strpad('Kp_V in component plateau_potassium_current_Kp_gate (dimensionless)');
LEGEND_CONSTANTS(:,20) = strpad('K_mCa in component Na_Ca_exchanger (millimolar)');
LEGEND_CONSTANTS(:,21) = strpad('K_mNa in component Na_Ca_exchanger (millimolar)');
LEGEND_CONSTANTS(:,22) = strpad('K_NaCa in component Na_Ca_exchanger (microA_per_microF)');
LEGEND_CONSTANTS(:,23) = strpad('K_sat in component Na_Ca_exchanger (dimensionless)');
LEGEND_CONSTANTS(:,24) = strpad('eta in component Na_Ca_exchanger (dimensionless)');
LEGEND_STATES(:,11) = strpad('Ca_i in component intracellular_ion_concentrations (millimolar)');
LEGEND_CONSTANTS(:,25) = strpad('Ca_o in component extracellular_ion_concentrations (millimolar)');
LEGEND_CONSTANTS(:,26) = strpad('I_NaK in component sodium_potassium_pump (microA_per_microF)');
LEGEND_ALGEBRAIC(:,41) = strpad('f_NaK in component sodium_potassium_pump (dimensionless)');
LEGEND_CONSTANTS(:,27) = strpad('K_mNa_i in component sodium_potassium_pump (millimolar)');
LEGEND_CONSTANTS(:,28) = strpad('K_mK_o in component sodium_potassium_pump (millimolar)');
LEGEND_CONSTANTS(:,101) = strpad('sigma in component sodium_potassium_pump (dimensionless)');
LEGEND_ALGEBRAIC(:,43) = strpad('i_p_Ca_winslow in component sarcolemmal_calcium_pump (microA_per_microF)');
LEGEND_CONSTANTS(:,29) = strpad('K_mpCa in component sarcolemmal_calcium_pump (millimolar)');
LEGEND_CONSTANTS(:,30) = strpad('I_pCa in component sarcolemmal_calcium_pump (microA_per_microF)');
LEGEND_STATES(:,12) = strpad('MgATP_i in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_CONSTANTS(:,31) = strpad('MgATP_i0 in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_CONSTANTS(:,32) = strpad('g_Cab in component calcium_background_current (milliS_per_microF)');
LEGEND_ALGEBRAIC(:,45) = strpad('E_Ca in component calcium_background_current (millivolt)');
LEGEND_CONSTANTS(:,33) = strpad('g_Nab in component sodium_background_current (milliS_per_microF)');
LEGEND_CONSTANTS(:,34) = strpad('P_Ca in component L_type_Ca_current (cm_per_second)');
LEGEND_CONSTANTS(:,35) = strpad('p_prime_k in component L_type_Ca_current (cm_per_second)');
LEGEND_ALGEBRAIC(:,49) = strpad('f_Ca in component L_type_Ca_current (dimensionless)');
LEGEND_ALGEBRAIC(:,48) = strpad('P_rom in component L_type_Ca_current (dimensionless)');
LEGEND_CONSTANTS(:,36) = strpad('k_MgATP_ss in component L_type_Ca_current (millimolar)');
LEGEND_ALGEBRAIC(:,8) = strpad('alpha in component L_type_Ca_current (per_second)');
LEGEND_ALGEBRAIC(:,19) = strpad('beta in component L_type_Ca_current (per_second)');
LEGEND_ALGEBRAIC(:,9) = strpad('gamma in component L_type_Ca_current (per_second)');
LEGEND_ALGEBRAIC(:,25) = strpad('v_gamma in component L_type_Ca_current (per_second)');
LEGEND_ALGEBRAIC(:,26) = strpad('alpha_prime in component L_type_Ca_current (per_second)');
LEGEND_ALGEBRAIC(:,29) = strpad('beta_prime in component L_type_Ca_current (per_second)');
LEGEND_CONSTANTS(:,37) = strpad('a in component L_type_Ca_current (dimensionless)');
LEGEND_CONSTANTS(:,38) = strpad('b in component L_type_Ca_current (dimensionless)');
LEGEND_CONSTANTS(:,39) = strpad('g in component L_type_Ca_current (per_second)');
LEGEND_CONSTANTS(:,40) = strpad('f in component L_type_Ca_current (per_second)');
LEGEND_ALGEBRAIC(:,20) = strpad('v_omega in component L_type_Ca_current (per_second)');
LEGEND_CONSTANTS(:,41) = strpad('omega in component L_type_Ca_current (per_second)');
LEGEND_CONSTANTS(:,102) = strpad('x in component L_type_Ca_current (dimensionless)');
LEGEND_STATES(:,13) = strpad('z in component L_type_Ca_current (dimensionless)');
LEGEND_STATES(:,14) = strpad('v in component L_type_Ca_current (dimensionless)');
LEGEND_STATES(:,15) = strpad('w in component L_type_Ca_current (dimensionless)');
LEGEND_STATES(:,16) = strpad('Ca_ss in component intracellular_ion_concentrations (millimolar)');
LEGEND_STATES(:,17) = strpad('MgATP_ss in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_STATES(:,18) = strpad('y in component L_type_Ca_current_y_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,10) = strpad('y_infinity in component L_type_Ca_current_y_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,21) = strpad('tau_y in component L_type_Ca_current_y_gate (second)');
LEGEND_ALGEBRAIC(:,76) = strpad('g_K_ATP in component ATP_sensitive_potassium_current (milliS_per_microF)');
LEGEND_CONSTANTS(:,42) = strpad('G_K_ATP in component ATP_sensitive_potassium_current (milliS_per_microF)');
LEGEND_ALGEBRAIC(:,74) = strpad('f_K_ATP in component ATP_sensitive_potassium_current (dimensionless)');
LEGEND_ALGEBRAIC(:,70) = strpad('f_ATP in component ATP_sensitive_potassium_current (dimensionless)');
LEGEND_CONSTANTS(:,43) = strpad('k_ATP in component ATP_sensitive_potassium_current (millimolar)');
LEGEND_CONSTANTS(:,45) = strpad('K_o_normal in component ATP_sensitive_potassium_current (millimolar)');
LEGEND_CONSTANTS(:,46) = strpad('go in component ATP_sensitive_potassium_current (dimensionless)');
LEGEND_CONSTANTS(:,47) = strpad('gd in component ATP_sensitive_potassium_current (dimensionless)');
LEGEND_ALGEBRAIC(:,69) = strpad('ATP_i in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_ALGEBRAIC(:,55) = strpad('J_rel in component RyR_channel (millimolar_per_second)');
LEGEND_CONSTANTS(:,48) = strpad('v1 in component RyR_channel (per_second)');
LEGEND_CONSTANTS(:,49) = strpad('k_a_plus in component RyR_channel (millimolar4_per_second)');
LEGEND_CONSTANTS(:,50) = strpad('k_a_minus in component RyR_channel (per_second)');
LEGEND_CONSTANTS(:,51) = strpad('k_b_plus in component RyR_channel (millimolar3_per_second)');
LEGEND_CONSTANTS(:,52) = strpad('k_b_minus in component RyR_channel (per_second)');
LEGEND_CONSTANTS(:,53) = strpad('k_c_plus in component RyR_channel (per_second)');
LEGEND_CONSTANTS(:,54) = strpad('k_c_minus in component RyR_channel (per_second)');
LEGEND_STATES(:,20) = strpad('P_O1 in component RyR_channel (dimensionless)');
LEGEND_STATES(:,21) = strpad('P_O2 in component RyR_channel (dimensionless)');
LEGEND_STATES(:,22) = strpad('P_C1 in component RyR_channel (dimensionless)');
LEGEND_STATES(:,23) = strpad('P_C2 in component RyR_channel (dimensionless)');
LEGEND_CONSTANTS(:,55) = strpad('n in component RyR_channel (dimensionless)');
LEGEND_CONSTANTS(:,56) = strpad('m in component RyR_channel (dimensionless)');
LEGEND_STATES(:,24) = strpad('Ca_JSR in component intracellular_ion_concentrations (millimolar)');
LEGEND_ALGEBRAIC(:,59) = strpad('J_up in component SERCA2a_pump (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,58) = strpad('J_up_winslow in component SERCA2a_pump (millimolar_per_second)');
LEGEND_CONSTANTS(:,57) = strpad('K_fb in component SERCA2a_pump (millimolar)');
LEGEND_CONSTANTS(:,58) = strpad('K_rb in component SERCA2a_pump (millimolar)');
LEGEND_ALGEBRAIC(:,56) = strpad('fb in component SERCA2a_pump (dimensionless)');
LEGEND_ALGEBRAIC(:,57) = strpad('rb in component SERCA2a_pump (dimensionless)');
LEGEND_CONSTANTS(:,59) = strpad('Vmaxf in component SERCA2a_pump (millimolar_per_second)');
LEGEND_CONSTANTS(:,60) = strpad('Vmaxr in component SERCA2a_pump (millimolar_per_second)');
LEGEND_CONSTANTS(:,61) = strpad('K_SR in component SERCA2a_pump (dimensionless)');
LEGEND_CONSTANTS(:,62) = strpad('N_fb in component SERCA2a_pump (dimensionless)');
LEGEND_CONSTANTS(:,63) = strpad('N_rb in component SERCA2a_pump (dimensionless)');
LEGEND_STATES(:,25) = strpad('Ca_NSR in component intracellular_ion_concentrations (millimolar)');
LEGEND_ALGEBRAIC(:,61) = strpad('J_tr in component intracellular_Ca_fluxes (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,60) = strpad('J_xfer in component intracellular_Ca_fluxes (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,65) = strpad('J_trpn in component intracellular_Ca_fluxes (millimolar_per_second)');
LEGEND_CONSTANTS(:,64) = strpad('tau_tr in component intracellular_Ca_fluxes (second)');
LEGEND_CONSTANTS(:,65) = strpad('tau_xfer in component intracellular_Ca_fluxes (second)');
LEGEND_STATES(:,26) = strpad('HTRPNCa in component intracellular_Ca_fluxes (millimolar)');
LEGEND_STATES(:,27) = strpad('LTRPNCa in component intracellular_Ca_fluxes (millimolar)');
LEGEND_ALGEBRAIC(:,63) = strpad('J_HTRPNCa in component intracellular_Ca_fluxes (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,64) = strpad('J_LTRPNCa in component intracellular_Ca_fluxes (millimolar_per_second)');
LEGEND_CONSTANTS(:,66) = strpad('HTRPN_tot in component intracellular_Ca_fluxes (dimensionless)');
LEGEND_CONSTANTS(:,67) = strpad('LTRPN_tot in component intracellular_Ca_fluxes (dimensionless)');
LEGEND_CONSTANTS(:,68) = strpad('k_htrpn_plus in component intracellular_Ca_fluxes (per_millimolar_second)');
LEGEND_CONSTANTS(:,69) = strpad('k_htrpn_minus in component intracellular_Ca_fluxes (per_second)');
LEGEND_CONSTANTS(:,70) = strpad('k_ltrpn_plus in component intracellular_Ca_fluxes (per_millimolar_second)');
LEGEND_CONSTANTS(:,71) = strpad('k_ltrpn_minus in component intracellular_Ca_fluxes (per_second)');
LEGEND_CONSTANTS(:,72) = strpad('A_cap in component intracellular_ion_concentrations (cm2)');
LEGEND_CONSTANTS(:,73) = strpad('V_myo in component intracellular_ion_concentrations (microlitre)');
LEGEND_CONSTANTS(:,74) = strpad('V_JSR in component intracellular_ion_concentrations (microlitre)');
LEGEND_CONSTANTS(:,75) = strpad('V_NSR in component intracellular_ion_concentrations (microlitre)');
LEGEND_CONSTANTS(:,76) = strpad('V_ss in component intracellular_ion_concentrations (microlitre)');
LEGEND_CONSTANTS(:,77) = strpad('K_mCMDN in component intracellular_ion_concentrations (millimolar)');
LEGEND_CONSTANTS(:,78) = strpad('K_mEGTA in component intracellular_ion_concentrations (millimolar)');
LEGEND_CONSTANTS(:,79) = strpad('K_mCSQN in component intracellular_ion_concentrations (millimolar)');
LEGEND_CONSTANTS(:,80) = strpad('CMDN_tot in component intracellular_ion_concentrations (millimolar)');
LEGEND_CONSTANTS(:,81) = strpad('EGTA_tot in component intracellular_ion_concentrations (millimolar)');
LEGEND_CONSTANTS(:,82) = strpad('CSQN_tot in component intracellular_ion_concentrations (millimolar)');
LEGEND_ALGEBRAIC(:,66) = strpad('beta_i in component intracellular_ion_concentrations (dimensionless)');
LEGEND_ALGEBRAIC(:,67) = strpad('beta_SS in component intracellular_ion_concentrations (dimensionless)');
LEGEND_ALGEBRAIC(:,62) = strpad('beta_JSR in component intracellular_ion_concentrations (dimensionless)');
LEGEND_CONSTANTS(:,83) = strpad('k_plus_CaATP in component Ca_and_Mg_buffering_by_ATP (per_millimolar_second)');
LEGEND_CONSTANTS(:,84) = strpad('k_minus_CaATP in component Ca_and_Mg_buffering_by_ATP (per_second)');
LEGEND_STATES(:,30) = strpad('CaATP_ss in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_ALGEBRAIC(:,68) = strpad('ATP_ss in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_STATES(:,31) = strpad('CaATP_i in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_STATES(:,32) = strpad('Mg_ss in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_STATES(:,33) = strpad('Mg_i in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_CONSTANTS(:,87) = strpad('ATP_tot in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_CONSTANTS(:,88) = strpad('k_plus_MgATP in component Ca_and_Mg_buffering_by_ATP (per_millimolar_second)');
LEGEND_CONSTANTS(:,89) = strpad('k_minus_MgATP in component Ca_and_Mg_buffering_by_ATP (per_second)');
LEGEND_ALGEBRAIC(:,72) = strpad('Jxfer_CaATP in component Ca_and_Mg_buffering_by_ATP (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,73) = strpad('Jxfer_MgATP in component Ca_and_Mg_buffering_by_ATP (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,77) = strpad('Jxfer_Mg in component Ca_and_Mg_buffering_by_ATP (millimolar_per_second)');
LEGEND_CONSTANTS(:,90) = strpad('tau_xfer_CaATP in component Ca_and_Mg_buffering_by_ATP (second)');
LEGEND_CONSTANTS(:,91) = strpad('tau_xfer_MgATP in component Ca_and_Mg_buffering_by_ATP (second)');
LEGEND_CONSTANTS(:,92) = strpad('tau_xfer_Mg in component Ca_and_Mg_buffering_by_ATP (second)');
LEGEND_CONSTANTS(:,98) = strpad('V_myo in component model_parameters (microlitre)');
LEGEND_CONSTANTS(:,99) = strpad('V_ss in component model_parameters (microlitre)');
LEGEND_RATES(:,1) = strpad('d/dt V in component membrane (millivolt)');
LEGEND_RATES(:,3) = strpad('d/dt m in component fast_sodium_current_m_gate (dimensionless)');
LEGEND_RATES(:,4) = strpad('d/dt h in component fast_sodium_current_h_gate (dimensionless)');
LEGEND_RATES(:,5) = strpad('d/dt j in component fast_sodium_current_j_gate (dimensionless)');
LEGEND_RATES(:,7) = strpad('d/dt X_kr in component rapid_activating_delayed_rectifiyer_K_current_X_kr_gate (dimensionless)');
LEGEND_RATES(:,8) = strpad('d/dt X_ks in component slow_activating_delayed_rectifiyer_K_current_X_ks_gate (dimensionless)');
LEGEND_RATES(:,9) = strpad('d/dt X_to1 in component transient_outward_potassium_current_X_to1_gate (dimensionless)');
LEGEND_RATES(:,10) = strpad('d/dt Y_to1 in component transient_outward_potassium_current_Y_to1_gate (dimensionless)');
LEGEND_RATES(:,14) = strpad('d/dt v in component L_type_Ca_current (dimensionless)');
LEGEND_RATES(:,15) = strpad('d/dt w in component L_type_Ca_current (dimensionless)');
LEGEND_RATES(:,13) = strpad('d/dt z in component L_type_Ca_current (dimensionless)');
LEGEND_RATES(:,18) = strpad('d/dt y in component L_type_Ca_current_y_gate (dimensionless)');
LEGEND_RATES(:,22) = strpad('d/dt P_C1 in component RyR_channel (dimensionless)');
LEGEND_RATES(:,20) = strpad('d/dt P_O1 in component RyR_channel (dimensionless)');
LEGEND_RATES(:,21) = strpad('d/dt P_O2 in component RyR_channel (dimensionless)');
LEGEND_RATES(:,23) = strpad('d/dt P_C2 in component RyR_channel (dimensionless)');
LEGEND_RATES(:,26) = strpad('d/dt HTRPNCa in component intracellular_Ca_fluxes (millimolar)');
LEGEND_RATES(:,27) = strpad('d/dt LTRPNCa in component intracellular_Ca_fluxes (millimolar)');
LEGEND_RATES(:,11) = strpad('d/dt Ca_i in component intracellular_ion_concentrations (millimolar)');
LEGEND_RATES(:,2) = strpad('d/dt Na_i in component intracellular_ion_concentrations (millimolar)');
LEGEND_RATES(:,6) = strpad('d/dt K_i in component intracellular_ion_concentrations (millimolar)');
LEGEND_RATES(:,16) = strpad('d/dt Ca_ss in component intracellular_ion_concentrations (millimolar)');
LEGEND_RATES(:,24) = strpad('d/dt Ca_JSR in component intracellular_ion_concentrations (millimolar)');
LEGEND_RATES(:,25) = strpad('d/dt Ca_NSR in component intracellular_ion_concentrations (millimolar)');
LEGEND_RATES(:,30) = strpad('d/dt CaATP_ss in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_RATES(:,17) = strpad('d/dt MgATP_ss in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_RATES(:,31) = strpad('d/dt CaATP_i in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_RATES(:,12) = strpad('d/dt MgATP_i in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_RATES(:,32) = strpad('d/dt Mg_ss in component Ca_and_Mg_buffering_by_ATP (millimolar)');
LEGEND_RATES(:,33) = strpad('d/dt Mg_i in component Ca_and_Mg_buffering_by_ATP (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) = -96.1638;
CONSTANTS(:,1) = 8.314472;
CONSTANTS(:,2) = 310;
CONSTANTS(:,3) = 96.4853415;
CONSTANTS(:,4) = 0.001;
CONSTANTS(:,5) = 0.1;
CONSTANTS(:,6) = 100000000;
CONSTANTS(:,7) = 1;
CONSTANTS(:,8) = 0.0005;
CONSTANTS(:,9) = -100.0;
CONSTANTS(:,10) = 12.8;
CONSTANTS(:,11) = 138;
STATES(:,2) = 10;
STATES(:,3) = 0.0328302;
STATES(:,4) = 0.988354;
STATES(:,5) = 0.99254;
CONSTANTS(:,12) = 0.0034;
CONSTANTS(:,13) = 4;
STATES(:,6) = 159.48;
STATES(:,7) = 0.51;
CONSTANTS(:,14) = 1;
CONSTANTS(:,15) = 0.0027134;
STATES(:,8) = 0.264;
CONSTANTS(:,16) = 0.23815;
STATES(:,9) = 2.63;
STATES(:,10) = 0.99;
CONSTANTS(:,17) = 2.8;
CONSTANTS(:,18) = 13;
CONSTANTS(:,19) = 0.002216;
CONSTANTS(:,20) = 1.38;
CONSTANTS(:,21) = 87.5;
CONSTANTS(:,22) = 0.3;
CONSTANTS(:,23) = 0.2;
CONSTANTS(:,24) = 0.35;
STATES(:,11) = 8.464E-5;
CONSTANTS(:,25) = 2;
CONSTANTS(:,26) = 0.693;
CONSTANTS(:,27) = 10;
CONSTANTS(:,28) = 1.5;
CONSTANTS(:,29) = 0.00005;
CONSTANTS(:,30) = 0.05;
STATES(:,12) = 6.4395;
CONSTANTS(:,31) = 2.888;
CONSTANTS(:,32) = 0.0003842;
CONSTANTS(:,33) = 0.0031;
CONSTANTS(:,34) = 3.594e-4;
CONSTANTS(:,35) = 6.658e-7;
CONSTANTS(:,36) = 1.4;
CONSTANTS(:,37) = 2;
CONSTANTS(:,38) = 2;
CONSTANTS(:,39) = 2000;
CONSTANTS(:,40) = 300;
CONSTANTS(:,41) = 10;
STATES(:,13) = 0.1;
STATES(:,14) = 0.1;
STATES(:,15) = 0.1;
STATES(:,16) = 1.315E-4;
STATES(:,17) = 6.4395;
STATES(:,18) = 0.798;
CONSTANTS(:,42) = 0.05;
CONSTANTS(:,43) = 0.6;
CONSTANTS(:,44) = 0.4;
CONSTANTS(:,45) = 4.5;
CONSTANTS(:,46) = 0.08;
CONSTANTS(:,47) = 0.89;
STATES(:,19) = 0.298E-2;
CONSTANTS(:,48) = 1800;
CONSTANTS(:,49) = 1.215e13;
CONSTANTS(:,50) = 576;
CONSTANTS(:,51) = 4.05e9;
CONSTANTS(:,52) = 1930;
CONSTANTS(:,53) = 100;
CONSTANTS(:,54) = 0.8;
STATES(:,20) = 0;
STATES(:,21) = 0;
STATES(:,22) = 0.47;
STATES(:,23) = 0.53;
CONSTANTS(:,55) = 4;
CONSTANTS(:,56) = 3;
STATES(:,24) = 0.2616;
CONSTANTS(:,57) = 0.000168;
CONSTANTS(:,58) = 3.29;
CONSTANTS(:,59) = 0.0813;
CONSTANTS(:,60) = 0.318;
CONSTANTS(:,61) = 1;
CONSTANTS(:,62) = 1.2;
CONSTANTS(:,63) = 1;
STATES(:,25) = 0.2620;
CONSTANTS(:,64) = 0.0005747;
CONSTANTS(:,65) = 0.0267;
STATES(:,26) = 0.98;
STATES(:,27) = 0.078;
CONSTANTS(:,66) = 0.14;
CONSTANTS(:,67) = 0.07;
CONSTANTS(:,68) = 20000;
CONSTANTS(:,69) = 0.066;
CONSTANTS(:,70) = 40000;
CONSTANTS(:,71) = 40;
CONSTANTS(:,72) = 0.0001534;
CONSTANTS(:,73) = 0.00002584;
CONSTANTS(:,74) = 0.00000016;
CONSTANTS(:,75) = 0.0000021;
CONSTANTS(:,76) = 0.0000000012;
CONSTANTS(:,77) = 0.00238;
CONSTANTS(:,78) = 0.00015;
CONSTANTS(:,79) = 0.8;
CONSTANTS(:,80) = 0.05;
CONSTANTS(:,81) = 0;
CONSTANTS(:,82) = 15;
CONSTANTS(:,83) = 225000.0;
CONSTANTS(:,84) = 45000.0;
CONSTANTS(:,85) = 125000.0;
CONSTANTS(:,86) = 193500;
STATES(:,28) = 0.11E-6;
STATES(:,29) = 0.13E-6;
STATES(:,30) = 0.25E-3;
STATES(:,31) = 0.237E-3;
STATES(:,32) = 1.0;
STATES(:,33) = 1.0;
STATES(:,34) = 0.298E-2;
CONSTANTS(:,87) = 7.0;
CONSTANTS(:,88) = 125000.0;
CONSTANTS(:,89) = 10875.0;
CONSTANTS(:,90) = 0.0534;
CONSTANTS(:,91) = 0.0534;
CONSTANTS(:,92) = 0.0267;
CONSTANTS(:,93) = 0.005;
CONSTANTS(:,94) = 125000.0;
CONSTANTS(:,95) = 84500.0;
CONSTANTS(:,96) = 0.0534;
CONSTANTS(:,97) = 0.0534;
CONSTANTS(:,98) = 0.00002584;
CONSTANTS(:,99) = 0.0000000012;
CONSTANTS(:,100) = power((CONSTANTS(:,13)./4.00000), 1.0 ./ 2);
CONSTANTS(:,101) =  (1.00000./7.00000).*(exp(CONSTANTS(:,11)./67.3000) - 1.00000);
CONSTANTS(:,102) = CONSTANTS(:,40)./(CONSTANTS(:,40)+CONSTANTS(:,39));
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
RATES(:,22) =   - CONSTANTS(:,49).*power(STATES(:,16), CONSTANTS(:,55)).*STATES(:,22)+ CONSTANTS(:,50).*STATES(:,20);
RATES(:,20) = ( CONSTANTS(:,49).*power(STATES(:,16), CONSTANTS(:,55)).*STATES(:,22) - ( CONSTANTS(:,50).*STATES(:,20)+ CONSTANTS(:,51).*power(STATES(:,16), CONSTANTS(:,56)).*STATES(:,20)+ CONSTANTS(:,53).*STATES(:,20)))+ CONSTANTS(:,52).*STATES(:,21)+ CONSTANTS(:,54).*STATES(:,23);
RATES(:,21) =  CONSTANTS(:,51).*power(STATES(:,16), CONSTANTS(:,56)).*STATES(:,20) -  CONSTANTS(:,52).*STATES(:,21);
RATES(:,23) =  CONSTANTS(:,53).*STATES(:,20) -  CONSTANTS(:,54).*STATES(:,23);
ALGEBRAIC(:,2) = piecewise({STATES(:,1)< - 40.0000,  135.000.*exp((80.0000+STATES(:,1))./ - 6.80000) }, 0.00000);
ALGEBRAIC(:,13) = piecewise({STATES(:,1)< - 40.0000,  3560.00.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.350000.*STATES(:,1)) }, 1000.00./( 0.130000.*(1.00000+exp((STATES(:,1)+10.6600)./ - 11.1000))));
RATES(:,4) =  ALGEBRAIC(:,2).*(1.00000 - STATES(:,4)) -  ALGEBRAIC(:,13).*STATES(:,4);
ALGEBRAIC(:,3) = piecewise({STATES(:,1)< - 40.0000, ( 1000.00.* - ( 127140..*exp( 0.244400.*STATES(:,1))+ 3.47400e-05.*exp(  - 0.0439100.*STATES(:,1))).*(STATES(:,1)+37.7800))./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300))) }, 0.00000);
ALGEBRAIC(:,14) = piecewise({STATES(:,1)< - 40.0000, ( 121.200.*exp(  - 0.0105200.*STATES(:,1)))./(1.00000+exp(  - 0.137800.*(STATES(:,1)+40.1400))) }, ( 300.000.*exp(  - 2.53500e-07.*STATES(:,1)))./(1.00000+exp(  - 0.100000.*(STATES(:,1)+32.0000))));
RATES(:,5) =  ALGEBRAIC(:,3).*(1.00000 - STATES(:,5)) -  ALGEBRAIC(:,14).*STATES(:,5);
ALGEBRAIC(:,16) = 0.00100000./(( 7.19000e-05.*(STATES(:,1) - 10.0000))./(1.00000 - exp(  - 0.148000.*(STATES(:,1) - 10.0000)))+( 0.000131000.*(STATES(:,1) - 10.0000))./(exp( 0.0687000.*(STATES(:,1) - 10.0000)) - 1.00000));
ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1) - 24.7000)./13.6000));
RATES(:,8) = (ALGEBRAIC(:,5) - STATES(:,8))./ALGEBRAIC(:,16);
ALGEBRAIC(:,6) =  45.1600.*exp( 0.0357700.*STATES(:,1));
ALGEBRAIC(:,17) =  98.9000.*exp(  - 0.0623700.*STATES(:,1));
RATES(:,9) =  ALGEBRAIC(:,6).*(1.00000 - STATES(:,9)) -  ALGEBRAIC(:,17).*STATES(:,9);
ALGEBRAIC(:,7) = ( 5.41500.*exp( - (STATES(:,1)+33.5000)./5.00000))./(1.00000+ 0.0513350.*exp( - (STATES(:,1)+33.5000)./5.00000));
ALGEBRAIC(:,18) = ( 5.41500.*exp((STATES(:,1)+33.5000)./5.00000))./(1.00000+ 0.0513350.*exp((STATES(:,1)+33.5000)./5.00000));
RATES(:,10) =  ALGEBRAIC(:,7).*(1.00000 - STATES(:,10)) -  ALGEBRAIC(:,18).*STATES(:,10);
ALGEBRAIC(:,8) =  400.000.*exp((STATES(:,1)+2.00000)./10.0000);
ALGEBRAIC(:,19) =  50.0000.*exp( - (STATES(:,1)+2.00000)./13.0000);
RATES(:,14) =  ALGEBRAIC(:,8).*(1.00000 - STATES(:,14)) -  ALGEBRAIC(:,19).*STATES(:,14);
ALGEBRAIC(:,10) = 0.800000./(1.00000+exp((STATES(:,1)+12.5000)./5.00000))+0.200000;
ALGEBRAIC(:,21) = (20.0000+600.000./(1.00000+exp((STATES(:,1)+20.0000)./9.50000)))./1000.00;
RATES(:,18) = (ALGEBRAIC(:,10) - STATES(:,18))./ALGEBRAIC(:,21);
ALGEBRAIC(:,1) = STATES(:,1)+47.1300;
ALGEBRAIC(:,12) = piecewise({abs(ALGEBRAIC(:,1))<1.00000e-05, 320.000./(0.100000 -  0.00500000.*ALGEBRAIC(:,1)) }, ( 320.000.*ALGEBRAIC(:,1))./(1.00000 - exp(  - 0.100000.*ALGEBRAIC(:,1))));
ALGEBRAIC(:,23) =  80.0000.*exp( - STATES(:,1)./11.0000);
RATES(:,3) = piecewise({STATES(:,1)>= - 90.0000,  ALGEBRAIC(:,12).*(1.00000 - STATES(:,3)) -  ALGEBRAIC(:,23).*STATES(:,3) }, 0.00000);
ALGEBRAIC(:,9) = ( 103.750.*STATES(:,16))./1.00000;
ALGEBRAIC(:,25) =  ALGEBRAIC(:,9).*( power(CONSTANTS(:,37), 0.00000).*power(STATES(:,14), 0.00000).*power(1.00000 - STATES(:,14), 4.00000 - 0.00000)+ power(CONSTANTS(:,37), 1.00000).*power(STATES(:,14), 1.00000).*power(1.00000 - STATES(:,14), 4.00000 - 1.00000)+ power(CONSTANTS(:,37), 2.00000).*power(STATES(:,14), 2.00000).*power(1.00000 - STATES(:,14), 4.00000 - 2.00000)+ power(CONSTANTS(:,37), 3.00000).*power(STATES(:,14), 3.00000).*power(1.00000 - STATES(:,14), 4.00000 - 3.00000)+ power(CONSTANTS(:,37), 4.00000).*power(STATES(:,14), 4.00000).*power(1.00000 - STATES(:,14), 4.00000 - 4.00000)+ - ( power(CONSTANTS(:,37), 4.00000).*power(STATES(:,14), 4.00000).*CONSTANTS(:,102)));
ALGEBRAIC(:,20) =  CONSTANTS(:,41).*( power(CONSTANTS(:,38),  - 0.00000).*power(STATES(:,15), 0.00000).*power(1.00000 - STATES(:,15), 4.00000 - 0.00000)+ power(CONSTANTS(:,38),  - 1.00000).*power(STATES(:,15), 1.00000).*power(1.00000 - STATES(:,15), 4.00000 - 1.00000)+ power(CONSTANTS(:,38),  - 2.00000).*power(STATES(:,15), 2.00000).*power(1.00000 - STATES(:,15), 4.00000 - 2.00000)+ power(CONSTANTS(:,38),  - 3.00000).*power(STATES(:,15), 3.00000).*power(1.00000 - STATES(:,15), 4.00000 - 3.00000)+ power(CONSTANTS(:,38),  - 4.00000).*power(STATES(:,15), 4.00000).*power(1.00000 - STATES(:,15), 4.00000 - 4.00000));
RATES(:,13) =  ALGEBRAIC(:,20).*(1.00000 - STATES(:,13)) -  ALGEBRAIC(:,25).*STATES(:,13);
ALGEBRAIC(:,4) = exp( - 5.49500+ 0.169100.*STATES(:,1));
ALGEBRAIC(:,15) = exp( - 7.67700 -  0.0128000.*STATES(:,1));
ALGEBRAIC(:,24) = ALGEBRAIC(:,4)./(ALGEBRAIC(:,4)+ALGEBRAIC(:,15));
ALGEBRAIC(:,28) = 0.00100000./(ALGEBRAIC(:,4)+ALGEBRAIC(:,15))+ CONSTANTS(:,14).*0.0270000;
RATES(:,7) = (ALGEBRAIC(:,24) - STATES(:,7))./ALGEBRAIC(:,28);
ALGEBRAIC(:,26) =  ALGEBRAIC(:,8).*CONSTANTS(:,37);
ALGEBRAIC(:,29) = ALGEBRAIC(:,19)./CONSTANTS(:,38);
RATES(:,15) =  ALGEBRAIC(:,26).*(1.00000 - STATES(:,15)) -  ALGEBRAIC(:,29).*STATES(:,15);
ALGEBRAIC(:,22) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,11)./STATES(:,2));
ALGEBRAIC(:,27) =  CONSTANTS(:,10).*power(STATES(:,3), 3.00000).*STATES(:,4).*STATES(:,5).*(STATES(:,1) - ALGEBRAIC(:,22));
ALGEBRAIC(:,40) =  (( CONSTANTS(:,22).*5000.00)./( (power(CONSTANTS(:,21), 3.00000)+power(CONSTANTS(:,11), 3.00000)).*(CONSTANTS(:,20)+CONSTANTS(:,25)).*(1.00000+ CONSTANTS(:,23).*exp(( (CONSTANTS(:,24) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))))).*( exp(( CONSTANTS(:,24).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,2), 3.00000).*CONSTANTS(:,25) -  exp(( (CONSTANTS(:,24) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(CONSTANTS(:,11), 3.00000).*STATES(:,11));
ALGEBRAIC(:,41) = 1.00000./(1.00000+ 0.124500.*exp((  - 0.100000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))+ 0.0365000.*CONSTANTS(:,101).*exp((  - STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))));
ALGEBRAIC(:,42) = ( (( CONSTANTS(:,26).*ALGEBRAIC(:,41))./(1.00000+power(CONSTANTS(:,27)./STATES(:,2), 1.50000))).*CONSTANTS(:,13))./(CONSTANTS(:,13)+CONSTANTS(:,28));
ALGEBRAIC(:,47) =  CONSTANTS(:,33).*(STATES(:,1) - ALGEBRAIC(:,22));
RATES(:,2) = (  - 0.00000.*(ALGEBRAIC(:,27)+ALGEBRAIC(:,47)+ ALGEBRAIC(:,40).*3.00000+ ALGEBRAIC(:,42).*3.00000).*CONSTANTS(:,72).*1.00000)./( CONSTANTS(:,73).*CONSTANTS(:,3));
RATES(:,26) =  CONSTANTS(:,68).*STATES(:,11).*(1.00000 - STATES(:,26)) -  CONSTANTS(:,69).*STATES(:,26);
ALGEBRAIC(:,56) = power(STATES(:,11)./CONSTANTS(:,57), CONSTANTS(:,62));
ALGEBRAIC(:,57) = power(STATES(:,25)./CONSTANTS(:,58), CONSTANTS(:,63));
ALGEBRAIC(:,58) = ( CONSTANTS(:,61).*( CONSTANTS(:,59).*ALGEBRAIC(:,56) -  CONSTANTS(:,60).*ALGEBRAIC(:,57)))./(1.00000+ALGEBRAIC(:,56)+ALGEBRAIC(:,57));
ALGEBRAIC(:,59) =  (STATES(:,12)./CONSTANTS(:,31)).*ALGEBRAIC(:,58);
ALGEBRAIC(:,61) = (STATES(:,25) - STATES(:,24))./CONSTANTS(:,64);
RATES(:,25) = ( ALGEBRAIC(:,59).*CONSTANTS(:,73))./CONSTANTS(:,75) - ( ALGEBRAIC(:,61).*CONSTANTS(:,74))./CONSTANTS(:,75);
ALGEBRAIC(:,55) =  CONSTANTS(:,48).*(STATES(:,20)+STATES(:,21)).*(STATES(:,24) - STATES(:,16));
ALGEBRAIC(:,62) = 1.00000./(1.00000+( CONSTANTS(:,82).*CONSTANTS(:,79))./power(CONSTANTS(:,79)+STATES(:,24), 2.00000));
RATES(:,24) =  ALGEBRAIC(:,62).*(ALGEBRAIC(:,61) - ALGEBRAIC(:,55));
RATES(:,27) =  CONSTANTS(:,70).*STATES(:,11).*(1.00000 - STATES(:,27)) -  CONSTANTS(:,71).*STATES(:,27);
ALGEBRAIC(:,49) = 1.00000./(1.00000+power(CONSTANTS(:,36)./STATES(:,17), 2.60000));
ALGEBRAIC(:,48) =  power(STATES(:,14), 4.00000).*STATES(:,18).*STATES(:,13).*(CONSTANTS(:,40)./(CONSTANTS(:,40)+CONSTANTS(:,39)));
ALGEBRAIC(:,50) =  ALGEBRAIC(:,49).*(CONSTANTS(:,34)./( 1.00000.*CONSTANTS(:,4))).*(( 4.00000.*STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(( 0.00100000.*exp(( CONSTANTS(:,3).*STATES(:,1))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.340000.*CONSTANTS(:,25))./(exp(( CONSTANTS(:,3).*STATES(:,1))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000)).*ALGEBRAIC(:,48);
ALGEBRAIC(:,60) = (STATES(:,16) - STATES(:,11))./CONSTANTS(:,65);
ALGEBRAIC(:,67) = 1.00000./(1.00000+( CONSTANTS(:,80).*CONSTANTS(:,77))./power(CONSTANTS(:,77)+STATES(:,16), 2.00000)+( CONSTANTS(:,81).*CONSTANTS(:,78))./power(CONSTANTS(:,78)+STATES(:,16), 2.00000));
ALGEBRAIC(:,71) = CONSTANTS(:,93) - (STATES(:,29)+STATES(:,34));
ALGEBRAIC(:,68) = CONSTANTS(:,87) - (STATES(:,30)+STATES(:,17));
RATES(:,16) =  ALGEBRAIC(:,67).*((( ALGEBRAIC(:,55).*CONSTANTS(:,74))./CONSTANTS(:,76)+ CONSTANTS(:,84).*STATES(:,30)+ CONSTANTS(:,86).*STATES(:,29)) - (( ALGEBRAIC(:,60).*CONSTANTS(:,73))./CONSTANTS(:,76)+ ALGEBRAIC(:,50).*(( CONSTANTS(:,72).*1.00000)./( 2.00000.*CONSTANTS(:,76).*CONSTANTS(:,3)))+ CONSTANTS(:,83).*STATES(:,16).*ALGEBRAIC(:,68)+ CONSTANTS(:,85).*STATES(:,16).*ALGEBRAIC(:,71)));
ALGEBRAIC(:,72) = (STATES(:,30) - STATES(:,31))./CONSTANTS(:,90);
RATES(:,30) =  CONSTANTS(:,83).*STATES(:,16).*ALGEBRAIC(:,68) - ( ALGEBRAIC(:,72).*(CONSTANTS(:,98)./CONSTANTS(:,99))+ CONSTANTS(:,84).*STATES(:,30));
ALGEBRAIC(:,73) = (STATES(:,17) - STATES(:,12))./CONSTANTS(:,91);
RATES(:,17) =  CONSTANTS(:,88).*STATES(:,32).*ALGEBRAIC(:,68) - ( ALGEBRAIC(:,73).*(CONSTANTS(:,98)./CONSTANTS(:,99))+ CONSTANTS(:,89).*STATES(:,17));
ALGEBRAIC(:,69) = CONSTANTS(:,87) - (STATES(:,31)+STATES(:,12));
RATES(:,31) = (ALGEBRAIC(:,72)+ CONSTANTS(:,83).*STATES(:,11).*ALGEBRAIC(:,69)) -  CONSTANTS(:,84).*STATES(:,31);
RATES(:,12) = (ALGEBRAIC(:,73)+ CONSTANTS(:,88).*STATES(:,33).*ALGEBRAIC(:,69)) -  CONSTANTS(:,89).*STATES(:,12);
ALGEBRAIC(:,43) = ( CONSTANTS(:,30).*STATES(:,11))./(CONSTANTS(:,29)+STATES(:,11));
ALGEBRAIC(:,44) =  (STATES(:,12)./CONSTANTS(:,31)).*ALGEBRAIC(:,43);
ALGEBRAIC(:,45) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./( 2.00000.*CONSTANTS(:,3))).*log(CONSTANTS(:,25)./STATES(:,11));
ALGEBRAIC(:,46) =  CONSTANTS(:,32).*(STATES(:,1) - ALGEBRAIC(:,45));
ALGEBRAIC(:,63) = RATES(:,26);
ALGEBRAIC(:,64) = RATES(:,27);
ALGEBRAIC(:,65) =  CONSTANTS(:,66).*ALGEBRAIC(:,63)+ CONSTANTS(:,67).*ALGEBRAIC(:,64);
ALGEBRAIC(:,66) = 1.00000./(1.00000+( CONSTANTS(:,80).*CONSTANTS(:,77))./power(CONSTANTS(:,77)+STATES(:,11), 2.00000)+( CONSTANTS(:,81).*CONSTANTS(:,78))./power(CONSTANTS(:,78)+STATES(:,11), 2.00000));
ALGEBRAIC(:,75) = CONSTANTS(:,93) - (STATES(:,28)+STATES(:,19));
RATES(:,11) =  ALGEBRAIC(:,66).*((ALGEBRAIC(:,60) - (ALGEBRAIC(:,59)+ALGEBRAIC(:,65)))+ - ( ((ALGEBRAIC(:,44)+ALGEBRAIC(:,46)) -  2.00000.*ALGEBRAIC(:,40)).*(( CONSTANTS(:,72).*CONSTANTS(:,4))./( 2.00000.*CONSTANTS(:,73).*CONSTANTS(:,3))))+(( CONSTANTS(:,84).*STATES(:,31)+ CONSTANTS(:,86).*STATES(:,28)) - ( CONSTANTS(:,83).*STATES(:,11).*ALGEBRAIC(:,69)+ CONSTANTS(:,85).*STATES(:,11).*ALGEBRAIC(:,75))));
ALGEBRAIC(:,78) = (STATES(:,29) - STATES(:,28))./CONSTANTS(:,96);
RATES(:,29) =  CONSTANTS(:,85).*STATES(:,16).*ALGEBRAIC(:,71) - ( ALGEBRAIC(:,78).*(CONSTANTS(:,98)./CONSTANTS(:,99))+ CONSTANTS(:,86).*STATES(:,29));
ALGEBRAIC(:,79) = (STATES(:,34) - STATES(:,19))./CONSTANTS(:,97);
RATES(:,34) =  CONSTANTS(:,94).*STATES(:,32).*ALGEBRAIC(:,71) - ( ALGEBRAIC(:,79).*(CONSTANTS(:,98)./CONSTANTS(:,99))+ CONSTANTS(:,95).*STATES(:,34));
RATES(:,28) = (ALGEBRAIC(:,78)+ CONSTANTS(:,85).*STATES(:,11).*ALGEBRAIC(:,75)) -  CONSTANTS(:,86).*STATES(:,28);
RATES(:,19) = (ALGEBRAIC(:,79)+ CONSTANTS(:,94).*STATES(:,33).*ALGEBRAIC(:,75)) -  CONSTANTS(:,95).*STATES(:,19);
ALGEBRAIC(:,77) = (STATES(:,32) - STATES(:,33))./CONSTANTS(:,92);
RATES(:,32) = ( CONSTANTS(:,89).*STATES(:,17)+ CONSTANTS(:,95).*STATES(:,34)) - ( CONSTANTS(:,88).*STATES(:,32).*ALGEBRAIC(:,68)+ CONSTANTS(:,94).*STATES(:,32).*ALGEBRAIC(:,71)+ ALGEBRAIC(:,77).*(CONSTANTS(:,98)./CONSTANTS(:,99)));
RATES(:,33) = (ALGEBRAIC(:,77)+ CONSTANTS(:,89).*STATES(:,12)+ CONSTANTS(:,95).*STATES(:,19)) - ( CONSTANTS(:,88).*STATES(:,33).*ALGEBRAIC(:,69)+ CONSTANTS(:,94).*STATES(:,33).*ALGEBRAIC(:,75));
ALGEBRAIC(:,11) = piecewise({VOI>=CONSTANTS(:,5)&VOI<=CONSTANTS(:,6)&(VOI - CONSTANTS(:,5)) -  floor((VOI - CONSTANTS(:,5))./CONSTANTS(:,7)).*CONSTANTS(:,7)<=CONSTANTS(:,8), CONSTANTS(:,9) }, 0.00000);
ALGEBRAIC(:,51) =  1.00000.*ALGEBRAIC(:,49).*(CONSTANTS(:,35)./CONSTANTS(:,4)).*ALGEBRAIC(:,48);
ALGEBRAIC(:,30) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,13)./STATES(:,6));
ALGEBRAIC(:,31) = 1.00000./(1.00000+ 1.49450.*exp( 0.0446000.*STATES(:,1)));
ALGEBRAIC(:,32) =  CONSTANTS(:,12).*CONSTANTS(:,100).*ALGEBRAIC(:,31).*STATES(:,7).*(STATES(:,1) - ALGEBRAIC(:,30));
ALGEBRAIC(:,33) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log((CONSTANTS(:,13)+ 0.0183300.*CONSTANTS(:,11))./(STATES(:,6)+ 0.0183300.*STATES(:,2)));
ALGEBRAIC(:,34) =  CONSTANTS(:,15).*power(STATES(:,8), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,33));
ALGEBRAIC(:,35) =  CONSTANTS(:,16).*STATES(:,9).*STATES(:,10).*(STATES(:,1) - ALGEBRAIC(:,30));
ALGEBRAIC(:,36) = 1.00000./(2.00000+exp( (( 1.50000.*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(STATES(:,1) - ALGEBRAIC(:,30))));
ALGEBRAIC(:,37) =  (( CONSTANTS(:,17).*ALGEBRAIC(:,36).*CONSTANTS(:,13))./(CONSTANTS(:,13)+CONSTANTS(:,18))).*(STATES(:,1) - ALGEBRAIC(:,30));
ALGEBRAIC(:,38) = 1.00000./(1.00000+exp((7.48800 - STATES(:,1))./5.98000));
ALGEBRAIC(:,39) =  CONSTANTS(:,19).*ALGEBRAIC(:,38).*(STATES(:,1) - ALGEBRAIC(:,30));
ALGEBRAIC(:,70) = power(1.00000 - ALGEBRAIC(:,69)./(ALGEBRAIC(:,69)+CONSTANTS(:,43)), 4.00000);
ALGEBRAIC(:,52) = power(STATES(:,19)./(STATES(:,19)+CONSTANTS(:,44)), 2.00000);
ALGEBRAIC(:,53) = 1.00000 - ALGEBRAIC(:,52);
ALGEBRAIC(:,54) = 1.00000 - power(ALGEBRAIC(:,53), 4.00000);
ALGEBRAIC(:,74) =  CONSTANTS(:,46).*ALGEBRAIC(:,70).*(1.00000 - ALGEBRAIC(:,54))+ CONSTANTS(:,47).*ALGEBRAIC(:,70).*ALGEBRAIC(:,54);
ALGEBRAIC(:,76) =  CONSTANTS(:,42).*ALGEBRAIC(:,74).*power(CONSTANTS(:,13)./CONSTANTS(:,45), 0.240000);
ALGEBRAIC(:,80) =  ALGEBRAIC(:,76).*(STATES(:,1) - ALGEBRAIC(:,30));
RATES(:,1) = (  - 1.00000.*1.00000.*(ALGEBRAIC(:,27)+ALGEBRAIC(:,50)+ALGEBRAIC(:,51)+ALGEBRAIC(:,32)+ALGEBRAIC(:,34)+ALGEBRAIC(:,35)+ALGEBRAIC(:,37)+ALGEBRAIC(:,39)+ALGEBRAIC(:,40)+ALGEBRAIC(:,42)+ALGEBRAIC(:,44)+ALGEBRAIC(:,47)+ALGEBRAIC(:,46)+ALGEBRAIC(:,80)+ALGEBRAIC(:,11)))./CONSTANTS(:,4);
RATES(:,6) = (  - 0.00000.*(ALGEBRAIC(:,51)+ALGEBRAIC(:,32)+ALGEBRAIC(:,34)+ALGEBRAIC(:,37)+ALGEBRAIC(:,39)+ALGEBRAIC(:,35)+ALGEBRAIC(:,80)+ ALGEBRAIC(:,42).* - 2.00000).*CONSTANTS(:,72).*1.00000)./( CONSTANTS(:,73).*CONSTANTS(:,3));
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(:,2) = piecewise({STATES(:,1)< - 40.0000,  135.000.*exp((80.0000+STATES(:,1))./ - 6.80000) }, 0.00000);
ALGEBRAIC(:,13) = piecewise({STATES(:,1)< - 40.0000,  3560.00.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.350000.*STATES(:,1)) }, 1000.00./( 0.130000.*(1.00000+exp((STATES(:,1)+10.6600)./ - 11.1000))));
ALGEBRAIC(:,3) = piecewise({STATES(:,1)< - 40.0000, ( 1000.00.* - ( 127140..*exp( 0.244400.*STATES(:,1))+ 3.47400e-05.*exp(  - 0.0439100.*STATES(:,1))).*(STATES(:,1)+37.7800))./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300))) }, 0.00000);
ALGEBRAIC(:,14) = piecewise({STATES(:,1)< - 40.0000, ( 121.200.*exp(  - 0.0105200.*STATES(:,1)))./(1.00000+exp(  - 0.137800.*(STATES(:,1)+40.1400))) }, ( 300.000.*exp(  - 2.53500e-07.*STATES(:,1)))./(1.00000+exp(  - 0.100000.*(STATES(:,1)+32.0000))));
ALGEBRAIC(:,16) = 0.00100000./(( 7.19000e-05.*(STATES(:,1) - 10.0000))./(1.00000 - exp(  - 0.148000.*(STATES(:,1) - 10.0000)))+( 0.000131000.*(STATES(:,1) - 10.0000))./(exp( 0.0687000.*(STATES(:,1) - 10.0000)) - 1.00000));
ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1) - 24.7000)./13.6000));
ALGEBRAIC(:,6) =  45.1600.*exp( 0.0357700.*STATES(:,1));
ALGEBRAIC(:,17) =  98.9000.*exp(  - 0.0623700.*STATES(:,1));
ALGEBRAIC(:,7) = ( 5.41500.*exp( - (STATES(:,1)+33.5000)./5.00000))./(1.00000+ 0.0513350.*exp( - (STATES(:,1)+33.5000)./5.00000));
ALGEBRAIC(:,18) = ( 5.41500.*exp((STATES(:,1)+33.5000)./5.00000))./(1.00000+ 0.0513350.*exp((STATES(:,1)+33.5000)./5.00000));
ALGEBRAIC(:,8) =  400.000.*exp((STATES(:,1)+2.00000)./10.0000);
ALGEBRAIC(:,19) =  50.0000.*exp( - (STATES(:,1)+2.00000)./13.0000);
ALGEBRAIC(:,10) = 0.800000./(1.00000+exp((STATES(:,1)+12.5000)./5.00000))+0.200000;
ALGEBRAIC(:,21) = (20.0000+600.000./(1.00000+exp((STATES(:,1)+20.0000)./9.50000)))./1000.00;
ALGEBRAIC(:,1) = STATES(:,1)+47.1300;
ALGEBRAIC(:,12) = piecewise({abs(ALGEBRAIC(:,1))<1.00000e-05, 320.000./(0.100000 -  0.00500000.*ALGEBRAIC(:,1)) }, ( 320.000.*ALGEBRAIC(:,1))./(1.00000 - exp(  - 0.100000.*ALGEBRAIC(:,1))));
ALGEBRAIC(:,23) =  80.0000.*exp( - STATES(:,1)./11.0000);
ALGEBRAIC(:,9) = ( 103.750.*STATES(:,16))./1.00000;
ALGEBRAIC(:,25) =  ALGEBRAIC(:,9).*( power(CONSTANTS(:,37), 0.00000).*power(STATES(:,14), 0.00000).*power(1.00000 - STATES(:,14), 4.00000 - 0.00000)+ power(CONSTANTS(:,37), 1.00000).*power(STATES(:,14), 1.00000).*power(1.00000 - STATES(:,14), 4.00000 - 1.00000)+ power(CONSTANTS(:,37), 2.00000).*power(STATES(:,14), 2.00000).*power(1.00000 - STATES(:,14), 4.00000 - 2.00000)+ power(CONSTANTS(:,37), 3.00000).*power(STATES(:,14), 3.00000).*power(1.00000 - STATES(:,14), 4.00000 - 3.00000)+ power(CONSTANTS(:,37), 4.00000).*power(STATES(:,14), 4.00000).*power(1.00000 - STATES(:,14), 4.00000 - 4.00000)+ - ( power(CONSTANTS(:,37), 4.00000).*power(STATES(:,14), 4.00000).*CONSTANTS(:,102)));
ALGEBRAIC(:,20) =  CONSTANTS(:,41).*( power(CONSTANTS(:,38),  - 0.00000).*power(STATES(:,15), 0.00000).*power(1.00000 - STATES(:,15), 4.00000 - 0.00000)+ power(CONSTANTS(:,38),  - 1.00000).*power(STATES(:,15), 1.00000).*power(1.00000 - STATES(:,15), 4.00000 - 1.00000)+ power(CONSTANTS(:,38),  - 2.00000).*power(STATES(:,15), 2.00000).*power(1.00000 - STATES(:,15), 4.00000 - 2.00000)+ power(CONSTANTS(:,38),  - 3.00000).*power(STATES(:,15), 3.00000).*power(1.00000 - STATES(:,15), 4.00000 - 3.00000)+ power(CONSTANTS(:,38),  - 4.00000).*power(STATES(:,15), 4.00000).*power(1.00000 - STATES(:,15), 4.00000 - 4.00000));
ALGEBRAIC(:,4) = exp( - 5.49500+ 0.169100.*STATES(:,1));
ALGEBRAIC(:,15) = exp( - 7.67700 -  0.0128000.*STATES(:,1));
ALGEBRAIC(:,24) = ALGEBRAIC(:,4)./(ALGEBRAIC(:,4)+ALGEBRAIC(:,15));
ALGEBRAIC(:,28) = 0.00100000./(ALGEBRAIC(:,4)+ALGEBRAIC(:,15))+ CONSTANTS(:,14).*0.0270000;
ALGEBRAIC(:,26) =  ALGEBRAIC(:,8).*CONSTANTS(:,37);
ALGEBRAIC(:,29) = ALGEBRAIC(:,19)./CONSTANTS(:,38);
ALGEBRAIC(:,22) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,11)./STATES(:,2));
ALGEBRAIC(:,27) =  CONSTANTS(:,10).*power(STATES(:,3), 3.00000).*STATES(:,4).*STATES(:,5).*(STATES(:,1) - ALGEBRAIC(:,22));
ALGEBRAIC(:,40) =  (( CONSTANTS(:,22).*5000.00)./( (power(CONSTANTS(:,21), 3.00000)+power(CONSTANTS(:,11), 3.00000)).*(CONSTANTS(:,20)+CONSTANTS(:,25)).*(1.00000+ CONSTANTS(:,23).*exp(( (CONSTANTS(:,24) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))))).*( exp(( CONSTANTS(:,24).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,2), 3.00000).*CONSTANTS(:,25) -  exp(( (CONSTANTS(:,24) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(CONSTANTS(:,11), 3.00000).*STATES(:,11));
ALGEBRAIC(:,41) = 1.00000./(1.00000+ 0.124500.*exp((  - 0.100000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))+ 0.0365000.*CONSTANTS(:,101).*exp((  - STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))));
ALGEBRAIC(:,42) = ( (( CONSTANTS(:,26).*ALGEBRAIC(:,41))./(1.00000+power(CONSTANTS(:,27)./STATES(:,2), 1.50000))).*CONSTANTS(:,13))./(CONSTANTS(:,13)+CONSTANTS(:,28));
ALGEBRAIC(:,47) =  CONSTANTS(:,33).*(STATES(:,1) - ALGEBRAIC(:,22));
ALGEBRAIC(:,56) = power(STATES(:,11)./CONSTANTS(:,57), CONSTANTS(:,62));
ALGEBRAIC(:,57) = power(STATES(:,25)./CONSTANTS(:,58), CONSTANTS(:,63));
ALGEBRAIC(:,58) = ( CONSTANTS(:,61).*( CONSTANTS(:,59).*ALGEBRAIC(:,56) -  CONSTANTS(:,60).*ALGEBRAIC(:,57)))./(1.00000+ALGEBRAIC(:,56)+ALGEBRAIC(:,57));
ALGEBRAIC(:,59) =  (STATES(:,12)./CONSTANTS(:,31)).*ALGEBRAIC(:,58);
ALGEBRAIC(:,61) = (STATES(:,25) - STATES(:,24))./CONSTANTS(:,64);
ALGEBRAIC(:,55) =  CONSTANTS(:,48).*(STATES(:,20)+STATES(:,21)).*(STATES(:,24) - STATES(:,16));
ALGEBRAIC(:,62) = 1.00000./(1.00000+( CONSTANTS(:,82).*CONSTANTS(:,79))./power(CONSTANTS(:,79)+STATES(:,24), 2.00000));
ALGEBRAIC(:,49) = 1.00000./(1.00000+power(CONSTANTS(:,36)./STATES(:,17), 2.60000));
ALGEBRAIC(:,48) =  power(STATES(:,14), 4.00000).*STATES(:,18).*STATES(:,13).*(CONSTANTS(:,40)./(CONSTANTS(:,40)+CONSTANTS(:,39)));
ALGEBRAIC(:,50) =  ALGEBRAIC(:,49).*(CONSTANTS(:,34)./( 1.00000.*CONSTANTS(:,4))).*(( 4.00000.*STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(( 0.00100000.*exp(( CONSTANTS(:,3).*STATES(:,1))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.340000.*CONSTANTS(:,25))./(exp(( CONSTANTS(:,3).*STATES(:,1))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000)).*ALGEBRAIC(:,48);
ALGEBRAIC(:,60) = (STATES(:,16) - STATES(:,11))./CONSTANTS(:,65);
ALGEBRAIC(:,67) = 1.00000./(1.00000+( CONSTANTS(:,80).*CONSTANTS(:,77))./power(CONSTANTS(:,77)+STATES(:,16), 2.00000)+( CONSTANTS(:,81).*CONSTANTS(:,78))./power(CONSTANTS(:,78)+STATES(:,16), 2.00000));
ALGEBRAIC(:,71) = CONSTANTS(:,93) - (STATES(:,29)+STATES(:,34));
ALGEBRAIC(:,68) = CONSTANTS(:,87) - (STATES(:,30)+STATES(:,17));
ALGEBRAIC(:,72) = (STATES(:,30) - STATES(:,31))./CONSTANTS(:,90);
ALGEBRAIC(:,73) = (STATES(:,17) - STATES(:,12))./CONSTANTS(:,91);
ALGEBRAIC(:,69) = CONSTANTS(:,87) - (STATES(:,31)+STATES(:,12));
ALGEBRAIC(:,43) = ( CONSTANTS(:,30).*STATES(:,11))./(CONSTANTS(:,29)+STATES(:,11));
ALGEBRAIC(:,44) =  (STATES(:,12)./CONSTANTS(:,31)).*ALGEBRAIC(:,43);
ALGEBRAIC(:,45) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./( 2.00000.*CONSTANTS(:,3))).*log(CONSTANTS(:,25)./STATES(:,11));
ALGEBRAIC(:,46) =  CONSTANTS(:,32).*(STATES(:,1) - ALGEBRAIC(:,45));
ALGEBRAIC(:,63) = RATES(:,26);
ALGEBRAIC(:,64) = RATES(:,27);
ALGEBRAIC(:,65) =  CONSTANTS(:,66).*ALGEBRAIC(:,63)+ CONSTANTS(:,67).*ALGEBRAIC(:,64);
ALGEBRAIC(:,66) = 1.00000./(1.00000+( CONSTANTS(:,80).*CONSTANTS(:,77))./power(CONSTANTS(:,77)+STATES(:,11), 2.00000)+( CONSTANTS(:,81).*CONSTANTS(:,78))./power(CONSTANTS(:,78)+STATES(:,11), 2.00000));
ALGEBRAIC(:,75) = CONSTANTS(:,93) - (STATES(:,28)+STATES(:,19));
ALGEBRAIC(:,78) = (STATES(:,29) - STATES(:,28))./CONSTANTS(:,96);
ALGEBRAIC(:,79) = (STATES(:,34) - STATES(:,19))./CONSTANTS(:,97);
ALGEBRAIC(:,77) = (STATES(:,32) - STATES(:,33))./CONSTANTS(:,92);
ALGEBRAIC(:,11) = piecewise({VOI>=CONSTANTS(:,5)&VOI<=CONSTANTS(:,6)&(VOI - CONSTANTS(:,5)) -  floor((VOI - CONSTANTS(:,5))./CONSTANTS(:,7)).*CONSTANTS(:,7)<=CONSTANTS(:,8), CONSTANTS(:,9) }, 0.00000);
ALGEBRAIC(:,51) =  1.00000.*ALGEBRAIC(:,49).*(CONSTANTS(:,35)./CONSTANTS(:,4)).*ALGEBRAIC(:,48);
ALGEBRAIC(:,30) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,13)./STATES(:,6));
ALGEBRAIC(:,31) = 1.00000./(1.00000+ 1.49450.*exp( 0.0446000.*STATES(:,1)));
ALGEBRAIC(:,32) =  CONSTANTS(:,12).*CONSTANTS(:,100).*ALGEBRAIC(:,31).*STATES(:,7).*(STATES(:,1) - ALGEBRAIC(:,30));
ALGEBRAIC(:,33) =  (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log((CONSTANTS(:,13)+ 0.0183300.*CONSTANTS(:,11))./(STATES(:,6)+ 0.0183300.*STATES(:,2)));
ALGEBRAIC(:,34) =  CONSTANTS(:,15).*power(STATES(:,8), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,33));
ALGEBRAIC(:,35) =  CONSTANTS(:,16).*STATES(:,9).*STATES(:,10).*(STATES(:,1) - ALGEBRAIC(:,30));
ALGEBRAIC(:,36) = 1.00000./(2.00000+exp( (( 1.50000.*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(STATES(:,1) - ALGEBRAIC(:,30))));
ALGEBRAIC(:,37) =  (( CONSTANTS(:,17).*ALGEBRAIC(:,36).*CONSTANTS(:,13))./(CONSTANTS(:,13)+CONSTANTS(:,18))).*(STATES(:,1) - ALGEBRAIC(:,30));
ALGEBRAIC(:,38) = 1.00000./(1.00000+exp((7.48800 - STATES(:,1))./5.98000));
ALGEBRAIC(:,39) =  CONSTANTS(:,19).*ALGEBRAIC(:,38).*(STATES(:,1) - ALGEBRAIC(:,30));
ALGEBRAIC(:,70) = power(1.00000 - ALGEBRAIC(:,69)./(ALGEBRAIC(:,69)+CONSTANTS(:,43)), 4.00000);
ALGEBRAIC(:,52) = power(STATES(:,19)./(STATES(:,19)+CONSTANTS(:,44)), 2.00000);
ALGEBRAIC(:,53) = 1.00000 - ALGEBRAIC(:,52);
ALGEBRAIC(:,54) = 1.00000 - power(ALGEBRAIC(:,53), 4.00000);
ALGEBRAIC(:,74) =  CONSTANTS(:,46).*ALGEBRAIC(:,70).*(1.00000 - ALGEBRAIC(:,54))+ CONSTANTS(:,47).*ALGEBRAIC(:,70).*ALGEBRAIC(:,54);
ALGEBRAIC(:,76) =  CONSTANTS(:,42).*ALGEBRAIC(:,74).*power(CONSTANTS(:,13)./CONSTANTS(:,45), 0.240000);
ALGEBRAIC(:,80) =  ALGEBRAIC(:,76).*(STATES(:,1) - ALGEBRAIC(:,30));
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 Michailova 2005 at changeset f5f59110784d.
Collaboration
To begin collaborating on this work, please use your git client and issue this command: