# 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 =90;
end
% There are a total of 31 entries in each of the rate and state variable arrays.
% There are a total of 133 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_CONSTANTS(:,1) = strpad('isotonic in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,2) = strpad('alpha_1 in component parameters (per_micrometre)');
LEGEND_CONSTANTS(:,3) = strpad('beta_1 in component parameters (millinewton)');
LEGEND_CONSTANTS(:,4) = strpad('alpha_2 in component parameters (per_micrometre)');
LEGEND_CONSTANTS(:,5) = strpad('beta_2 in component parameters (millinewton)');
LEGEND_CONSTANTS(:,6) = strpad('alpha_3 in component parameters (per_micrometre)');
LEGEND_CONSTANTS(:,7) = strpad('beta_3 in component parameters (millinewton)');
LEGEND_CONSTANTS(:,8) = strpad('lambda in component parameters (millinewton)');
LEGEND_CONSTANTS(:,9) = strpad('mu in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,10) = strpad('k_mu in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,11) = strpad('kappa in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,12) = strpad('kappa_0 in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,13) = strpad('m_0 in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,14) = strpad('v_max in component parameters (micrometre_per_second)');
LEGEND_CONSTANTS(:,15) = strpad('a in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,16) = strpad('d_h in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,17) = strpad('alpha_P in component parameters (dimensionless)');
LEGEND_ALGEBRAIC(:,38) = strpad('l in component length (micrometre)');
LEGEND_ALGEBRAIC(:,27) = strpad('F_muscle in component force (millinewton)');
LEGEND_ALGEBRAIC(:,41) = strpad('isotonic_mode in component isotonic (dimensionless)');
LEGEND_CONSTANTS(:,19) = strpad('l_0 in component length (micrometre)');
LEGEND_CONSTANTS(:,20) = strpad('stim_period in component membrane (second)');
LEGEND_CONSTANTS(:,21) = strpad('S_0 in component parameters_izakov_et_al_1991 (micrometre)');
LEGEND_ALGEBRAIC(:,3) = strpad('q_v in component parameters_izakov_et_al_1991 (per_second)');
LEGEND_CONSTANTS(:,22) = strpad('q_1 in component parameters_izakov_et_al_1991 (per_second)');
LEGEND_CONSTANTS(:,23) = strpad('q_2 in component parameters_izakov_et_al_1991 (per_second)');
LEGEND_CONSTANTS(:,24) = strpad('q_3 in component parameters_izakov_et_al_1991 (per_second)');
LEGEND_CONSTANTS(:,25) = strpad('q_4 in component parameters_izakov_et_al_1991 (per_second)');
LEGEND_CONSTANTS(:,26) = strpad('x_st in component parameters_izakov_et_al_1991 (dimensionless)');
LEGEND_CONSTANTS(:,124) = strpad('v_st in component parameters_izakov_et_al_1991 (micrometre_per_second)');
LEGEND_CONSTANTS(:,125) = strpad('v_1 in component parameters_izakov_et_al_1991 (micrometre_per_second)');
LEGEND_CONSTANTS(:,27) = strpad('alpha_G in component parameters_izakov_et_al_1991 (dimensionless)');
LEGEND_CONSTANTS(:,28) = strpad('k_A in component parameters_izakov_et_al_1991 (per_millimolar)');
LEGEND_STATES(:,1) = strpad('v in component CE_velocity (micrometre_per_second)');
LEGEND_CONSTANTS(:,29) = strpad('alpha_Q in component parameters_izakov_et_al_1991 (dimensionless)');
LEGEND_CONSTANTS(:,30) = strpad('beta_Q in component parameters_izakov_et_al_1991 (dimensionless)');
LEGEND_ALGEBRAIC(:,72) = strpad('F_CE in component force (millinewton)');
LEGEND_ALGEBRAIC(:,16) = strpad('F_XSE in component force (millinewton)');
LEGEND_ALGEBRAIC(:,1) = strpad('F_SE in component force (millinewton)');
LEGEND_ALGEBRAIC(:,2) = strpad('F_PE in component force (millinewton)');
LEGEND_STATES(:,2) = strpad('N in component crossbridge_kinetics (dimensionless)');
LEGEND_ALGEBRAIC(:,45) = strpad('k_P_vis in component CE_velocity (millinewton_second_per_micrometre)');
LEGEND_ALGEBRAIC(:,52) = strpad('k_S_vis in component PE_velocity (millinewton_second_per_micrometre)');
LEGEND_STATES(:,3) = strpad('w in component PE_velocity (micrometre_per_second)');
LEGEND_STATES(:,4) = strpad('l_1 in component length (micrometre)');
LEGEND_STATES(:,5) = strpad('l_2 in component length (micrometre)');
LEGEND_STATES(:,6) = strpad('l_3 in component length (micrometre)');
LEGEND_ALGEBRAIC(:,70) = strpad('p_v in component average_crossbridge_force (dimensionless)');
LEGEND_ALGEBRAIC(:,64) = strpad('K_kappa in component crossbridge_kinetics (per_second)');
LEGEND_ALGEBRAIC(:,32) = strpad('M_A in component crossbridge_kinetics (dimensionless)');
LEGEND_ALGEBRAIC(:,34) = strpad('n_1 in component crossbridge_kinetics (dimensionless)');
LEGEND_ALGEBRAIC(:,36) = strpad('L_oz in component crossbridge_kinetics (dimensionless)');
LEGEND_ALGEBRAIC(:,60) = strpad('k_p_v in component crossbridge_kinetics (per_second)');
LEGEND_ALGEBRAIC(:,62) = strpad('k_m_v in component crossbridge_kinetics (per_second)');
LEGEND_STATES(:,7) = strpad('A in component intracellular_calcium_concentration (millimolar)');
LEGEND_CONSTANTS(:,31) = strpad('A_tot in component intracellular_calcium_concentration (millimolar)');
LEGEND_ALGEBRAIC(:,58) = strpad('G_star in component average_crossbridge_force (dimensionless)');
LEGEND_ALGEBRAIC(:,54) = strpad('P_star in component average_crossbridge_force (dimensionless)');
LEGEND_CONSTANTS(:,32) = strpad('g_1 in component crossbridge_kinetics (per_micrometre)');
LEGEND_CONSTANTS(:,33) = strpad('g_2 in component crossbridge_kinetics (dimensionless)');
LEGEND_ALGEBRAIC(:,4) = strpad('dl_1_dt in component length (micrometre_per_second)');
LEGEND_ALGEBRAIC(:,55) = strpad('dl_2_dt in component length (micrometre_per_second)');
LEGEND_ALGEBRAIC(:,56) = strpad('dl_3_dt in component length (micrometre_per_second)');
LEGEND_ALGEBRAIC(:,48) = strpad('phi_chi_2 in component CE_velocity (micrometre_per_second)');
LEGEND_CONSTANTS(:,34) = strpad('stim_start in component membrane (second)');
LEGEND_CONSTANTS(:,35) = strpad('stim_end in component membrane (second)');
LEGEND_CONSTANTS(:,36) = strpad('stim_duration in component membrane (second)');
LEGEND_CONSTANTS(:,37) = strpad('stim_amplitude in component membrane (nanoA)');
LEGEND_ALGEBRAIC(:,75) = strpad('phi_chi in component CE_velocity (micrometre_per_second2)');
LEGEND_ALGEBRAIC(:,73) = strpad('p_prime_v in component average_crossbridge_force (second_per_micrometre)');
LEGEND_CONSTANTS(:,38) = strpad('alpha_P_lengthening in component CE_velocity (per_micrometre)');
LEGEND_CONSTANTS(:,39) = strpad('beta_P_lengthening in component CE_velocity (millinewton_second_per_micrometre)');
LEGEND_CONSTANTS(:,40) = strpad('alpha_P_shortening in component CE_velocity (per_micrometre)');
LEGEND_CONSTANTS(:,41) = strpad('beta_P_shortening in component CE_velocity (millinewton_second_per_micrometre)');
LEGEND_ALGEBRAIC(:,43) = strpad('alp_p in component CE_velocity (per_micrometre)');
LEGEND_CONSTANTS(:,42) = strpad('alpha_S_lengthening in component PE_velocity (per_micrometre)');
LEGEND_CONSTANTS(:,43) = strpad('beta_S_lengthening in component PE_velocity (millinewton_second_per_micrometre)');
LEGEND_CONSTANTS(:,44) = strpad('alpha_S_shortening in component PE_velocity (per_micrometre)');
LEGEND_CONSTANTS(:,45) = strpad('beta_S_shortening in component PE_velocity (millinewton_second_per_micrometre)');
LEGEND_ALGEBRAIC(:,50) = strpad('alp_s in component PE_velocity (per_micrometre)');
LEGEND_CONSTANTS(:,131) = strpad('gamma in component average_crossbridge_force (dimensionless)');
LEGEND_CONSTANTS(:,126) = strpad('case_1 in component average_crossbridge_force (second_per_micrometre)');
LEGEND_ALGEBRAIC(:,66) = strpad('case_2 in component average_crossbridge_force (second_per_micrometre)');
LEGEND_CONSTANTS(:,127) = strpad('case_3 in component average_crossbridge_force (second_per_micrometre)');
LEGEND_ALGEBRAIC(:,68) = strpad('case_4 in component average_crossbridge_force (second_per_micrometre)');
LEGEND_STATES(:,8) = strpad('V in component membrane (millivolt)');
LEGEND_CONSTANTS(:,46) = strpad('R in component membrane (joule_per_kilomole_kelvin)');
LEGEND_CONSTANTS(:,47) = strpad('T in component membrane (kelvin)');
LEGEND_CONSTANTS(:,48) = strpad('F in component membrane (coulomb_per_mole)');
LEGEND_CONSTANTS(:,49) = strpad('Cm in component membrane (microF)');
LEGEND_ALGEBRAIC(:,53) = strpad('i_K1 in component time_independent_potassium_current (nanoA)');
LEGEND_ALGEBRAIC(:,80) = strpad('i_to in component transient_outward_current (nanoA)');
LEGEND_ALGEBRAIC(:,57) = strpad('i_Kr in component rapid_delayed_rectifier_potassium_current (nanoA)');
LEGEND_ALGEBRAIC(:,59) = strpad('i_Ks in component slow_delayed_rectifier_potassium_current (nanoA)');
LEGEND_ALGEBRAIC(:,69) = strpad('i_Ca_L_K_cyt in component L_type_Ca_channel (nanoA)');
LEGEND_ALGEBRAIC(:,76) = strpad('i_Ca_L_K_ds in component L_type_Ca_channel (nanoA)');
LEGEND_ALGEBRAIC(:,81) = strpad('i_NaK in component sodium_potassium_pump (nanoA)');
LEGEND_ALGEBRAIC(:,61) = strpad('i_Na in component fast_sodium_current (nanoA)');
LEGEND_ALGEBRAIC(:,65) = strpad('i_b_Na in component sodium_background_current (nanoA)');
LEGEND_ALGEBRAIC(:,63) = strpad('i_p_Na in component persistent_sodium_current (nanoA)');
LEGEND_ALGEBRAIC(:,71) = strpad('i_Ca_L_Na_cyt in component L_type_Ca_channel (nanoA)');
LEGEND_ALGEBRAIC(:,77) = strpad('i_Ca_L_Na_ds in component L_type_Ca_channel (nanoA)');
LEGEND_ALGEBRAIC(:,82) = strpad('i_NaCa_cyt in component sodium_calcium_exchanger (nanoA)');
LEGEND_ALGEBRAIC(:,83) = strpad('i_NaCa_ds in component sodium_calcium_exchanger (nanoA)');
LEGEND_ALGEBRAIC(:,67) = strpad('i_Ca_L_Ca_cyt in component L_type_Ca_channel (nanoA)');
LEGEND_ALGEBRAIC(:,74) = strpad('i_Ca_L_Ca_ds in component L_type_Ca_channel (nanoA)');
LEGEND_ALGEBRAIC(:,79) = strpad('i_b_Ca in component calcium_background_current (nanoA)');
LEGEND_ALGEBRAIC(:,40) = strpad('i_Stim in component membrane (nanoA)');
LEGEND_ALGEBRAIC(:,42) = strpad('E_Na in component reversal_potentials (millivolt)');
LEGEND_ALGEBRAIC(:,44) = strpad('E_K in component reversal_potentials (millivolt)');
LEGEND_ALGEBRAIC(:,47) = strpad('E_Ks in component reversal_potentials (millivolt)');
LEGEND_ALGEBRAIC(:,49) = strpad('E_Ca in component reversal_potentials (millivolt)');
LEGEND_ALGEBRAIC(:,51) = strpad('E_mh in component reversal_potentials (millivolt)');
LEGEND_CONSTANTS(:,50) = strpad('P_kna in component reversal_potentials (dimensionless)');
LEGEND_STATES(:,9) = strpad('K_o in component extracellular_potassium_concentration (millimolar)');
LEGEND_CONSTANTS(:,51) = strpad('Na_o in component extracellular_sodium_concentration (millimolar)');
LEGEND_STATES(:,10) = strpad('K_i in component intracellular_potassium_concentration (millimolar)');
LEGEND_STATES(:,11) = strpad('Na_i in component intracellular_sodium_concentration (millimolar)');
LEGEND_CONSTANTS(:,52) = strpad('Ca_o in component extracellular_calcium_concentration (millimolar)');
LEGEND_STATES(:,12) = strpad('Ca_i in component intracellular_calcium_concentration (millimolar)');
LEGEND_CONSTANTS(:,53) = strpad('K_mk1 in component time_independent_potassium_current (millimolar)');
LEGEND_CONSTANTS(:,54) = strpad('g_K1 in component time_independent_potassium_current (microS)');
LEGEND_CONSTANTS(:,55) = strpad('g_Kr1 in component rapid_delayed_rectifier_potassium_current (microS)');
LEGEND_CONSTANTS(:,56) = strpad('g_Kr2 in component rapid_delayed_rectifier_potassium_current (microS)');
LEGEND_STATES(:,13) = strpad('xr1 in component rapid_delayed_rectifier_potassium_current_xr1_gate (dimensionless)');
LEGEND_STATES(:,14) = strpad('xr2 in component rapid_delayed_rectifier_potassium_current_xr2_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,5) = strpad('alpha_xr1 in component rapid_delayed_rectifier_potassium_current_xr1_gate (per_second)');
LEGEND_ALGEBRAIC(:,17) = strpad('beta_xr1 in component rapid_delayed_rectifier_potassium_current_xr1_gate (per_second)');
LEGEND_ALGEBRAIC(:,6) = strpad('alpha_xr2 in component rapid_delayed_rectifier_potassium_current_xr2_gate (per_second)');
LEGEND_ALGEBRAIC(:,18) = strpad('beta_xr2 in component rapid_delayed_rectifier_potassium_current_xr2_gate (per_second)');
LEGEND_CONSTANTS(:,57) = strpad('g_Ks in component slow_delayed_rectifier_potassium_current (microS)');
LEGEND_STATES(:,15) = strpad('xs in component slow_delayed_rectifier_potassium_current_xs_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,7) = strpad('alpha_xs in component slow_delayed_rectifier_potassium_current_xs_gate (per_second)');
LEGEND_ALGEBRAIC(:,19) = strpad('beta_xs in component slow_delayed_rectifier_potassium_current_xs_gate (per_second)');
LEGEND_ALGEBRAIC(:,46) = strpad('i_KNa in component sodium_activated_potassium_current (nanoA)');
LEGEND_CONSTANTS(:,58) = strpad('g_K_Na in component sodium_activated_potassium_current (microS)');
LEGEND_CONSTANTS(:,59) = strpad('K_kna in component sodium_activated_potassium_current (millimolar)');
LEGEND_CONSTANTS(:,60) = strpad('g_Na in component fast_sodium_current (microS)');
LEGEND_STATES(:,16) = strpad('m in component fast_sodium_current_m_gate (dimensionless)');
LEGEND_STATES(:,17) = strpad('h in component fast_sodium_current_h_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,20) = strpad('alpha_m in component fast_sodium_current_m_gate (per_second)');
LEGEND_ALGEBRAIC(:,28) = strpad('beta_m in component fast_sodium_current_m_gate (per_second)');
LEGEND_CONSTANTS(:,61) = strpad('delta_m in component fast_sodium_current_m_gate (millivolt)');
LEGEND_ALGEBRAIC(:,8) = strpad('E0_m in component fast_sodium_current_m_gate (millivolt)');
LEGEND_ALGEBRAIC(:,9) = strpad('alpha_h in component fast_sodium_current_h_gate (per_second)');
LEGEND_ALGEBRAIC(:,21) = strpad('beta_h in component fast_sodium_current_h_gate (per_second)');
LEGEND_CONSTANTS(:,62) = strpad('g_pna in component persistent_sodium_current (microS)');
LEGEND_CONSTANTS(:,63) = strpad('g_bna in component sodium_background_current (microS)');
LEGEND_ALGEBRAIC(:,78) = strpad('i_Ca_L in component L_type_Ca_channel (nanoA)');
LEGEND_CONSTANTS(:,64) = strpad('P_Ca_L in component L_type_Ca_channel (nanoA_per_millimolar)');
LEGEND_CONSTANTS(:,65) = strpad('P_CaK in component L_type_Ca_channel (dimensionless)');
LEGEND_CONSTANTS(:,66) = strpad('P_CaNa in component L_type_Ca_channel (dimensionless)');
LEGEND_STATES(:,18) = strpad('Ca_ds in component intracellular_calcium_concentration (millimolar)');
LEGEND_STATES(:,19) = strpad('d in component L_type_Ca_channel_d_gate (dimensionless)');
LEGEND_STATES(:,20) = strpad('f in component L_type_Ca_channel_f_gate (dimensionless)');
LEGEND_STATES(:,21) = strpad('f2 in component L_type_Ca_channel_f2_gate (dimensionless)');
LEGEND_STATES(:,22) = strpad('f2ds in component L_type_Ca_channel_f2ds_gate (dimensionless)');
LEGEND_CONSTANTS(:,67) = strpad('Km_f2 in component L_type_Ca_channel (millimolar)');
LEGEND_CONSTANTS(:,68) = strpad('Km_f2ds in component L_type_Ca_channel (millimolar)');
LEGEND_CONSTANTS(:,69) = strpad('R_decay in component L_type_Ca_channel (per_second)');
LEGEND_CONSTANTS(:,70) = strpad('FrICa in component L_type_Ca_channel (dimensionless)');
LEGEND_ALGEBRAIC(:,22) = strpad('alpha_d in component L_type_Ca_channel_d_gate (per_second)');
LEGEND_ALGEBRAIC(:,29) = strpad('beta_d in component L_type_Ca_channel_d_gate (per_second)');
LEGEND_ALGEBRAIC(:,10) = strpad('E0_d in component L_type_Ca_channel_d_gate (millivolt)');
LEGEND_CONSTANTS(:,71) = strpad('speed_d in component L_type_Ca_channel_d_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,23) = strpad('alpha_f in component L_type_Ca_channel_f_gate (per_second)');
LEGEND_ALGEBRAIC(:,30) = strpad('beta_f in component L_type_Ca_channel_f_gate (per_second)');
LEGEND_CONSTANTS(:,72) = strpad('speed_f in component L_type_Ca_channel_f_gate (dimensionless)');
LEGEND_CONSTANTS(:,73) = strpad('delta_f in component L_type_Ca_channel_f_gate (millivolt)');
LEGEND_ALGEBRAIC(:,11) = strpad('E0_f in component L_type_Ca_channel_f_gate (millivolt)');
LEGEND_CONSTANTS(:,74) = strpad('g_bca in component calcium_background_current (microS)');
LEGEND_CONSTANTS(:,75) = strpad('g_to in component transient_outward_current (microS)');
LEGEND_CONSTANTS(:,76) = strpad('g_tos in component transient_outward_current (dimensionless)');
LEGEND_STATES(:,23) = strpad('s in component transient_outward_current_s_gate (dimensionless)');
LEGEND_STATES(:,24) = strpad('r in component transient_outward_current_r_gate (dimensionless)');
LEGEND_ALGEBRAIC(:,12) = strpad('alpha_s in component transient_outward_current_s_gate (per_second)');
LEGEND_ALGEBRAIC(:,24) = strpad('beta_s in component transient_outward_current_s_gate (per_second)');
LEGEND_CONSTANTS(:,77) = strpad('i_NaK_max in component sodium_potassium_pump (nanoA)');
LEGEND_CONSTANTS(:,78) = strpad('K_mK in component sodium_potassium_pump (millimolar)');
LEGEND_CONSTANTS(:,79) = strpad('K_mNa in component sodium_potassium_pump (millimolar)');
LEGEND_ALGEBRAIC(:,85) = strpad('i_NaCa in component sodium_calcium_exchanger (nanoA)');
LEGEND_CONSTANTS(:,80) = strpad('k_NaCa in component sodium_calcium_exchanger (nanoA)');
LEGEND_CONSTANTS(:,81) = strpad('n_NaCa in component sodium_calcium_exchanger (dimensionless)');
LEGEND_CONSTANTS(:,82) = strpad('d_NaCa in component sodium_calcium_exchanger (dimensionless)');
LEGEND_CONSTANTS(:,83) = strpad('gamma in component sodium_calcium_exchanger (dimensionless)');
LEGEND_CONSTANTS(:,84) = strpad('FRiNaCa in component sodium_calcium_exchanger (dimensionless)');
LEGEND_ALGEBRAIC(:,86) = strpad('i_up in component sarcoplasmic_reticulum_calcium_pump (millimolar_per_second)');
LEGEND_CONSTANTS(:,129) = strpad('K_1 in component sarcoplasmic_reticulum_calcium_pump (dimensionless)');
LEGEND_ALGEBRAIC(:,84) = strpad('K_2 in component sarcoplasmic_reticulum_calcium_pump (millimolar)');
LEGEND_CONSTANTS(:,85) = strpad('K_cyca in component sarcoplasmic_reticulum_calcium_pump (millimolar)');
LEGEND_CONSTANTS(:,86) = strpad('K_xcs in component sarcoplasmic_reticulum_calcium_pump (dimensionless)');
LEGEND_CONSTANTS(:,87) = strpad('K_srca in component sarcoplasmic_reticulum_calcium_pump (millimolar)');
LEGEND_CONSTANTS(:,88) = strpad('alpha_up in component sarcoplasmic_reticulum_calcium_pump (millimolar_per_second)');
LEGEND_CONSTANTS(:,89) = strpad('beta_up in component sarcoplasmic_reticulum_calcium_pump (millimolar_per_second)');
LEGEND_STATES(:,25) = strpad('Ca_up in component intracellular_calcium_concentration (millimolar)');
LEGEND_CONSTANTS(:,90) = strpad('flag_ingib in component sarcoplasmic_reticulum_calcium_pump (dimensionless)');
LEGEND_CONSTANTS(:,91) = strpad('K_inh in component sarcoplasmic_reticulum_calcium_pump (millimolar)');
LEGEND_ALGEBRAIC(:,87) = strpad('i_trans in component calcium_translocation (millimolar_per_second)');
LEGEND_STATES(:,26) = strpad('Ca_rel in component intracellular_calcium_concentration (millimolar)');
LEGEND_CONSTANTS(:,92) = strpad('a_tr in component calcium_translocation (per_second)');
LEGEND_CONSTANTS(:,93) = strpad('alpha_CaS in component calcium_translocation (per_millimolar_second)');
LEGEND_CONSTANTS(:,94) = strpad('beta_CaS in component calcium_translocation (per_second)');
LEGEND_CONSTANTS(:,95) = strpad('CaS_tot in component calcium_translocation (millimolar)');
LEGEND_CONSTANTS(:,130) = strpad('beta in component calcium_translocation (millimolar)');
LEGEND_ALGEBRAIC(:,88) = strpad('i_rel in component calcium_release (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,13) = strpad('VoltDep in component calcium_release (dimensionless)');
LEGEND_ALGEBRAIC(:,31) = strpad('RegBindSite in component calcium_release (dimensionless)');
LEGEND_ALGEBRAIC(:,14) = strpad('CaiReg in component calcium_release (dimensionless)');
LEGEND_ALGEBRAIC(:,33) = strpad('ActRate in component calcium_release (per_second)');
LEGEND_ALGEBRAIC(:,35) = strpad('InactRate in component calcium_release (per_second)');
LEGEND_CONSTANTS(:,96) = strpad('SRLeak in component calcium_release (per_second)');
LEGEND_CONSTANTS(:,97) = strpad('K_m_rel in component calcium_release (per_second)');
LEGEND_CONSTANTS(:,98) = strpad('K_m_Ca_cyt in component calcium_release (millimolar)');
LEGEND_CONSTANTS(:,99) = strpad('K_m_Ca_ds in component calcium_release (millimolar)');
LEGEND_ALGEBRAIC(:,39) = strpad('PrecFrac in component calcium_release (dimensionless)');
LEGEND_STATES(:,27) = strpad('ActFrac in component calcium_release (dimensionless)');
LEGEND_STATES(:,28) = strpad('ProdFrac in component calcium_release (dimensionless)');
LEGEND_ALGEBRAIC(:,37) = strpad('SpeedRel in component calcium_release (dimensionless)');
LEGEND_CONSTANTS(:,132) = strpad('V_i in component intracellular_calcium_concentration (micrometre3)');
LEGEND_CONSTANTS(:,100) = strpad('n_NaK in component intracellular_sodium_concentration (dimensionless)');
LEGEND_CONSTANTS(:,101) = strpad('K_b in component extracellular_potassium_concentration (millimolar)');
LEGEND_CONSTANTS(:,133) = strpad('V_e in component intracellular_calcium_concentration (micrometre3)');
LEGEND_CONSTANTS(:,103) = strpad('length in component intracellular_calcium_concentration (micrometre)');
LEGEND_CONSTANTS(:,128) = strpad('V_Cell in component intracellular_calcium_concentration (micrometre3)');
LEGEND_CONSTANTS(:,104) = strpad('V_i_ratio in component intracellular_calcium_concentration (dimensionless)');
LEGEND_CONSTANTS(:,105) = strpad('V_ds_ratio in component intracellular_calcium_concentration (dimensionless)');
LEGEND_CONSTANTS(:,106) = strpad('V_rel_ratio in component intracellular_calcium_concentration (dimensionless)');
LEGEND_CONSTANTS(:,107) = strpad('V_e_ratio in component intracellular_calcium_concentration (dimensionless)');
LEGEND_CONSTANTS(:,108) = strpad('V_up_ratio in component intracellular_calcium_concentration (dimensionless)');
LEGEND_CONSTANTS(:,109) = strpad('Kdecay in component intracellular_calcium_concentration (per_second)');
LEGEND_ALGEBRAIC(:,89) = strpad('N_A in component intracellular_calcium_concentration (dimensionless)');
LEGEND_ALGEBRAIC(:,90) = strpad('pi_N_A in component intracellular_calcium_concentration (dimensionless)');
LEGEND_CONSTANTS(:,110) = strpad('pi_min in component intracellular_calcium_concentration (dimensionless)');
LEGEND_CONSTANTS(:,111) = strpad('a_on in component intracellular_calcium_concentration (per_millimolar_second)');
LEGEND_CONSTANTS(:,112) = strpad('a_off in component intracellular_calcium_concentration (per_second)');
LEGEND_STATES(:,29) = strpad('B_1 in component intracellular_calcium_concentration (millimolar)');
LEGEND_CONSTANTS(:,113) = strpad('B_1_tot in component intracellular_calcium_concentration (millimolar)');
LEGEND_CONSTANTS(:,114) = strpad('b_1_on in component intracellular_calcium_concentration (per_millimolar_second)');
LEGEND_CONSTANTS(:,115) = strpad('b_1_off in component intracellular_calcium_concentration (per_second)');
LEGEND_STATES(:,30) = strpad('B_2 in component intracellular_calcium_concentration (millimolar)');
LEGEND_CONSTANTS(:,116) = strpad('B_2_tot in component intracellular_calcium_concentration (millimolar)');
LEGEND_CONSTANTS(:,117) = strpad('b_2_on in component intracellular_calcium_concentration (per_millimolar_second)');
LEGEND_CONSTANTS(:,118) = strpad('b_2_off in component intracellular_calcium_concentration (per_second)');
LEGEND_CONSTANTS(:,119) = strpad('g_fibro_junct in component fibroblast (microS)');
LEGEND_CONSTANTS(:,120) = strpad('g_fibro in component fibroblast (microS)');
LEGEND_CONSTANTS(:,121) = strpad('c_fibro in component fibroblast (microF)');
LEGEND_CONSTANTS(:,122) = strpad('g_fibro_stretch in component fibroblast (microS)');
LEGEND_CONSTANTS(:,123) = strpad('E_fibro_stretch in component fibroblast (millivolt)');
LEGEND_STATES(:,31) = strpad('V_fibro in component fibroblast (millivolt)');
LEGEND_ALGEBRAIC(:,15) = strpad('i_fibro in component fibroblast (nanoA)');
LEGEND_ALGEBRAIC(:,26) = strpad('i_fibro_junct in component fibroblast (nanoA)');
LEGEND_RATES(:,2) = strpad('d/dt N in component crossbridge_kinetics (dimensionless)');
LEGEND_RATES(:,4) = strpad('d/dt l_1 in component length (micrometre)');
LEGEND_RATES(:,5) = strpad('d/dt l_2 in component length (micrometre)');
LEGEND_RATES(:,6) = strpad('d/dt l_3 in component length (micrometre)');
LEGEND_RATES(:,1) = strpad('d/dt v in component CE_velocity (micrometre_per_second)');
LEGEND_RATES(:,3) = strpad('d/dt w in component PE_velocity (micrometre_per_second)');
LEGEND_RATES(:,8) = strpad('d/dt V in component membrane (millivolt)');
LEGEND_RATES(:,13) = strpad('d/dt xr1 in component rapid_delayed_rectifier_potassium_current_xr1_gate (dimensionless)');
LEGEND_RATES(:,14) = strpad('d/dt xr2 in component rapid_delayed_rectifier_potassium_current_xr2_gate (dimensionless)');
LEGEND_RATES(:,15) = strpad('d/dt xs in component slow_delayed_rectifier_potassium_current_xs_gate (dimensionless)');
LEGEND_RATES(:,16) = strpad('d/dt m in component fast_sodium_current_m_gate (dimensionless)');
LEGEND_RATES(:,17) = strpad('d/dt h in component fast_sodium_current_h_gate (dimensionless)');
LEGEND_RATES(:,19) = strpad('d/dt d in component L_type_Ca_channel_d_gate (dimensionless)');
LEGEND_RATES(:,20) = strpad('d/dt f in component L_type_Ca_channel_f_gate (dimensionless)');
LEGEND_RATES(:,21) = strpad('d/dt f2 in component L_type_Ca_channel_f2_gate (dimensionless)');
LEGEND_RATES(:,22) = strpad('d/dt f2ds in component L_type_Ca_channel_f2ds_gate (dimensionless)');
LEGEND_RATES(:,23) = strpad('d/dt s in component transient_outward_current_s_gate (dimensionless)');
LEGEND_RATES(:,24) = strpad('d/dt r in component transient_outward_current_r_gate (dimensionless)');
LEGEND_RATES(:,27) = strpad('d/dt ActFrac in component calcium_release (dimensionless)');
LEGEND_RATES(:,28) = strpad('d/dt ProdFrac in component calcium_release (dimensionless)');
LEGEND_RATES(:,11) = strpad('d/dt Na_i in component intracellular_sodium_concentration (millimolar)');
LEGEND_RATES(:,9) = strpad('d/dt K_o in component extracellular_potassium_concentration (millimolar)');
LEGEND_RATES(:,10) = strpad('d/dt K_i in component intracellular_potassium_concentration (millimolar)');
LEGEND_RATES(:,7) = strpad('d/dt A in component intracellular_calcium_concentration (millimolar)');
LEGEND_RATES(:,29) = strpad('d/dt B_1 in component intracellular_calcium_concentration (millimolar)');
LEGEND_RATES(:,30) = strpad('d/dt B_2 in component intracellular_calcium_concentration (millimolar)');
LEGEND_RATES(:,12) = strpad('d/dt Ca_i in component intracellular_calcium_concentration (millimolar)');
LEGEND_RATES(:,18) = strpad('d/dt Ca_ds in component intracellular_calcium_concentration (millimolar)');
LEGEND_RATES(:,25) = strpad('d/dt Ca_up in component intracellular_calcium_concentration (millimolar)');
LEGEND_RATES(:,26) = strpad('d/dt Ca_rel in component intracellular_calcium_concentration (millimolar)');
LEGEND_RATES(:,31) = strpad('d/dt V_fibro in component fibroblast (millivolt)');
LEGEND_STATES  = LEGEND_STATES';
LEGEND_ALGEBRAIC = LEGEND_ALGEBRAIC';
LEGEND_RATES = LEGEND_RATES';
LEGEND_CONSTANTS = LEGEND_CONSTANTS';
end

function [STATES, CONSTANTS] = initConsts()
VOI = 0; CONSTANTS = []; STATES = []; ALGEBRAIC = [];
CONSTANTS(:,1) = 0;
CONSTANTS(:,2) = 14.6;
CONSTANTS(:,3) = 0.84;
CONSTANTS(:,4) = 14.6;
CONSTANTS(:,5) = 0.0018;
CONSTANTS(:,6) = 48;
CONSTANTS(:,7) = 0.015;
CONSTANTS(:,8) = 30;
CONSTANTS(:,9) = 3;
CONSTANTS(:,10) = 0.6;
CONSTANTS(:,11) = 0.705;
CONSTANTS(:,12) = 3;
CONSTANTS(:,13) = 0.9;
CONSTANTS(:,14) = 5.5;
CONSTANTS(:,15) = 0.25;
CONSTANTS(:,16) = 0.5;
CONSTANTS(:,17) = 4;
CONSTANTS(:,18) = 2;
CONSTANTS(:,19) = 0.525139356105856;
CONSTANTS(:,20) = 1;
CONSTANTS(:,21) = 1.14;
CONSTANTS(:,22) = 17.3;
CONSTANTS(:,23) = 259;
CONSTANTS(:,24) = 17.3;
CONSTANTS(:,25) = 15;
CONSTANTS(:,26) = 0.964285;
CONSTANTS(:,27) = 1;
CONSTANTS(:,28) = 40;
STATES(:,1) = 0;
CONSTANTS(:,29) = 10;
CONSTANTS(:,30) = 5;
STATES(:,2) = 7.455e-8;
STATES(:,3) = 0;
STATES(:,4) = 0.436333342969918;
STATES(:,5) = 0.436333525334166;
STATES(:,6) = 0.088805830771694;
STATES(:,7) = 0.00015;
CONSTANTS(:,31) = 0.07;
CONSTANTS(:,32) = 0.6;
CONSTANTS(:,33) = 0.52;
CONSTANTS(:,34) = 0.06;
CONSTANTS(:,35) = 10000;
CONSTANTS(:,36) = 0.0025;
CONSTANTS(:,37) = -3;
CONSTANTS(:,38) = 16;
CONSTANTS(:,39) = 0.0015;
CONSTANTS(:,40) = 16;
CONSTANTS(:,41) = 0.0015;
CONSTANTS(:,42) = 46;
CONSTANTS(:,43) = 0;
CONSTANTS(:,44) = 39;
CONSTANTS(:,45) = 0;
STATES(:,8) = -93.658148;
CONSTANTS(:,46) = 8314.472;
CONSTANTS(:,47) = 310;
CONSTANTS(:,48) = 96485.3415;
CONSTANTS(:,49) = 9.5e-5;
CONSTANTS(:,50) = 0.03;
STATES(:,9) = 3.988;
CONSTANTS(:,51) = 140;
STATES(:,10) = 139.054;
STATES(:,11) = 5.18787513289509;
CONSTANTS(:,52) = 2;
STATES(:,12) = 6.15e-6;
CONSTANTS(:,53) = 10;
CONSTANTS(:,54) = 0.5;
CONSTANTS(:,55) = 0.0021;
CONSTANTS(:,56) = 0.0013;
STATES(:,13) = 8.88859784542779e-6;
STATES(:,14) = 1.53745791069154e-7;
CONSTANTS(:,57) = 0.0026;
STATES(:,15) = 0.001;
CONSTANTS(:,58) = 0;
CONSTANTS(:,59) = 20;
CONSTANTS(:,60) = 2.5;
STATES(:,16) = 0.0015;
STATES(:,17) = 0.995;
CONSTANTS(:,61) = 1e-5;
CONSTANTS(:,62) = 0.004;
CONSTANTS(:,63) = 0.0006;
CONSTANTS(:,64) = 0.1;
CONSTANTS(:,65) = 0.002;
CONSTANTS(:,66) = 0.01;
STATES(:,18) = 2.55e-6;
STATES(:,19) = 0;
STATES(:,20) = 1;
STATES(:,21) = 1;
STATES(:,22) = 0.997;
CONSTANTS(:,67) = 100000;
CONSTANTS(:,68) = 0.001;
CONSTANTS(:,69) = 20;
CONSTANTS(:,70) = 1;
CONSTANTS(:,71) = 3;
CONSTANTS(:,72) = 0.3;
CONSTANTS(:,73) = 0.0001;
CONSTANTS(:,74) = 0.00025;
CONSTANTS(:,75) = 0.006;
CONSTANTS(:,76) = 0;
STATES(:,23) = 0.997044616031121;
STATES(:,24) = 1.63117173173398e-8;
CONSTANTS(:,77) = 0.7;
CONSTANTS(:,78) = 1;
CONSTANTS(:,79) = 24.2;
CONSTANTS(:,80) = 0.0005;
CONSTANTS(:,81) = 3;
CONSTANTS(:,82) = 0;
CONSTANTS(:,83) = 0.5;
CONSTANTS(:,84) = 0.001;
CONSTANTS(:,85) = 0.00015;
CONSTANTS(:,86) = 0.4;
CONSTANTS(:,87) = 0.5;
CONSTANTS(:,88) = 1;
CONSTANTS(:,89) = 0.03;
STATES(:,25) = 0.994579;
CONSTANTS(:,90) = 0;
CONSTANTS(:,91) = 4;
STATES(:,26) = 0.989665;
CONSTANTS(:,92) = 15;
CONSTANTS(:,93) = 50000;
CONSTANTS(:,94) = 32500;
CONSTANTS(:,95) = 40;
CONSTANTS(:,96) = 0.05;
CONSTANTS(:,97) = 10000;
CONSTANTS(:,98) = 0.0005;
CONSTANTS(:,99) = 0.01;
STATES(:,27) = 0.001914;
STATES(:,28) = 0.2854569;
CONSTANTS(:,100) = 1.5;
CONSTANTS(:,101) = 4;
CONSTANTS(:,102) = 12;
CONSTANTS(:,103) = 74;
CONSTANTS(:,104) = 0.49;
CONSTANTS(:,105) = 0.1;
CONSTANTS(:,106) = 0.003;
CONSTANTS(:,107) = 0.4;
CONSTANTS(:,108) = 0.03;
CONSTANTS(:,109) = 10;
CONSTANTS(:,110) = 0.03;
CONSTANTS(:,111) = 70000;
CONSTANTS(:,112) = 200;
STATES(:,29) = 0;
CONSTANTS(:,113) = 0.08;
CONSTANTS(:,114) = 100000;
CONSTANTS(:,115) = 182;
STATES(:,30) = 0;
CONSTANTS(:,116) = 0.1;
CONSTANTS(:,117) = 1000;
CONSTANTS(:,118) = 3;
CONSTANTS(:,119) = 2.9e-4;
CONSTANTS(:,120) = 2e-4;
CONSTANTS(:,121) = 1e-5;
CONSTANTS(:,122) = 0;
CONSTANTS(:,123) = 0;
STATES(:,31) = -20;
CONSTANTS(:,124) =  CONSTANTS(:,26).*CONSTANTS(:,14);
CONSTANTS(:,125) = CONSTANTS(:,14)./10.0000;
CONSTANTS(:,126) = ( CONSTANTS(:,15).*(0.400000+ 0.400000.*CONSTANTS(:,15)))./( CONSTANTS(:,14).*power( (CONSTANTS(:,15)+1.00000).*0.400000, 2.00000));
CONSTANTS(:,127) = ( 0.400000.*CONSTANTS(:,15)+1.00000)./( CONSTANTS(:,15).*CONSTANTS(:,14));
CONSTANTS(:,128) = ( 3.14159.*power(CONSTANTS(:,102)./1000.00, 2.00000).*CONSTANTS(:,103))./1000.00;
CONSTANTS(:,129) = ( CONSTANTS(:,85).*CONSTANTS(:,86))./CONSTANTS(:,87);
CONSTANTS(:,130) = CONSTANTS(:,94)./CONSTANTS(:,93);
CONSTANTS(:,131) = ( CONSTANTS(:,15).*CONSTANTS(:,16).*power(CONSTANTS(:,125)./CONSTANTS(:,14), 2.00000))./( 3.00000.*CONSTANTS(:,15).*CONSTANTS(:,16) - ( (CONSTANTS(:,15)+1.00000).*CONSTANTS(:,125))./CONSTANTS(:,14));
CONSTANTS(:,132) =  CONSTANTS(:,128).*CONSTANTS(:,104);
CONSTANTS(:,133) =  CONSTANTS(:,128).*CONSTANTS(:,107);
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(:,21) = 1.00000 -  1.00000.*(STATES(:,12)./(CONSTANTS(:,67)+STATES(:,12))+STATES(:,21));
RATES(:,22) =  CONSTANTS(:,69).*(1.00000 - (STATES(:,18)./(CONSTANTS(:,68)+STATES(:,18))+STATES(:,22)));
RATES(:,24) =  333.000.*(1.00000./(1.00000+exp( - (STATES(:,8)+4.00000)./5.00000)) - STATES(:,24));
ALGEBRAIC(:,4) = STATES(:,1);
RATES(:,4) = ALGEBRAIC(:,4);
ALGEBRAIC(:,5) = 50.0000./(1.00000+exp( - (STATES(:,8) - 5.00000)./9.00000));
ALGEBRAIC(:,17) =  0.0500000.*exp( - (STATES(:,8) - 20.0000)./15.0000);
RATES(:,13) =  ALGEBRAIC(:,5).*(1.00000 - STATES(:,13)) -  ALGEBRAIC(:,17).*STATES(:,13);
ALGEBRAIC(:,6) = 50.0000./(1.00000+exp( - (STATES(:,8) - 5.00000)./9.00000));
ALGEBRAIC(:,18) =  0.400000.*exp( - power((STATES(:,8)+30.0000)./30.0000, 3.00000));
RATES(:,14) =  ALGEBRAIC(:,6).*(1.00000 - STATES(:,14)) -  ALGEBRAIC(:,18).*STATES(:,14);
ALGEBRAIC(:,7) = 14.0000./(1.00000+exp( - (STATES(:,8) - 40.0000)./9.00000));
ALGEBRAIC(:,19) =  1.00000.*exp( - STATES(:,8)./45.0000);
RATES(:,15) =  ALGEBRAIC(:,7).*(1.00000 - STATES(:,15)) -  ALGEBRAIC(:,19).*STATES(:,15);
ALGEBRAIC(:,9) =  20.0000.*exp(  - 0.125000.*(STATES(:,8)+75.0000));
ALGEBRAIC(:,21) = 2000.00./(1.00000+ 320.000.*exp(  - 0.100000.*(STATES(:,8)+75.0000)));
RATES(:,17) =  ALGEBRAIC(:,9).*(1.00000 - STATES(:,17)) -  ALGEBRAIC(:,21).*STATES(:,17);
ALGEBRAIC(:,12) =  0.0330000.*exp( - STATES(:,8)./17.0000);
ALGEBRAIC(:,24) = 33.0000./(1.00000+exp(  - 0.125000.*(STATES(:,8)+10.0000)));
RATES(:,23) =  ALGEBRAIC(:,12).*(1.00000 - STATES(:,23)) -  ALGEBRAIC(:,24).*STATES(:,23);
ALGEBRAIC(:,15) =  CONSTANTS(:,120).*(STATES(:,31)+20.0000)+ CONSTANTS(:,122).*(STATES(:,31) - CONSTANTS(:,123));
ALGEBRAIC(:,26) =   - CONSTANTS(:,119).*(STATES(:,8) - STATES(:,31));
RATES(:,31) =  - (ALGEBRAIC(:,15)+ALGEBRAIC(:,26))./CONSTANTS(:,121);
ALGEBRAIC(:,8) = STATES(:,8)+41.0000;
ALGEBRAIC(:,20) = piecewise({abs(ALGEBRAIC(:,8))<CONSTANTS(:,61), 2000.00 }, ( 200.000.*ALGEBRAIC(:,8))./(1.00000 - exp(  - 0.100000.*ALGEBRAIC(:,8))));
ALGEBRAIC(:,28) =  8000.00.*exp(  - 0.0560000.*(STATES(:,8)+66.0000));
RATES(:,16) =  ALGEBRAIC(:,20).*(1.00000 - STATES(:,16)) -  ALGEBRAIC(:,28).*STATES(:,16);
ALGEBRAIC(:,10) = (STATES(:,8)+24.0000) - 5.00000;
ALGEBRAIC(:,22) = piecewise({abs(ALGEBRAIC(:,10))<0.000100000, 120.000 }, ( 30.0000.*ALGEBRAIC(:,10))./(1.00000 - exp( - ALGEBRAIC(:,10)./4.00000)));
ALGEBRAIC(:,29) = piecewise({abs(ALGEBRAIC(:,10))<0.000100000, 120.000 }, ( 12.0000.*ALGEBRAIC(:,10))./(exp(ALGEBRAIC(:,10)./10.0000) - 1.00000));
RATES(:,19) =  CONSTANTS(:,71).*( ALGEBRAIC(:,22).*(1.00000 - STATES(:,19)) -  ALGEBRAIC(:,29).*STATES(:,19));
ALGEBRAIC(:,11) = STATES(:,8)+34.0000;
ALGEBRAIC(:,23) = piecewise({abs(ALGEBRAIC(:,11))<CONSTANTS(:,73), 25.0000 }, ( 6.25000.*ALGEBRAIC(:,11))./(exp(ALGEBRAIC(:,11)./4.00000) - 1.00000));
ALGEBRAIC(:,30) = 12.0000./(1.00000+exp((  - 1.00000.*(STATES(:,8)+34.0000))./4.00000));
RATES(:,20) =  CONSTANTS(:,72).*( ALGEBRAIC(:,23).*(1.00000 - STATES(:,20)) -  ALGEBRAIC(:,30).*STATES(:,20));
ALGEBRAIC(:,14) = STATES(:,12)./(STATES(:,12)+CONSTANTS(:,98));
ALGEBRAIC(:,25) = STATES(:,18)./(STATES(:,18)+CONSTANTS(:,99));
ALGEBRAIC(:,31) = ALGEBRAIC(:,14)+ (1.00000 - ALGEBRAIC(:,14)).*ALGEBRAIC(:,25);
ALGEBRAIC(:,35) = 60.0000+ 500.000.*power(ALGEBRAIC(:,31), 2.00000);
ALGEBRAIC(:,37) = piecewise({STATES(:,8)< - 50.0000, 5.00000 }, 1.00000);
RATES(:,28) =  STATES(:,27).*ALGEBRAIC(:,37).*ALGEBRAIC(:,35) -  ALGEBRAIC(:,37).*0.600000.*STATES(:,28);
ALGEBRAIC(:,33) =  500.000.*power(ALGEBRAIC(:,31), 2.00000);
ALGEBRAIC(:,39) = (1.00000 - STATES(:,27)) - STATES(:,28);
RATES(:,27) =  ALGEBRAIC(:,39).*ALGEBRAIC(:,37).*ALGEBRAIC(:,33) -  STATES(:,27).*ALGEBRAIC(:,37).*ALGEBRAIC(:,35);
ALGEBRAIC(:,52) = piecewise({STATES(:,3)<=STATES(:,1),  CONSTANTS(:,43).*exp( CONSTANTS(:,42).*(STATES(:,5) - STATES(:,4))) },  CONSTANTS(:,45).*exp( CONSTANTS(:,44).*(STATES(:,5) - STATES(:,4))));
ALGEBRAIC(:,38) = STATES(:,5)+STATES(:,6);
ALGEBRAIC(:,16) =  CONSTANTS(:,7).*(exp( CONSTANTS(:,6).*STATES(:,6)) - 1.00000);
ALGEBRAIC(:,27) = ALGEBRAIC(:,16);
ALGEBRAIC(:,41) = piecewise({CONSTANTS(:,1)==1.00000&ALGEBRAIC(:,27)>CONSTANTS(:,18)&ALGEBRAIC(:,38)<= CONSTANTS(:,19).*(1.00000+0.000100000), 1.00000 }, 0.00000);
ALGEBRAIC(:,48) = piecewise({ALGEBRAIC(:,41)==1.00000, ( CONSTANTS(:,2).*CONSTANTS(:,3).*exp( CONSTANTS(:,2).*(STATES(:,5) - STATES(:,4))).*STATES(:,1))./( CONSTANTS(:,2).*CONSTANTS(:,3).*exp( CONSTANTS(:,2).*(STATES(:,5) - STATES(:,4)))+ CONSTANTS(:,4).*CONSTANTS(:,5).*exp( CONSTANTS(:,4).*STATES(:,5))) }, ( CONSTANTS(:,2).*CONSTANTS(:,3).*exp( CONSTANTS(:,2).*(STATES(:,5) - STATES(:,4))).*STATES(:,1))./( CONSTANTS(:,2).*CONSTANTS(:,3).*exp( CONSTANTS(:,2).*(STATES(:,5) - STATES(:,4)))+ CONSTANTS(:,4).*CONSTANTS(:,5).*exp( CONSTANTS(:,4).*STATES(:,5))+ CONSTANTS(:,6).*CONSTANTS(:,7).*exp( CONSTANTS(:,6).*STATES(:,6))));
ALGEBRAIC(:,55) = piecewise({ALGEBRAIC(:,52)==0.00000, ALGEBRAIC(:,48) }, STATES(:,3));
RATES(:,5) = ALGEBRAIC(:,55);
ALGEBRAIC(:,56) = piecewise({ALGEBRAIC(:,41)==1.00000, 0.00000 , ALGEBRAIC(:,41)==0.00000&ALGEBRAIC(:,52)==0.00000,  - ALGEBRAIC(:,48) , ALGEBRAIC(:,41)==0.00000&ALGEBRAIC(:,52) ~= 0.00000,  - STATES(:,3) }, NaN);
RATES(:,6) = piecewise({VOI>=CONSTANTS(:,34)&VOI<=CONSTANTS(:,35)&(VOI - CONSTANTS(:,34)) -  floor((VOI - CONSTANTS(:,34))./CONSTANTS(:,20)).*CONSTANTS(:,20)<=CONSTANTS(:,36),  - ((STATES(:,5)+STATES(:,6)) - CONSTANTS(:,19))./CONSTANTS(:,36) }, ALGEBRAIC(:,56));
ALGEBRAIC(:,32) = ( power(STATES(:,7)./CONSTANTS(:,31), CONSTANTS(:,9)).*(1.00000+power(CONSTANTS(:,10), CONSTANTS(:,9))))./(power(STATES(:,7)./CONSTANTS(:,31), CONSTANTS(:,9))+power(CONSTANTS(:,10), CONSTANTS(:,9)));
ALGEBRAIC(:,34) = piecewise({ CONSTANTS(:,32).*STATES(:,4)+CONSTANTS(:,33)<0.00000, 0.00000 ,  CONSTANTS(:,32).*STATES(:,4)+CONSTANTS(:,33)<1.00000,  CONSTANTS(:,32).*STATES(:,4)+CONSTANTS(:,33) }, 1.00000);
ALGEBRAIC(:,36) = piecewise({STATES(:,4)>0.550000, (STATES(:,4)+CONSTANTS(:,21))./(0.460000+CONSTANTS(:,21)) },  (CONSTANTS(:,21)+0.550000).*1.00000);
ALGEBRAIC(:,3) = piecewise({STATES(:,1)<=0.00000, CONSTANTS(:,22) - ( CONSTANTS(:,23).*STATES(:,1))./CONSTANTS(:,14) , STATES(:,1)<=CONSTANTS(:,124)&0.00000<STATES(:,1), ( (CONSTANTS(:,25) - CONSTANTS(:,24)).*STATES(:,1))./CONSTANTS(:,124)+CONSTANTS(:,24) }, CONSTANTS(:,25)./power(1.00000+( CONSTANTS(:,30).*(STATES(:,1) - CONSTANTS(:,124)))./CONSTANTS(:,14), CONSTANTS(:,29)));
ALGEBRAIC(:,54) = piecewise({STATES(:,1)<=0.00000, ( CONSTANTS(:,15).*(1.00000+STATES(:,1)./CONSTANTS(:,14)))./(CONSTANTS(:,15) - STATES(:,1)./CONSTANTS(:,14)) }, (1.00000+CONSTANTS(:,16)) - ( power(CONSTANTS(:,16), 2.00000).*CONSTANTS(:,15))./( (( CONSTANTS(:,15).*CONSTANTS(:,16))./CONSTANTS(:,131)).*power(STATES(:,1)./CONSTANTS(:,14), 2.00000)+( (CONSTANTS(:,15)+1.00000).*STATES(:,1))./CONSTANTS(:,14)+ CONSTANTS(:,15).*CONSTANTS(:,16)));
ALGEBRAIC(:,58) = piecewise({ - CONSTANTS(:,14)<=STATES(:,1)&STATES(:,1)<=0.00000, 1.00000+( 0.600000.*STATES(:,1))./CONSTANTS(:,14) , 0.00000<STATES(:,1)&STATES(:,1)<=CONSTANTS(:,125), ALGEBRAIC(:,54)./(( ( 0.400000.*CONSTANTS(:,15)+1.00000).*STATES(:,1))./( CONSTANTS(:,15).*CONSTANTS(:,14))+1.00000) }, ( ALGEBRAIC(:,54).*exp(  - CONSTANTS(:,27).*power((STATES(:,1) - CONSTANTS(:,125))./CONSTANTS(:,14), CONSTANTS(:,17))))./(( ( 0.400000.*CONSTANTS(:,15)+1.00000).*STATES(:,1))./( CONSTANTS(:,15).*CONSTANTS(:,14))+1.00000));
ALGEBRAIC(:,60) =  CONSTANTS(:,11).*CONSTANTS(:,12).*ALGEBRAIC(:,3).*CONSTANTS(:,13).*ALGEBRAIC(:,58);
ALGEBRAIC(:,62) =  CONSTANTS(:,12).*ALGEBRAIC(:,3).*(1.00000 -  CONSTANTS(:,11).*CONSTANTS(:,13).*ALGEBRAIC(:,58));
ALGEBRAIC(:,64) =  ALGEBRAIC(:,60).*ALGEBRAIC(:,32).*ALGEBRAIC(:,34).*ALGEBRAIC(:,36).*(1.00000 - STATES(:,2)) -  ALGEBRAIC(:,62).*STATES(:,2);
RATES(:,2) = ALGEBRAIC(:,64);
ALGEBRAIC(:,45) = piecewise({STATES(:,1)<=0.00000,  CONSTANTS(:,39).*exp( CONSTANTS(:,38).*STATES(:,4)) },  CONSTANTS(:,41).*exp( CONSTANTS(:,40).*STATES(:,4)));
ALGEBRAIC(:,70) = ALGEBRAIC(:,54)./ALGEBRAIC(:,58);
ALGEBRAIC(:,66) = ( CONSTANTS(:,15).*1.00000.*(1.00000+ 0.400000.*CONSTANTS(:,15)+( 1.20000.*STATES(:,1))./CONSTANTS(:,14)+ 0.600000.*power(STATES(:,1)./CONSTANTS(:,14), 2.00000)))./( CONSTANTS(:,14).*power( (CONSTANTS(:,15) - STATES(:,1)./CONSTANTS(:,14)).*(1.00000+( 0.600000.*STATES(:,1))./CONSTANTS(:,14)), 2.00000));
ALGEBRAIC(:,68) =  (1.00000./CONSTANTS(:,14)).*exp(  - CONSTANTS(:,27).*power(STATES(:,1)./CONSTANTS(:,14) - CONSTANTS(:,125)./CONSTANTS(:,14), CONSTANTS(:,17))).*(( 0.400000.*CONSTANTS(:,15)+1.00000)./CONSTANTS(:,15)+ CONSTANTS(:,27).*CONSTANTS(:,17).*(1.00000+( ( 0.400000.*CONSTANTS(:,15)+1.00000).*STATES(:,1))./( CONSTANTS(:,15).*CONSTANTS(:,14))).*power(STATES(:,1)./CONSTANTS(:,14) - CONSTANTS(:,125)./CONSTANTS(:,14), CONSTANTS(:,17) - 1.00000));
ALGEBRAIC(:,73) = piecewise({STATES(:,1)<= - CONSTANTS(:,14), CONSTANTS(:,126) ,  - CONSTANTS(:,14)<STATES(:,1)&STATES(:,1)<=0.00000, ALGEBRAIC(:,66) , 0.00000<STATES(:,1)&STATES(:,1)<=CONSTANTS(:,125), CONSTANTS(:,127) }, ALGEBRAIC(:,68));
ALGEBRAIC(:,43) = piecewise({STATES(:,1)<=0.00000, CONSTANTS(:,38) }, CONSTANTS(:,40));
ALGEBRAIC(:,75) = piecewise({ALGEBRAIC(:,41)==1.00000,  - ( CONSTANTS(:,8).*ALGEBRAIC(:,64).*ALGEBRAIC(:,70)+ ALGEBRAIC(:,43).*ALGEBRAIC(:,45).*power(STATES(:,1), 2.00000)+ CONSTANTS(:,4).*CONSTANTS(:,5).*exp( CONSTANTS(:,4).*STATES(:,5)).*STATES(:,3))./( CONSTANTS(:,8).*STATES(:,2).*ALGEBRAIC(:,73)+ALGEBRAIC(:,45)) },  - ( CONSTANTS(:,8).*ALGEBRAIC(:,64).*ALGEBRAIC(:,70)+ ALGEBRAIC(:,43).*ALGEBRAIC(:,45).*power(STATES(:,1), 2.00000)+ ( CONSTANTS(:,4).*CONSTANTS(:,5).*exp( CONSTANTS(:,4).*STATES(:,5))+ CONSTANTS(:,6).*CONSTANTS(:,7).*exp( CONSTANTS(:,6).*STATES(:,6))).*STATES(:,3))./( CONSTANTS(:,8).*STATES(:,2).*ALGEBRAIC(:,73)+ALGEBRAIC(:,45)));
RATES(:,1) = piecewise({ALGEBRAIC(:,52)==0.00000, ( CONSTANTS(:,2).*CONSTANTS(:,3).*exp( CONSTANTS(:,2).*(STATES(:,5) - STATES(:,4))).*(ALGEBRAIC(:,48) - STATES(:,1)) - ( CONSTANTS(:,8).*ALGEBRAIC(:,64).*ALGEBRAIC(:,70)+ ALGEBRAIC(:,43).*ALGEBRAIC(:,45).*power(STATES(:,1), 2.00000)))./( CONSTANTS(:,8).*STATES(:,2).*ALGEBRAIC(:,73)+ALGEBRAIC(:,45)) }, ALGEBRAIC(:,75));
ALGEBRAIC(:,50) = piecewise({STATES(:,3)<=STATES(:,1), CONSTANTS(:,42) }, CONSTANTS(:,44));
RATES(:,3) = piecewise({ALGEBRAIC(:,41)==1.00000&ALGEBRAIC(:,52) ~= 0.00000, (( ALGEBRAIC(:,52).*(ALGEBRAIC(:,75) -  ALGEBRAIC(:,50).*power(STATES(:,3) - STATES(:,1), 2.00000)) -  CONSTANTS(:,2).*CONSTANTS(:,3).*exp( CONSTANTS(:,2).*(STATES(:,5) - STATES(:,4))).*(STATES(:,3) - STATES(:,1))) -  CONSTANTS(:,4).*CONSTANTS(:,5).*exp( CONSTANTS(:,4).*STATES(:,5)).*STATES(:,3))./ALGEBRAIC(:,52) , ALGEBRAIC(:,41)==0.00000&ALGEBRAIC(:,52) ~= 0.00000, (ALGEBRAIC(:,75) -  ALGEBRAIC(:,50).*power(STATES(:,3) - STATES(:,1), 2.00000)) - ( CONSTANTS(:,2).*CONSTANTS(:,3).*exp( CONSTANTS(:,2).*(STATES(:,5) - STATES(:,4))).*(STATES(:,3) - STATES(:,1))+ ( CONSTANTS(:,4).*CONSTANTS(:,5).*exp( CONSTANTS(:,4).*STATES(:,5))+ CONSTANTS(:,6).*CONSTANTS(:,7).*exp( CONSTANTS(:,6).*STATES(:,6))).*STATES(:,3))./ALGEBRAIC(:,52) , ALGEBRAIC(:,52)==0.00000, 0.00000 }, NaN);
ALGEBRAIC(:,44) =  (( CONSTANTS(:,46).*CONSTANTS(:,47))./CONSTANTS(:,48)).*log(STATES(:,9)./STATES(:,10));
ALGEBRAIC(:,53) = ( (( CONSTANTS(:,54).*STATES(:,9))./(STATES(:,9)+CONSTANTS(:,53))).*(STATES(:,8) - ALGEBRAIC(:,44)))./(1.00000+exp(( ((STATES(:,8) - ALGEBRAIC(:,44)) - 10.0000).*CONSTANTS(:,48).*1.25000)./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,80) =  CONSTANTS(:,75).*(CONSTANTS(:,76)+ STATES(:,23).*(1.00000 - CONSTANTS(:,76))).*STATES(:,24).*(STATES(:,8) - ALGEBRAIC(:,44));
ALGEBRAIC(:,57) =  (( ( CONSTANTS(:,55).*STATES(:,13)+ CONSTANTS(:,56).*STATES(:,14)).*1.00000)./(1.00000+exp((STATES(:,8)+9.00000)./22.4000))).*(STATES(:,8) - ALGEBRAIC(:,44));
ALGEBRAIC(:,47) =  (( CONSTANTS(:,46).*CONSTANTS(:,47))./CONSTANTS(:,48)).*log((STATES(:,9)+ CONSTANTS(:,50).*CONSTANTS(:,51))./(STATES(:,10)+ CONSTANTS(:,50).*STATES(:,11)));
ALGEBRAIC(:,59) =  CONSTANTS(:,57).*power(STATES(:,15), 2.00000).*(STATES(:,8) - ALGEBRAIC(:,47));
ALGEBRAIC(:,69) =  ((( (1.00000 - CONSTANTS(:,70)).*CONSTANTS(:,65).*CONSTANTS(:,64).*STATES(:,19).*STATES(:,20).*STATES(:,21).*(STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47)))./(1.00000 - exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))))).*( STATES(:,10).*exp(( 50.0000.*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))) -  STATES(:,9).*exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,76) =  ((( CONSTANTS(:,70).*CONSTANTS(:,65).*CONSTANTS(:,64).*STATES(:,19).*STATES(:,20).*STATES(:,22).*(STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47)))./(1.00000 - exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))))).*( STATES(:,10).*exp(( 50.0000.*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))) -  STATES(:,9).*exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,81) = ( (( CONSTANTS(:,77).*STATES(:,9))./(CONSTANTS(:,78)+STATES(:,9))).*STATES(:,11))./(CONSTANTS(:,79)+STATES(:,11));
RATES(:,9) = ( 1.00000.*(((ALGEBRAIC(:,57)+ALGEBRAIC(:,59)+ALGEBRAIC(:,53)+ALGEBRAIC(:,80)) -  (1.00000./(CONSTANTS(:,100) - 1.00000)).*ALGEBRAIC(:,81))+ALGEBRAIC(:,69)+ALGEBRAIC(:,76)))./( 1.00000.*CONSTANTS(:,133).*CONSTANTS(:,48)) -  0.700000.*(STATES(:,9) - CONSTANTS(:,101));
RATES(:,10) =  ( - 1.00000./( 1.00000.*CONSTANTS(:,132).*CONSTANTS(:,48))).*((ALGEBRAIC(:,53)+ALGEBRAIC(:,57)+ALGEBRAIC(:,59)+ALGEBRAIC(:,69)+ALGEBRAIC(:,76)+ALGEBRAIC(:,80)) -  (1.00000./(CONSTANTS(:,100) - 1.00000)).*ALGEBRAIC(:,81));
ALGEBRAIC(:,51) =  (( CONSTANTS(:,46).*CONSTANTS(:,47))./CONSTANTS(:,48)).*log((CONSTANTS(:,51)+ 0.120000.*STATES(:,9))./(STATES(:,11)+ 0.120000.*STATES(:,10)));
ALGEBRAIC(:,61) =  CONSTANTS(:,60).*power(STATES(:,16), 3.00000).*STATES(:,17).*(STATES(:,8) - ALGEBRAIC(:,51));
ALGEBRAIC(:,42) =  (( CONSTANTS(:,46).*CONSTANTS(:,47))./CONSTANTS(:,48)).*log(CONSTANTS(:,51)./STATES(:,11));
ALGEBRAIC(:,65) =  CONSTANTS(:,63).*(STATES(:,8) - ALGEBRAIC(:,42));
ALGEBRAIC(:,63) =  (( CONSTANTS(:,62).*1.00000)./(1.00000+exp( - (STATES(:,8)+52.0000)./8.00000))).*(STATES(:,8) - ALGEBRAIC(:,42));
ALGEBRAIC(:,71) =  ((( (1.00000 - CONSTANTS(:,70)).*CONSTANTS(:,66).*CONSTANTS(:,64).*STATES(:,19).*STATES(:,20).*STATES(:,21).*(STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47)))./(1.00000 - exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))))).*( STATES(:,11).*exp(( 50.0000.*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))) -  CONSTANTS(:,51).*exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,77) =  ((( CONSTANTS(:,70).*CONSTANTS(:,66).*CONSTANTS(:,64).*STATES(:,19).*STATES(:,20).*STATES(:,22).*(STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47)))./(1.00000 - exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))))).*( STATES(:,11).*exp(( 50.0000.*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))) -  CONSTANTS(:,51).*exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,82) = ( (1.00000 - CONSTANTS(:,84)).*CONSTANTS(:,80).*( exp(( CONSTANTS(:,83).*(CONSTANTS(:,81) - 2.00000).*STATES(:,8).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))).*power(STATES(:,11), CONSTANTS(:,81)).*CONSTANTS(:,52) -  exp(( (CONSTANTS(:,83) - 1.00000).*(CONSTANTS(:,81) - 2.00000).*STATES(:,8).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))).*power(CONSTANTS(:,51), CONSTANTS(:,81)).*STATES(:,12)))./( (1.00000+ CONSTANTS(:,82).*( STATES(:,12).*power(CONSTANTS(:,51), CONSTANTS(:,81))+ CONSTANTS(:,52).*power(STATES(:,11), CONSTANTS(:,81)))).*(1.00000+STATES(:,12)./0.00690000));
ALGEBRAIC(:,83) = ( CONSTANTS(:,84).*CONSTANTS(:,80).*( exp(( CONSTANTS(:,83).*(CONSTANTS(:,81) - 2.00000).*STATES(:,8).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))).*power(STATES(:,11), CONSTANTS(:,81)).*CONSTANTS(:,52) -  exp(( (CONSTANTS(:,83) - 1.00000).*(CONSTANTS(:,81) - 2.00000).*STATES(:,8).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))).*power(CONSTANTS(:,51), CONSTANTS(:,81)).*STATES(:,18)))./( (1.00000+ CONSTANTS(:,82).*( STATES(:,18).*power(CONSTANTS(:,51), CONSTANTS(:,81))+ CONSTANTS(:,52).*power(STATES(:,11), CONSTANTS(:,81)))).*(1.00000+STATES(:,18)./0.00690000));
ALGEBRAIC(:,67) =  ((( (1.00000 - CONSTANTS(:,70)).*4.00000.*CONSTANTS(:,64).*STATES(:,19).*STATES(:,20).*STATES(:,21).*(STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47)))./(1.00000 - exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48).*2.00000)./( CONSTANTS(:,46).*CONSTANTS(:,47))))).*( STATES(:,12).*exp(( 100.000.*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))) -  CONSTANTS(:,52).*exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48).*2.00000)./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,74) =  ((( CONSTANTS(:,70).*4.00000.*CONSTANTS(:,64).*STATES(:,19).*STATES(:,20).*STATES(:,22).*(STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47)))./(1.00000 - exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48).*2.00000)./( CONSTANTS(:,46).*CONSTANTS(:,47))))).*( STATES(:,12).*exp(( 100.000.*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))) -  CONSTANTS(:,52).*exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48).*2.00000)./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,49) =  (( 0.500000.*CONSTANTS(:,46).*CONSTANTS(:,47))./CONSTANTS(:,48)).*log(CONSTANTS(:,52)./STATES(:,12));
ALGEBRAIC(:,79) =  CONSTANTS(:,74).*(STATES(:,8) - ALGEBRAIC(:,49));
ALGEBRAIC(:,40) = piecewise({VOI>=CONSTANTS(:,34)&VOI<=CONSTANTS(:,35)&(VOI - CONSTANTS(:,34)) -  floor((VOI - CONSTANTS(:,34))./CONSTANTS(:,20)).*CONSTANTS(:,20)<=CONSTANTS(:,36), CONSTANTS(:,37) }, 0.00000);
RATES(:,8) =  ( - 1.00000./CONSTANTS(:,49)).*(ALGEBRAIC(:,40)+ALGEBRAIC(:,53)+ALGEBRAIC(:,80)+ALGEBRAIC(:,57)+ALGEBRAIC(:,59)+ALGEBRAIC(:,81)+ALGEBRAIC(:,61)+ALGEBRAIC(:,65)+ALGEBRAIC(:,63)+ALGEBRAIC(:,71)+ALGEBRAIC(:,77)+ALGEBRAIC(:,82)+ALGEBRAIC(:,83)+ALGEBRAIC(:,67)+ALGEBRAIC(:,74)+ALGEBRAIC(:,69)+ALGEBRAIC(:,76)+ALGEBRAIC(:,79));
RATES(:,18) = (  - 1.00000.*ALGEBRAIC(:,74)+( 2.00000.*ALGEBRAIC(:,83))./(CONSTANTS(:,81) - 2.00000))./( 2.00000.*1.00000.*CONSTANTS(:,105).*CONSTANTS(:,132).*CONSTANTS(:,48)) -  STATES(:,18).*CONSTANTS(:,109);
ALGEBRAIC(:,85) = ALGEBRAIC(:,82)+ALGEBRAIC(:,83);
RATES(:,11) =  ( - 1.00000./( 1.00000.*CONSTANTS(:,132).*CONSTANTS(:,48))).*(ALGEBRAIC(:,61)+ALGEBRAIC(:,63)+ALGEBRAIC(:,65)+ALGEBRAIC(:,71)+ALGEBRAIC(:,77)+ (CONSTANTS(:,100)./(CONSTANTS(:,100) - 1.00000)).*ALGEBRAIC(:,81)+ (CONSTANTS(:,81)./(CONSTANTS(:,81) - 2.00000)).*ALGEBRAIC(:,85));
ALGEBRAIC(:,84) = STATES(:,12)+ STATES(:,25).*CONSTANTS(:,129)+ CONSTANTS(:,85).*CONSTANTS(:,86)+CONSTANTS(:,85);
ALGEBRAIC(:,86) = piecewise({CONSTANTS(:,90)==0.00000,  (STATES(:,12)./ALGEBRAIC(:,84)).*CONSTANTS(:,88) -  (( STATES(:,25).*CONSTANTS(:,129))./ALGEBRAIC(:,84)).*CONSTANTS(:,89) }, ( (STATES(:,12)./ALGEBRAIC(:,84)).*CONSTANTS(:,88))./(1.00000+STATES(:,25)./CONSTANTS(:,91)) -  (( STATES(:,25).*CONSTANTS(:,129))./ALGEBRAIC(:,84)).*CONSTANTS(:,89));
ALGEBRAIC(:,87) =  CONSTANTS(:,92).*(STATES(:,25) - STATES(:,26));
RATES(:,25) =  (CONSTANTS(:,104)./CONSTANTS(:,108)).*ALGEBRAIC(:,86) - ALGEBRAIC(:,87);
ALGEBRAIC(:,88) =  ( power(STATES(:,27)./(STATES(:,27)+0.250000), 2.00000).*CONSTANTS(:,97)+CONSTANTS(:,96)).*STATES(:,26);
RATES(:,26) = ( (CONSTANTS(:,108)./CONSTANTS(:,106)).*ALGEBRAIC(:,87) - ALGEBRAIC(:,88))./(1.00000+( CONSTANTS(:,130).*CONSTANTS(:,95))./power(STATES(:,26)+CONSTANTS(:,130), 2.00000));
ALGEBRAIC(:,89) = ( CONSTANTS(:,31).*STATES(:,2))./( ALGEBRAIC(:,36).*STATES(:,7));
ALGEBRAIC(:,90) = piecewise({ALGEBRAIC(:,89)<=0.00000, CONSTANTS(:,110) , ALGEBRAIC(:,89)<=1.00000, power(CONSTANTS(:,110), ALGEBRAIC(:,89)) }, 1.00000);
RATES(:,7) =  CONSTANTS(:,111).*(CONSTANTS(:,31) - STATES(:,7)).*STATES(:,12) -  CONSTANTS(:,112).*exp(  - CONSTANTS(:,28).*STATES(:,7)).*ALGEBRAIC(:,90).*STATES(:,7);
RATES(:,29) =  CONSTANTS(:,114).*(CONSTANTS(:,113) - STATES(:,29)).*STATES(:,12) -  CONSTANTS(:,115).*STATES(:,29);
RATES(:,30) =  CONSTANTS(:,117).*(CONSTANTS(:,116) - STATES(:,30)).*STATES(:,12) -  CONSTANTS(:,118).*STATES(:,30);
RATES(:,12) = (((( ( - 1.00000./( 2.00000.*1.00000.*CONSTANTS(:,132).*CONSTANTS(:,48))).*((ALGEBRAIC(:,67)+ALGEBRAIC(:,79)) -  (2.00000./(CONSTANTS(:,81) - 2.00000)).*ALGEBRAIC(:,82))+ STATES(:,18).*CONSTANTS(:,105).*CONSTANTS(:,109)+( ALGEBRAIC(:,88).*CONSTANTS(:,106))./CONSTANTS(:,104)) - RATES(:,7)) - RATES(:,29)) - RATES(:,30)) - ALGEBRAIC(:,86);
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(:,4) = STATES(:,1);
ALGEBRAIC(:,5) = 50.0000./(1.00000+exp( - (STATES(:,8) - 5.00000)./9.00000));
ALGEBRAIC(:,17) =  0.0500000.*exp( - (STATES(:,8) - 20.0000)./15.0000);
ALGEBRAIC(:,6) = 50.0000./(1.00000+exp( - (STATES(:,8) - 5.00000)./9.00000));
ALGEBRAIC(:,18) =  0.400000.*exp( - power((STATES(:,8)+30.0000)./30.0000, 3.00000));
ALGEBRAIC(:,7) = 14.0000./(1.00000+exp( - (STATES(:,8) - 40.0000)./9.00000));
ALGEBRAIC(:,19) =  1.00000.*exp( - STATES(:,8)./45.0000);
ALGEBRAIC(:,9) =  20.0000.*exp(  - 0.125000.*(STATES(:,8)+75.0000));
ALGEBRAIC(:,21) = 2000.00./(1.00000+ 320.000.*exp(  - 0.100000.*(STATES(:,8)+75.0000)));
ALGEBRAIC(:,12) =  0.0330000.*exp( - STATES(:,8)./17.0000);
ALGEBRAIC(:,24) = 33.0000./(1.00000+exp(  - 0.125000.*(STATES(:,8)+10.0000)));
ALGEBRAIC(:,15) =  CONSTANTS(:,120).*(STATES(:,31)+20.0000)+ CONSTANTS(:,122).*(STATES(:,31) - CONSTANTS(:,123));
ALGEBRAIC(:,26) =   - CONSTANTS(:,119).*(STATES(:,8) - STATES(:,31));
ALGEBRAIC(:,8) = STATES(:,8)+41.0000;
ALGEBRAIC(:,20) = piecewise({abs(ALGEBRAIC(:,8))<CONSTANTS(:,61), 2000.00 }, ( 200.000.*ALGEBRAIC(:,8))./(1.00000 - exp(  - 0.100000.*ALGEBRAIC(:,8))));
ALGEBRAIC(:,28) =  8000.00.*exp(  - 0.0560000.*(STATES(:,8)+66.0000));
ALGEBRAIC(:,10) = (STATES(:,8)+24.0000) - 5.00000;
ALGEBRAIC(:,22) = piecewise({abs(ALGEBRAIC(:,10))<0.000100000, 120.000 }, ( 30.0000.*ALGEBRAIC(:,10))./(1.00000 - exp( - ALGEBRAIC(:,10)./4.00000)));
ALGEBRAIC(:,29) = piecewise({abs(ALGEBRAIC(:,10))<0.000100000, 120.000 }, ( 12.0000.*ALGEBRAIC(:,10))./(exp(ALGEBRAIC(:,10)./10.0000) - 1.00000));
ALGEBRAIC(:,11) = STATES(:,8)+34.0000;
ALGEBRAIC(:,23) = piecewise({abs(ALGEBRAIC(:,11))<CONSTANTS(:,73), 25.0000 }, ( 6.25000.*ALGEBRAIC(:,11))./(exp(ALGEBRAIC(:,11)./4.00000) - 1.00000));
ALGEBRAIC(:,30) = 12.0000./(1.00000+exp((  - 1.00000.*(STATES(:,8)+34.0000))./4.00000));
ALGEBRAIC(:,14) = STATES(:,12)./(STATES(:,12)+CONSTANTS(:,98));
ALGEBRAIC(:,25) = STATES(:,18)./(STATES(:,18)+CONSTANTS(:,99));
ALGEBRAIC(:,31) = ALGEBRAIC(:,14)+ (1.00000 - ALGEBRAIC(:,14)).*ALGEBRAIC(:,25);
ALGEBRAIC(:,35) = 60.0000+ 500.000.*power(ALGEBRAIC(:,31), 2.00000);
ALGEBRAIC(:,37) = piecewise({STATES(:,8)< - 50.0000, 5.00000 }, 1.00000);
ALGEBRAIC(:,33) =  500.000.*power(ALGEBRAIC(:,31), 2.00000);
ALGEBRAIC(:,39) = (1.00000 - STATES(:,27)) - STATES(:,28);
ALGEBRAIC(:,52) = piecewise({STATES(:,3)<=STATES(:,1),  CONSTANTS(:,43).*exp( CONSTANTS(:,42).*(STATES(:,5) - STATES(:,4))) },  CONSTANTS(:,45).*exp( CONSTANTS(:,44).*(STATES(:,5) - STATES(:,4))));
ALGEBRAIC(:,38) = STATES(:,5)+STATES(:,6);
ALGEBRAIC(:,16) =  CONSTANTS(:,7).*(exp( CONSTANTS(:,6).*STATES(:,6)) - 1.00000);
ALGEBRAIC(:,27) = ALGEBRAIC(:,16);
ALGEBRAIC(:,41) = piecewise({CONSTANTS(:,1)==1.00000&ALGEBRAIC(:,27)>CONSTANTS(:,18)&ALGEBRAIC(:,38)<= CONSTANTS(:,19).*(1.00000+0.000100000), 1.00000 }, 0.00000);
ALGEBRAIC(:,48) = piecewise({ALGEBRAIC(:,41)==1.00000, ( CONSTANTS(:,2).*CONSTANTS(:,3).*exp( CONSTANTS(:,2).*(STATES(:,5) - STATES(:,4))).*STATES(:,1))./( CONSTANTS(:,2).*CONSTANTS(:,3).*exp( CONSTANTS(:,2).*(STATES(:,5) - STATES(:,4)))+ CONSTANTS(:,4).*CONSTANTS(:,5).*exp( CONSTANTS(:,4).*STATES(:,5))) }, ( CONSTANTS(:,2).*CONSTANTS(:,3).*exp( CONSTANTS(:,2).*(STATES(:,5) - STATES(:,4))).*STATES(:,1))./( CONSTANTS(:,2).*CONSTANTS(:,3).*exp( CONSTANTS(:,2).*(STATES(:,5) - STATES(:,4)))+ CONSTANTS(:,4).*CONSTANTS(:,5).*exp( CONSTANTS(:,4).*STATES(:,5))+ CONSTANTS(:,6).*CONSTANTS(:,7).*exp( CONSTANTS(:,6).*STATES(:,6))));
ALGEBRAIC(:,55) = piecewise({ALGEBRAIC(:,52)==0.00000, ALGEBRAIC(:,48) }, STATES(:,3));
ALGEBRAIC(:,56) = piecewise({ALGEBRAIC(:,41)==1.00000, 0.00000 , ALGEBRAIC(:,41)==0.00000&ALGEBRAIC(:,52)==0.00000,  - ALGEBRAIC(:,48) , ALGEBRAIC(:,41)==0.00000&ALGEBRAIC(:,52) ~= 0.00000,  - STATES(:,3) }, NaN);
ALGEBRAIC(:,32) = ( power(STATES(:,7)./CONSTANTS(:,31), CONSTANTS(:,9)).*(1.00000+power(CONSTANTS(:,10), CONSTANTS(:,9))))./(power(STATES(:,7)./CONSTANTS(:,31), CONSTANTS(:,9))+power(CONSTANTS(:,10), CONSTANTS(:,9)));
ALGEBRAIC(:,34) = piecewise({ CONSTANTS(:,32).*STATES(:,4)+CONSTANTS(:,33)<0.00000, 0.00000 ,  CONSTANTS(:,32).*STATES(:,4)+CONSTANTS(:,33)<1.00000,  CONSTANTS(:,32).*STATES(:,4)+CONSTANTS(:,33) }, 1.00000);
ALGEBRAIC(:,36) = piecewise({STATES(:,4)>0.550000, (STATES(:,4)+CONSTANTS(:,21))./(0.460000+CONSTANTS(:,21)) },  (CONSTANTS(:,21)+0.550000).*1.00000);
ALGEBRAIC(:,3) = piecewise({STATES(:,1)<=0.00000, CONSTANTS(:,22) - ( CONSTANTS(:,23).*STATES(:,1))./CONSTANTS(:,14) , STATES(:,1)<=CONSTANTS(:,124)&0.00000<STATES(:,1), ( (CONSTANTS(:,25) - CONSTANTS(:,24)).*STATES(:,1))./CONSTANTS(:,124)+CONSTANTS(:,24) }, CONSTANTS(:,25)./power(1.00000+( CONSTANTS(:,30).*(STATES(:,1) - CONSTANTS(:,124)))./CONSTANTS(:,14), CONSTANTS(:,29)));
ALGEBRAIC(:,54) = piecewise({STATES(:,1)<=0.00000, ( CONSTANTS(:,15).*(1.00000+STATES(:,1)./CONSTANTS(:,14)))./(CONSTANTS(:,15) - STATES(:,1)./CONSTANTS(:,14)) }, (1.00000+CONSTANTS(:,16)) - ( power(CONSTANTS(:,16), 2.00000).*CONSTANTS(:,15))./( (( CONSTANTS(:,15).*CONSTANTS(:,16))./CONSTANTS(:,131)).*power(STATES(:,1)./CONSTANTS(:,14), 2.00000)+( (CONSTANTS(:,15)+1.00000).*STATES(:,1))./CONSTANTS(:,14)+ CONSTANTS(:,15).*CONSTANTS(:,16)));
ALGEBRAIC(:,58) = piecewise({ - CONSTANTS(:,14)<=STATES(:,1)&STATES(:,1)<=0.00000, 1.00000+( 0.600000.*STATES(:,1))./CONSTANTS(:,14) , 0.00000<STATES(:,1)&STATES(:,1)<=CONSTANTS(:,125), ALGEBRAIC(:,54)./(( ( 0.400000.*CONSTANTS(:,15)+1.00000).*STATES(:,1))./( CONSTANTS(:,15).*CONSTANTS(:,14))+1.00000) }, ( ALGEBRAIC(:,54).*exp(  - CONSTANTS(:,27).*power((STATES(:,1) - CONSTANTS(:,125))./CONSTANTS(:,14), CONSTANTS(:,17))))./(( ( 0.400000.*CONSTANTS(:,15)+1.00000).*STATES(:,1))./( CONSTANTS(:,15).*CONSTANTS(:,14))+1.00000));
ALGEBRAIC(:,60) =  CONSTANTS(:,11).*CONSTANTS(:,12).*ALGEBRAIC(:,3).*CONSTANTS(:,13).*ALGEBRAIC(:,58);
ALGEBRAIC(:,62) =  CONSTANTS(:,12).*ALGEBRAIC(:,3).*(1.00000 -  CONSTANTS(:,11).*CONSTANTS(:,13).*ALGEBRAIC(:,58));
ALGEBRAIC(:,64) =  ALGEBRAIC(:,60).*ALGEBRAIC(:,32).*ALGEBRAIC(:,34).*ALGEBRAIC(:,36).*(1.00000 - STATES(:,2)) -  ALGEBRAIC(:,62).*STATES(:,2);
ALGEBRAIC(:,45) = piecewise({STATES(:,1)<=0.00000,  CONSTANTS(:,39).*exp( CONSTANTS(:,38).*STATES(:,4)) },  CONSTANTS(:,41).*exp( CONSTANTS(:,40).*STATES(:,4)));
ALGEBRAIC(:,70) = ALGEBRAIC(:,54)./ALGEBRAIC(:,58);
ALGEBRAIC(:,66) = ( CONSTANTS(:,15).*1.00000.*(1.00000+ 0.400000.*CONSTANTS(:,15)+( 1.20000.*STATES(:,1))./CONSTANTS(:,14)+ 0.600000.*power(STATES(:,1)./CONSTANTS(:,14), 2.00000)))./( CONSTANTS(:,14).*power( (CONSTANTS(:,15) - STATES(:,1)./CONSTANTS(:,14)).*(1.00000+( 0.600000.*STATES(:,1))./CONSTANTS(:,14)), 2.00000));
ALGEBRAIC(:,68) =  (1.00000./CONSTANTS(:,14)).*exp(  - CONSTANTS(:,27).*power(STATES(:,1)./CONSTANTS(:,14) - CONSTANTS(:,125)./CONSTANTS(:,14), CONSTANTS(:,17))).*(( 0.400000.*CONSTANTS(:,15)+1.00000)./CONSTANTS(:,15)+ CONSTANTS(:,27).*CONSTANTS(:,17).*(1.00000+( ( 0.400000.*CONSTANTS(:,15)+1.00000).*STATES(:,1))./( CONSTANTS(:,15).*CONSTANTS(:,14))).*power(STATES(:,1)./CONSTANTS(:,14) - CONSTANTS(:,125)./CONSTANTS(:,14), CONSTANTS(:,17) - 1.00000));
ALGEBRAIC(:,73) = piecewise({STATES(:,1)<= - CONSTANTS(:,14), CONSTANTS(:,126) ,  - CONSTANTS(:,14)<STATES(:,1)&STATES(:,1)<=0.00000, ALGEBRAIC(:,66) , 0.00000<STATES(:,1)&STATES(:,1)<=CONSTANTS(:,125), CONSTANTS(:,127) }, ALGEBRAIC(:,68));
ALGEBRAIC(:,43) = piecewise({STATES(:,1)<=0.00000, CONSTANTS(:,38) }, CONSTANTS(:,40));
ALGEBRAIC(:,75) = piecewise({ALGEBRAIC(:,41)==1.00000,  - ( CONSTANTS(:,8).*ALGEBRAIC(:,64).*ALGEBRAIC(:,70)+ ALGEBRAIC(:,43).*ALGEBRAIC(:,45).*power(STATES(:,1), 2.00000)+ CONSTANTS(:,4).*CONSTANTS(:,5).*exp( CONSTANTS(:,4).*STATES(:,5)).*STATES(:,3))./( CONSTANTS(:,8).*STATES(:,2).*ALGEBRAIC(:,73)+ALGEBRAIC(:,45)) },  - ( CONSTANTS(:,8).*ALGEBRAIC(:,64).*ALGEBRAIC(:,70)+ ALGEBRAIC(:,43).*ALGEBRAIC(:,45).*power(STATES(:,1), 2.00000)+ ( CONSTANTS(:,4).*CONSTANTS(:,5).*exp( CONSTANTS(:,4).*STATES(:,5))+ CONSTANTS(:,6).*CONSTANTS(:,7).*exp( CONSTANTS(:,6).*STATES(:,6))).*STATES(:,3))./( CONSTANTS(:,8).*STATES(:,2).*ALGEBRAIC(:,73)+ALGEBRAIC(:,45)));
ALGEBRAIC(:,50) = piecewise({STATES(:,3)<=STATES(:,1), CONSTANTS(:,42) }, CONSTANTS(:,44));
ALGEBRAIC(:,44) =  (( CONSTANTS(:,46).*CONSTANTS(:,47))./CONSTANTS(:,48)).*log(STATES(:,9)./STATES(:,10));
ALGEBRAIC(:,53) = ( (( CONSTANTS(:,54).*STATES(:,9))./(STATES(:,9)+CONSTANTS(:,53))).*(STATES(:,8) - ALGEBRAIC(:,44)))./(1.00000+exp(( ((STATES(:,8) - ALGEBRAIC(:,44)) - 10.0000).*CONSTANTS(:,48).*1.25000)./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,80) =  CONSTANTS(:,75).*(CONSTANTS(:,76)+ STATES(:,23).*(1.00000 - CONSTANTS(:,76))).*STATES(:,24).*(STATES(:,8) - ALGEBRAIC(:,44));
ALGEBRAIC(:,57) =  (( ( CONSTANTS(:,55).*STATES(:,13)+ CONSTANTS(:,56).*STATES(:,14)).*1.00000)./(1.00000+exp((STATES(:,8)+9.00000)./22.4000))).*(STATES(:,8) - ALGEBRAIC(:,44));
ALGEBRAIC(:,47) =  (( CONSTANTS(:,46).*CONSTANTS(:,47))./CONSTANTS(:,48)).*log((STATES(:,9)+ CONSTANTS(:,50).*CONSTANTS(:,51))./(STATES(:,10)+ CONSTANTS(:,50).*STATES(:,11)));
ALGEBRAIC(:,59) =  CONSTANTS(:,57).*power(STATES(:,15), 2.00000).*(STATES(:,8) - ALGEBRAIC(:,47));
ALGEBRAIC(:,69) =  ((( (1.00000 - CONSTANTS(:,70)).*CONSTANTS(:,65).*CONSTANTS(:,64).*STATES(:,19).*STATES(:,20).*STATES(:,21).*(STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47)))./(1.00000 - exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))))).*( STATES(:,10).*exp(( 50.0000.*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))) -  STATES(:,9).*exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,76) =  ((( CONSTANTS(:,70).*CONSTANTS(:,65).*CONSTANTS(:,64).*STATES(:,19).*STATES(:,20).*STATES(:,22).*(STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47)))./(1.00000 - exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))))).*( STATES(:,10).*exp(( 50.0000.*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))) -  STATES(:,9).*exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,81) = ( (( CONSTANTS(:,77).*STATES(:,9))./(CONSTANTS(:,78)+STATES(:,9))).*STATES(:,11))./(CONSTANTS(:,79)+STATES(:,11));
ALGEBRAIC(:,51) =  (( CONSTANTS(:,46).*CONSTANTS(:,47))./CONSTANTS(:,48)).*log((CONSTANTS(:,51)+ 0.120000.*STATES(:,9))./(STATES(:,11)+ 0.120000.*STATES(:,10)));
ALGEBRAIC(:,61) =  CONSTANTS(:,60).*power(STATES(:,16), 3.00000).*STATES(:,17).*(STATES(:,8) - ALGEBRAIC(:,51));
ALGEBRAIC(:,42) =  (( CONSTANTS(:,46).*CONSTANTS(:,47))./CONSTANTS(:,48)).*log(CONSTANTS(:,51)./STATES(:,11));
ALGEBRAIC(:,65) =  CONSTANTS(:,63).*(STATES(:,8) - ALGEBRAIC(:,42));
ALGEBRAIC(:,63) =  (( CONSTANTS(:,62).*1.00000)./(1.00000+exp( - (STATES(:,8)+52.0000)./8.00000))).*(STATES(:,8) - ALGEBRAIC(:,42));
ALGEBRAIC(:,71) =  ((( (1.00000 - CONSTANTS(:,70)).*CONSTANTS(:,66).*CONSTANTS(:,64).*STATES(:,19).*STATES(:,20).*STATES(:,21).*(STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47)))./(1.00000 - exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))))).*( STATES(:,11).*exp(( 50.0000.*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))) -  CONSTANTS(:,51).*exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,77) =  ((( CONSTANTS(:,70).*CONSTANTS(:,66).*CONSTANTS(:,64).*STATES(:,19).*STATES(:,20).*STATES(:,22).*(STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47)))./(1.00000 - exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))))).*( STATES(:,11).*exp(( 50.0000.*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))) -  CONSTANTS(:,51).*exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,82) = ( (1.00000 - CONSTANTS(:,84)).*CONSTANTS(:,80).*( exp(( CONSTANTS(:,83).*(CONSTANTS(:,81) - 2.00000).*STATES(:,8).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))).*power(STATES(:,11), CONSTANTS(:,81)).*CONSTANTS(:,52) -  exp(( (CONSTANTS(:,83) - 1.00000).*(CONSTANTS(:,81) - 2.00000).*STATES(:,8).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))).*power(CONSTANTS(:,51), CONSTANTS(:,81)).*STATES(:,12)))./( (1.00000+ CONSTANTS(:,82).*( STATES(:,12).*power(CONSTANTS(:,51), CONSTANTS(:,81))+ CONSTANTS(:,52).*power(STATES(:,11), CONSTANTS(:,81)))).*(1.00000+STATES(:,12)./0.00690000));
ALGEBRAIC(:,83) = ( CONSTANTS(:,84).*CONSTANTS(:,80).*( exp(( CONSTANTS(:,83).*(CONSTANTS(:,81) - 2.00000).*STATES(:,8).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))).*power(STATES(:,11), CONSTANTS(:,81)).*CONSTANTS(:,52) -  exp(( (CONSTANTS(:,83) - 1.00000).*(CONSTANTS(:,81) - 2.00000).*STATES(:,8).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))).*power(CONSTANTS(:,51), CONSTANTS(:,81)).*STATES(:,18)))./( (1.00000+ CONSTANTS(:,82).*( STATES(:,18).*power(CONSTANTS(:,51), CONSTANTS(:,81))+ CONSTANTS(:,52).*power(STATES(:,11), CONSTANTS(:,81)))).*(1.00000+STATES(:,18)./0.00690000));
ALGEBRAIC(:,67) =  ((( (1.00000 - CONSTANTS(:,70)).*4.00000.*CONSTANTS(:,64).*STATES(:,19).*STATES(:,20).*STATES(:,21).*(STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47)))./(1.00000 - exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48).*2.00000)./( CONSTANTS(:,46).*CONSTANTS(:,47))))).*( STATES(:,12).*exp(( 100.000.*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))) -  CONSTANTS(:,52).*exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48).*2.00000)./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,74) =  ((( CONSTANTS(:,70).*4.00000.*CONSTANTS(:,64).*STATES(:,19).*STATES(:,20).*STATES(:,22).*(STATES(:,8) - 50.0000).*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47)))./(1.00000 - exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48).*2.00000)./( CONSTANTS(:,46).*CONSTANTS(:,47))))).*( STATES(:,12).*exp(( 100.000.*CONSTANTS(:,48))./( CONSTANTS(:,46).*CONSTANTS(:,47))) -  CONSTANTS(:,52).*exp((  - (STATES(:,8) - 50.0000).*CONSTANTS(:,48).*2.00000)./( CONSTANTS(:,46).*CONSTANTS(:,47))));
ALGEBRAIC(:,49) =  (( 0.500000.*CONSTANTS(:,46).*CONSTANTS(:,47))./CONSTANTS(:,48)).*log(CONSTANTS(:,52)./STATES(:,12));
ALGEBRAIC(:,79) =  CONSTANTS(:,74).*(STATES(:,8) - ALGEBRAIC(:,49));
ALGEBRAIC(:,40) = piecewise({VOI>=CONSTANTS(:,34)&VOI<=CONSTANTS(:,35)&(VOI - CONSTANTS(:,34)) -  floor((VOI - CONSTANTS(:,34))./CONSTANTS(:,20)).*CONSTANTS(:,20)<=CONSTANTS(:,36), CONSTANTS(:,37) }, 0.00000);
ALGEBRAIC(:,85) = ALGEBRAIC(:,82)+ALGEBRAIC(:,83);
ALGEBRAIC(:,84) = STATES(:,12)+ STATES(:,25).*CONSTANTS(:,129)+ CONSTANTS(:,85).*CONSTANTS(:,86)+CONSTANTS(:,85);
ALGEBRAIC(:,86) = piecewise({CONSTANTS(:,90)==0.00000,  (STATES(:,12)./ALGEBRAIC(:,84)).*CONSTANTS(:,88) -  (( STATES(:,25).*CONSTANTS(:,129))./ALGEBRAIC(:,84)).*CONSTANTS(:,89) }, ( (STATES(:,12)./ALGEBRAIC(:,84)).*CONSTANTS(:,88))./(1.00000+STATES(:,25)./CONSTANTS(:,91)) -  (( STATES(:,25).*CONSTANTS(:,129))./ALGEBRAIC(:,84)).*CONSTANTS(:,89));
ALGEBRAIC(:,87) =  CONSTANTS(:,92).*(STATES(:,25) - STATES(:,26));
ALGEBRAIC(:,88) =  ( power(STATES(:,27)./(STATES(:,27)+0.250000), 2.00000).*CONSTANTS(:,97)+CONSTANTS(:,96)).*STATES(:,26);
ALGEBRAIC(:,89) = ( CONSTANTS(:,31).*STATES(:,2))./( ALGEBRAIC(:,36).*STATES(:,7));
ALGEBRAIC(:,90) = piecewise({ALGEBRAIC(:,89)<=0.00000, CONSTANTS(:,110) , ALGEBRAIC(:,89)<=1.00000, power(CONSTANTS(:,110), ALGEBRAIC(:,89)) }, 1.00000);
ALGEBRAIC(:,1) =  CONSTANTS(:,3).*(exp( CONSTANTS(:,2).*(STATES(:,5) - STATES(:,4))) - 1.00000);
ALGEBRAIC(:,2) =  CONSTANTS(:,5).*(exp( CONSTANTS(:,4).*STATES(:,5)) - 1.00000);
ALGEBRAIC(:,13) = exp( 0.0800000.*(STATES(:,8) - 40.0000));
ALGEBRAIC(:,46) =  (( CONSTANTS(:,58).*STATES(:,11))./(STATES(:,11)+CONSTANTS(:,59))).*(STATES(:,8) - ALGEBRAIC(:,44));
ALGEBRAIC(:,72) =  CONSTANTS(:,8).*ALGEBRAIC(:,70).*STATES(:,2);
ALGEBRAIC(:,78) = ALGEBRAIC(:,67)+ALGEBRAIC(:,69)+ALGEBRAIC(:,71)+ALGEBRAIC(:,74)+ALGEBRAIC(:,76)+ALGEBRAIC(:,77);
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 Sulman et al. 2008 at changeset cdb65f0bd7f1.
This exposure was expired. A more up-to-date exposure is available, or view related resources.
Collaboration
To begin collaborating on this work, please use your git client and issue this command: