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 =128;
end
% There are a total of 45 entries in each of the rate and state variable arrays.
% There are a total of 177 entries in the constant variable array.
%

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

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

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

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

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

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

function [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends()
    LEGEND_STATES = ''; LEGEND_ALGEBRAIC = ''; LEGEND_VOI = ''; LEGEND_CONSTANTS = '';
    LEGEND_VOI = strpad('time in component environment (millisecond)');
    LEGEND_STATES(:,1) = strpad('V in component cell (millivolt)');
    LEGEND_ALGEBRAIC(:,51) = strpad('i_Na in component INa (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,54) = strpad('i_Nab in component INab (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,58) = strpad('i_NaK in component INaK (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,60) = strpad('i_Kr in component IKr (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,68) = strpad('i_Ks in component IKs (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,72) = strpad('i_tos in component Itos (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,73) = strpad('i_tof in component Itof (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,77) = strpad('i_K1 in component IK1 (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,78) = strpad('i_Kp in component IKp (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,97) = strpad('i_NaCa in component INaCa (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,79) = strpad('i_Cl_Ca in component ICl_Ca (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,80) = strpad('i_Clb in component IClb (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,89) = strpad('i_CaL in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,106) = strpad('i_Cab in component ICab (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,103) = strpad('i_Cap in component ICap (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,7) = strpad('i_Stim in component cell (microA_per_microF)');
    LEGEND_CONSTANTS(:,1) = strpad('stim_start in component cell (millisecond)');
    LEGEND_CONSTANTS(:,2) = strpad('stim_period in component cell (millisecond)');
    LEGEND_CONSTANTS(:,3) = strpad('stim_duration in component cell (millisecond)');
    LEGEND_CONSTANTS(:,4) = strpad('stim_amplitude in component cell (microA_per_microF)');
    LEGEND_CONSTANTS(:,5) = strpad('Ko in component model_parameters (millimolar)');
    LEGEND_CONSTANTS(:,6) = strpad('Nao in component model_parameters (millimolar)');
    LEGEND_CONSTANTS(:,7) = strpad('Cao in component model_parameters (millimolar)');
    LEGEND_CONSTANTS(:,8) = strpad('Clo in component model_parameters (millimolar)');
    LEGEND_CONSTANTS(:,9) = strpad('Ki in component model_parameters (millimolar)');
    LEGEND_CONSTANTS(:,10) = strpad('Mgi in component model_parameters (millimolar)');
    LEGEND_CONSTANTS(:,11) = strpad('Mgo in component model_parameters (millimolar)');
    LEGEND_CONSTANTS(:,12) = strpad('Cli in component model_parameters (millimolar)');
    LEGEND_CONSTANTS(:,13) = strpad('R in component model_parameters (joule_per_kilomole_kelvin)');
    LEGEND_CONSTANTS(:,14) = strpad('T in component model_parameters (kelvin)');
    LEGEND_CONSTANTS(:,15) = strpad('F in component model_parameters (coulomb_per_mole)');
    LEGEND_CONSTANTS(:,170) = strpad('Cm in component model_parameters (farad)');
    LEGEND_CONSTANTS(:,16) = strpad('Cm_per_area in component model_parameters (farad_per_cm2)');
    LEGEND_CONSTANTS(:,17) = strpad('cell_length in component model_parameters (micrometre)');
    LEGEND_CONSTANTS(:,18) = strpad('cell_radius in component model_parameters (micrometre)');
    LEGEND_CONSTANTS(:,19) = strpad('jct_radius in component model_parameters (micrometre)');
    LEGEND_CONSTANTS(:,20) = strpad('jct_depth in component model_parameters (micrometre)');
    LEGEND_CONSTANTS(:,21) = strpad('SL_depth in component model_parameters (micrometre)');
    LEGEND_CONSTANTS(:,171) = strpad('Vol_Cell in component model_parameters (litre)');
    LEGEND_CONSTANTS(:,172) = strpad('Vol_SR in component model_parameters (litre)');
    LEGEND_CONSTANTS(:,173) = strpad('Vol_SL in component model_parameters (litre)');
    LEGEND_CONSTANTS(:,174) = strpad('Vol_jct in component model_parameters (litre)');
    LEGEND_CONSTANTS(:,175) = strpad('Vol_cytosol in component model_parameters (litre)');
    LEGEND_CONSTANTS(:,176) = strpad('Vol_mito in component model_parameters (litre)');
    LEGEND_ALGEBRAIC(:,22) = strpad('E_Na_jct in component reversal_potentials (millivolt)');
    LEGEND_ALGEBRAIC(:,40) = strpad('E_Na_SL in component reversal_potentials (millivolt)');
    LEGEND_ALGEBRAIC(:,45) = strpad('E_Ca_jct in component reversal_potentials (millivolt)');
    LEGEND_ALGEBRAIC(:,47) = strpad('E_Ca_SL in component reversal_potentials (millivolt)');
    LEGEND_CONSTANTS(:,151) = strpad('E_K in component reversal_potentials (millivolt)');
    LEGEND_CONSTANTS(:,152) = strpad('E_Cl in component reversal_potentials (millivolt)');
    LEGEND_STATES(:,2) = strpad('Nai in component Na_buffer (millimolar)');
    LEGEND_STATES(:,3) = strpad('Na_jct in component Na_buffer (millimolar)');
    LEGEND_STATES(:,4) = strpad('Na_SL in component Na_buffer (millimolar)');
    LEGEND_STATES(:,5) = strpad('Cai in component Ca_buffer (millimolar)');
    LEGEND_STATES(:,6) = strpad('Ca_jct in component Ca_buffer (millimolar)');
    LEGEND_STATES(:,7) = strpad('Ca_SL in component Ca_buffer (millimolar)');
    LEGEND_ALGEBRAIC(:,49) = strpad('i_Na_jct in component INa (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,50) = strpad('i_Na_SL in component INa (microA_per_microF)');
    LEGEND_CONSTANTS(:,22) = strpad('G_INa in component INa (milliS_per_microF)');
    LEGEND_CONSTANTS(:,23) = strpad('Fx_Na_jct in component INa (dimensionless)');
    LEGEND_CONSTANTS(:,24) = strpad('Fx_Na_SL in component INa (dimensionless)');
    LEGEND_STATES(:,8) = strpad('m in component INa_m_gate (dimensionless)');
    LEGEND_STATES(:,9) = strpad('h in component INa_h_gate (dimensionless)');
    LEGEND_STATES(:,10) = strpad('j in component INa_j_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,48) = strpad('openProb in component INa (dimensionless)');
    LEGEND_ALGEBRAIC(:,1) = strpad('alpha_h in component INa_h_gate (per_millisecond)');
    LEGEND_ALGEBRAIC(:,18) = strpad('beta_h in component INa_h_gate (per_millisecond)');
    LEGEND_ALGEBRAIC(:,37) = strpad('tau_h in component INa_h_gate (millisecond)');
    LEGEND_ALGEBRAIC(:,42) = strpad('h_infinity in component INa_h_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,2) = strpad('alpha_j in component INa_j_gate (per_millisecond)');
    LEGEND_ALGEBRAIC(:,19) = strpad('beta_j in component INa_j_gate (per_millisecond)');
    LEGEND_ALGEBRAIC(:,38) = strpad('tau_j in component INa_j_gate (millisecond)');
    LEGEND_ALGEBRAIC(:,43) = strpad('j_infinity in component INa_j_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,3) = strpad('alpha_m in component INa_m_gate (per_millisecond)');
    LEGEND_ALGEBRAIC(:,20) = strpad('beta_m in component INa_m_gate (per_millisecond)');
    LEGEND_ALGEBRAIC(:,39) = strpad('tau_m in component INa_m_gate (millisecond)');
    LEGEND_ALGEBRAIC(:,44) = strpad('m_infinity in component INa_m_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,52) = strpad('i_Nab_jct in component INab (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,53) = strpad('i_Nab_SL in component INab (microA_per_microF)');
    LEGEND_CONSTANTS(:,25) = strpad('G_NaBk in component INab (milliS_per_microF)');
    LEGEND_CONSTANTS(:,26) = strpad('Fx_NaBk_jct in component INab (dimensionless)');
    LEGEND_CONSTANTS(:,27) = strpad('Fx_NaBk_SL in component INab (dimensionless)');
    LEGEND_ALGEBRAIC(:,56) = strpad('i_NaK_jct in component INaK (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,57) = strpad('i_NaK_SL in component INaK (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,55) = strpad('f_NaK in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,28) = strpad('Q10_NaK in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,153) = strpad('Q_NaK in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,29) = strpad('H_NaK in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,30) = strpad('Q10_Km_Nai in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,154) = strpad('Q_Km_Nai in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,31) = strpad('Km_Nai in component INaK (millimolar)');
    LEGEND_CONSTANTS(:,32) = strpad('Km_Ko in component INaK (millimolar)');
    LEGEND_CONSTANTS(:,33) = strpad('I_NaK_max in component INaK (microA_per_microF)');
    LEGEND_CONSTANTS(:,155) = strpad('sigma in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,34) = strpad('Fx_NaK_jct in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,35) = strpad('Fx_NaK_SL in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,156) = strpad('G_IKr in component IKr (milliS_per_microF)');
    LEGEND_STATES(:,11) = strpad('Xr in component IKr_Xr_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,59) = strpad('Rr in component IKr_Rr_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,4) = strpad('Xr_infinity in component IKr_Xr_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,21) = strpad('tau_Xr in component IKr_Xr_gate (millisecond)');
    LEGEND_ALGEBRAIC(:,66) = strpad('i_Ks_jct in component IKs (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,67) = strpad('i_Ks_SL in component IKs (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,64) = strpad('G_Ks_SL in component IKs (milliS_per_microF)');
    LEGEND_ALGEBRAIC(:,63) = strpad('G_Ks_jct in component IKs (milliS_per_microF)');
    LEGEND_CONSTANTS(:,36) = strpad('Fx_Ks_jct in component IKs (dimensionless)');
    LEGEND_CONSTANTS(:,37) = strpad('Fx_Ks_SL in component IKs (dimensionless)');
    LEGEND_ALGEBRAIC(:,5) = strpad('E_Ks_jct in component IKs (millivolt)');
    LEGEND_ALGEBRAIC(:,6) = strpad('E_Ks_SL in component IKs (millivolt)');
    LEGEND_ALGEBRAIC(:,65) = strpad('E_Ks in component IKs (millivolt)');
    LEGEND_CONSTANTS(:,38) = strpad('pKNa in component IKs (dimensionless)');
    LEGEND_ALGEBRAIC(:,61) = strpad('pCa_jct in component IKs (dimensionless)');
    LEGEND_ALGEBRAIC(:,62) = strpad('pCa_SL in component IKs (dimensionless)');
    LEGEND_STATES(:,12) = strpad('Xs in component IKs_Xs_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,8) = strpad('Xs_infinity in component IKs_Xs_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,23) = strpad('tau_Xs in component IKs_Xs_gate (millisecond)');
    LEGEND_CONSTANTS(:,39) = strpad('G_tos in component Itos (milliS_per_microF)');
    LEGEND_STATES(:,13) = strpad('Y_tos in component Itos_Y_gate (dimensionless)');
    LEGEND_STATES(:,14) = strpad('X_tos in component Itos_X_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,71) = strpad('R_tos in component Itos_R_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,9) = strpad('X_tos_infinity in component Itos_X_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,24) = strpad('tau_X_tos in component Itos_X_gate (millisecond)');
    LEGEND_ALGEBRAIC(:,10) = strpad('Y_tos_infinity in component Itos_Y_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,25) = strpad('tau_Y_tos in component Itos_Y_gate (millisecond)');
    LEGEND_STATES(:,15) = strpad('R_tos_other in component Itos_R_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,69) = strpad('R_tos_infinity in component Itos_R_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,70) = strpad('tau_R_tos in component Itos_R_gate (millisecond)');
    LEGEND_CONSTANTS(:,40) = strpad('G_tof in component Itof (milliS_per_microF)');
    LEGEND_STATES(:,16) = strpad('Y_tof in component Itof_Y_gate (dimensionless)');
    LEGEND_STATES(:,17) = strpad('X_tof in component Itof_X_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,11) = strpad('X_tof_infinity in component Itof_X_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,26) = strpad('tau_X_tof in component Itof_X_gate (millisecond)');
    LEGEND_ALGEBRAIC(:,12) = strpad('Y_tof_infinity in component Itof_Y_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,27) = strpad('tau_Y_tof in component Itof_Y_gate (millisecond)');
    LEGEND_CONSTANTS(:,157) = strpad('G_K1 in component IK1 (milliS_per_microF)');
    LEGEND_ALGEBRAIC(:,76) = strpad('K1_infinity in component IK1_K1_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,74) = strpad('alpha_K1 in component IK1_K1_gate (per_millisecond)');
    LEGEND_ALGEBRAIC(:,75) = strpad('beta_K1 in component IK1_K1_gate (per_millisecond)');
    LEGEND_CONSTANTS(:,41) = strpad('g_Kp in component IKp (milliS_per_microF)');
    LEGEND_CONSTANTS(:,42) = strpad('G_Cl in component ICl_Ca (milliS_per_microF)');
    LEGEND_CONSTANTS(:,43) = strpad('Kd_ClCa in component ICl_Ca (millimolar)');
    LEGEND_CONSTANTS(:,44) = strpad('Fx_Cl_jct in component ICl_Ca (dimensionless)');
    LEGEND_CONSTANTS(:,45) = strpad('Fx_Cl_SL in component ICl_Ca (dimensionless)');
    LEGEND_CONSTANTS(:,46) = strpad('G_ClBk in component IClb (milliS_per_microF)');
    LEGEND_ALGEBRAIC(:,83) = strpad('i_CaL_Ca_SL in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,86) = strpad('i_CaL_Ca_jct in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,84) = strpad('i_CaL_Na_SL in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,87) = strpad('i_CaL_Na_jct in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,88) = strpad('i_CaL_K in component ICaL (microA_per_microF)');
    LEGEND_CONSTANTS(:,47) = strpad('PCa in component ICaL (litre_per_farad_millisecond)');
    LEGEND_CONSTANTS(:,48) = strpad('PNa in component ICaL (litre_per_farad_millisecond)');
    LEGEND_CONSTANTS(:,49) = strpad('PK in component ICaL (litre_per_farad_millisecond)');
    LEGEND_CONSTANTS(:,50) = strpad('Fx_ICaL_jct in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,51) = strpad('Fx_ICaL_SL in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,52) = strpad('gamma_Cai in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,53) = strpad('gamma_Cao in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,54) = strpad('gamma_Nai in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,55) = strpad('gamma_Nao in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,56) = strpad('gamma_Ki in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,57) = strpad('gamma_Ko in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,58) = strpad('Q10_CaL in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,158) = strpad('Q_CaL in component ICaL (dimensionless)');
    LEGEND_STATES(:,18) = strpad('d in component ICaL_d_gate (dimensionless)');
    LEGEND_STATES(:,19) = strpad('f in component ICaL_f_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,82) = strpad('fCa_SL in component ICaL_fCa_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,85) = strpad('fCa_jct in component ICaL_fCa_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,81) = strpad('temp in component ICaL (coulomb_per_mole)');
    LEGEND_ALGEBRAIC(:,13) = strpad('d_infinity in component ICaL_d_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,28) = strpad('tau_d in component ICaL_d_gate (millisecond)');
    LEGEND_ALGEBRAIC(:,14) = strpad('f_infinity in component ICaL_f_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,29) = strpad('tau_f in component ICaL_f_gate (millisecond)');
    LEGEND_STATES(:,20) = strpad('fCaB_SL in component ICaL_fCa_gate (dimensionless)');
    LEGEND_STATES(:,21) = strpad('fCaB_jct in component ICaL_fCa_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,95) = strpad('i_NaCa_SL in component INaCa (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,94) = strpad('i_NaCa_jct in component INaCa (microA_per_microF)');
    LEGEND_CONSTANTS(:,59) = strpad('V_max in component INaCa (microA_per_microF)');
    LEGEND_CONSTANTS(:,60) = strpad('Fx_NCX_jct in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,61) = strpad('Fx_NCX_SL in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,62) = strpad('Q10_NCX in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,159) = strpad('Q_NCX in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,63) = strpad('K_mNai in component INaCa (millimolar)');
    LEGEND_CONSTANTS(:,64) = strpad('K_mCao in component INaCa (millimolar)');
    LEGEND_CONSTANTS(:,65) = strpad('K_mNao in component INaCa (millimolar)');
    LEGEND_CONSTANTS(:,66) = strpad('K_mCai in component INaCa (millimolar)');
    LEGEND_ALGEBRAIC(:,92) = strpad('Ka_SL in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,93) = strpad('Ka_jct in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,67) = strpad('Kd_act in component INaCa (millimolar)');
    LEGEND_CONSTANTS(:,68) = strpad('ksat in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,69) = strpad('eta in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,70) = strpad('HNa in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,90) = strpad('temp_jct in component INaCa (millimolar4)');
    LEGEND_ALGEBRAIC(:,91) = strpad('temp_SL in component INaCa (millimolar4)');
    LEGEND_ALGEBRAIC(:,102) = strpad('i_Cap_SL in component ICap (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,100) = strpad('i_Cap_jct in component ICap (microA_per_microF)');
    LEGEND_CONSTANTS(:,71) = strpad('V_max in component ICap (millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,72) = strpad('Fx_SLCaP_jct in component ICap (dimensionless)');
    LEGEND_CONSTANTS(:,73) = strpad('Fx_SLCaP_SL in component ICap (dimensionless)');
    LEGEND_CONSTANTS(:,74) = strpad('Q10_SLCaP in component ICap (dimensionless)');
    LEGEND_CONSTANTS(:,160) = strpad('Q_SLCaP in component ICap (dimensionless)');
    LEGEND_CONSTANTS(:,75) = strpad('Km in component ICap (millimolar)');
    LEGEND_CONSTANTS(:,76) = strpad('H in component ICap (dimensionless)');
    LEGEND_CONSTANTS(:,177) = strpad('V_maxAF_old in component ICap (microA_per_microF)');
    LEGEND_CONSTANTS(:,77) = strpad('V_maxAF in component ICap (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,104) = strpad('i_Cab_jct in component ICab (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,105) = strpad('i_Cab_SL in component ICab (microA_per_microF)');
    LEGEND_CONSTANTS(:,78) = strpad('G_CaBk in component ICab (milliS_per_microF)');
    LEGEND_CONSTANTS(:,79) = strpad('Fx_CaBk_jct in component ICab (dimensionless)');
    LEGEND_CONSTANTS(:,80) = strpad('Fx_CaBk_SL in component ICab (dimensionless)');
    LEGEND_ALGEBRAIC(:,107) = strpad('j_rel_SR in component Jrel_SR (millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,81) = strpad('Max_SR in component Jrel_SR (dimensionless)');
    LEGEND_CONSTANTS(:,82) = strpad('Min_SR in component Jrel_SR (dimensionless)');
    LEGEND_CONSTANTS(:,83) = strpad('EC50_SR in component Jrel_SR (millimolar)');
    LEGEND_STATES(:,22) = strpad('R in component Jrel_SR (dimensionless)');
    LEGEND_STATES(:,23) = strpad('I in component Jrel_SR (dimensionless)');
    LEGEND_ALGEBRAIC(:,46) = strpad('RI in component Jrel_SR (dimensionless)');
    LEGEND_STATES(:,24) = strpad('O in component Jrel_SR (dimensionless)');
    LEGEND_CONSTANTS(:,84) = strpad('ks in component Jrel_SR (per_millisecond)');
    LEGEND_CONSTANTS(:,85) = strpad('koCa in component Jrel_SR (per_millimolar2_per_millisecond)');
    LEGEND_CONSTANTS(:,86) = strpad('kom in component Jrel_SR (per_millisecond)');
    LEGEND_CONSTANTS(:,87) = strpad('kiCa in component Jrel_SR (per_millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,88) = strpad('kim in component Jrel_SR (per_millisecond)');
    LEGEND_CONSTANTS(:,89) = strpad('HSR in component Jrel_SR (dimensionless)');
    LEGEND_STATES(:,25) = strpad('Ca_SR in component Ca_buffer (millimolar)');
    LEGEND_ALGEBRAIC(:,15) = strpad('kCaSR in component Jrel_SR (dimensionless)');
    LEGEND_ALGEBRAIC(:,30) = strpad('koSRCa in component Jrel_SR (per_millimolar2_per_millisecond)');
    LEGEND_ALGEBRAIC(:,41) = strpad('kiSRCa in component Jrel_SR (per_millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,108) = strpad('j_leak_SR in component Jleak_SR (millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,90) = strpad('KSRleak in component Jleak_SR (per_millisecond)');
    LEGEND_ALGEBRAIC(:,109) = strpad('j_pump_SR in component Jpump_SR (millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,91) = strpad('V_max in component Jpump_SR (millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,92) = strpad('Q10_SRCaP in component Jpump_SR (dimensionless)');
    LEGEND_CONSTANTS(:,161) = strpad('Q_SRCaP in component Jpump_SR (dimensionless)');
    LEGEND_CONSTANTS(:,93) = strpad('Kmf in component Jpump_SR (millimolar)');
    LEGEND_CONSTANTS(:,94) = strpad('Kmr in component Jpump_SR (millimolar)');
    LEGEND_CONSTANTS(:,95) = strpad('H in component Jpump_SR (dimensionless)');
    LEGEND_ALGEBRAIC(:,96) = strpad('J_Na_jct_SL in component ion_diffusion (millimole_per_millisecond)');
    LEGEND_ALGEBRAIC(:,99) = strpad('J_Na_SL_cytosol in component ion_diffusion (millimole_per_millisecond)');
    LEGEND_ALGEBRAIC(:,111) = strpad('J_Ca_jct_SL in component ion_diffusion (millimole_per_millisecond)');
    LEGEND_ALGEBRAIC(:,112) = strpad('J_Ca_SL_cytosol in component ion_diffusion (millimole_per_millisecond)');
    LEGEND_CONSTANTS(:,96) = strpad('D_Ca_jct_SL in component ion_diffusion (dm2_per_second)');
    LEGEND_CONSTANTS(:,97) = strpad('D_Ca_SL_cytosol in component ion_diffusion (dm2_per_second)');
    LEGEND_CONSTANTS(:,98) = strpad('D_Na_jct_SL in component ion_diffusion (dm2_per_second)');
    LEGEND_CONSTANTS(:,99) = strpad('D_Na_SL_cytosol in component ion_diffusion (dm2_per_second)');
    LEGEND_CONSTANTS(:,100) = strpad('x_jct_SL in component ion_diffusion (micrometre)');
    LEGEND_CONSTANTS(:,101) = strpad('x_SL_cytosol in component ion_diffusion (micrometre)');
    LEGEND_CONSTANTS(:,102) = strpad('A_jct_SL in component ion_diffusion (cm2)');
    LEGEND_CONSTANTS(:,103) = strpad('A_SL_cytosol in component ion_diffusion (cm2)');
    LEGEND_CONSTANTS(:,162) = strpad('j_Na_jct_SL in component ion_diffusion (litre_per_millisecond)');
    LEGEND_CONSTANTS(:,163) = strpad('j_Na_SL_cytosol in component ion_diffusion (litre_per_millisecond)');
    LEGEND_CONSTANTS(:,164) = strpad('j_Ca_jct_SL in component ion_diffusion (litre_per_millisecond)');
    LEGEND_CONSTANTS(:,165) = strpad('j_Ca_SL_cytosol in component ion_diffusion (litre_per_millisecond)');
    LEGEND_CONSTANTS(:,166) = strpad('j_Na_jct_SL_new in component ion_diffusion (litre_per_millisecond)');
    LEGEND_CONSTANTS(:,167) = strpad('j_Na_SL_cytosol_new in component ion_diffusion (litre_per_millisecond)');
    LEGEND_CONSTANTS(:,168) = strpad('j_Ca_jct_SL_new in component ion_diffusion (litre_per_millisecond)');
    LEGEND_CONSTANTS(:,169) = strpad('j_Ca_SL_cytosol_new in component ion_diffusion (litre_per_millisecond)');
    LEGEND_STATES(:,26) = strpad('Na_SL_buf in component Na_buffer (millimolar)');
    LEGEND_STATES(:,27) = strpad('Na_jct_buf in component Na_buffer (millimolar)');
    LEGEND_CONSTANTS(:,104) = strpad('Bmax_SL in component Na_buffer (millimolar)');
    LEGEND_CONSTANTS(:,105) = strpad('Bmax_jct in component Na_buffer (millimolar)');
    LEGEND_CONSTANTS(:,106) = strpad('kon in component Na_buffer (per_millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,107) = strpad('koff in component Na_buffer (per_millisecond)');
    LEGEND_ALGEBRAIC(:,98) = strpad('dNa_jct_buf in component Na_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,101) = strpad('dNa_SL_buf in component Na_buffer (millimolar_per_millisecond)');
    LEGEND_STATES(:,28) = strpad('Ca_SLB_SL in component Ca_buffer (millimolar)');
    LEGEND_STATES(:,29) = strpad('Ca_SLB_jct in component Ca_buffer (millimolar)');
    LEGEND_STATES(:,30) = strpad('Ca_SLHigh_SL in component Ca_buffer (millimolar)');
    LEGEND_STATES(:,31) = strpad('Ca_SLHigh_jct in component Ca_buffer (millimolar)');
    LEGEND_STATES(:,32) = strpad('Ca_Calsequestrin in component Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,108) = strpad('Bmax_SLB_SL in component Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,109) = strpad('Bmax_SLB_jct in component Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,110) = strpad('Bmax_SLHigh_SL in component Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,111) = strpad('Bmax_SLHigh_jct in component Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,112) = strpad('Bmax_Calsequestrin in component Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,113) = strpad('kon_SL in component Ca_buffer (per_millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,114) = strpad('kon_Calsequestrin in component Ca_buffer (per_millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,115) = strpad('koff_SLB in component Ca_buffer (per_millisecond)');
    LEGEND_CONSTANTS(:,116) = strpad('koff_SLHigh in component Ca_buffer (per_millisecond)');
    LEGEND_CONSTANTS(:,117) = strpad('koff_Calsequestrin in component Ca_buffer (per_millisecond)');
    LEGEND_ALGEBRAIC(:,110) = strpad('dCalsequestrin in component Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,128) = strpad('dCa_cytosol_tot_bound in component cytosolic_Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,115) = strpad('dCa_SLB_SL in component Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,113) = strpad('dCa_SLB_jct in component Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,118) = strpad('dCa_SLHigh_SL in component Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,116) = strpad('dCa_SLHigh_jct in component Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,119) = strpad('dCa_jct_tot_bound in component Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,122) = strpad('dCa_SL_tot_bound in component Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,121) = strpad('i_Ca_jct_tot in component Ca_buffer (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,124) = strpad('i_Ca_SL_tot in component Ca_buffer (microA_per_microF)');
    LEGEND_STATES(:,33) = strpad('Ca_TroponinC in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_STATES(:,34) = strpad('Ca_TroponinC_Ca_Mg in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_STATES(:,35) = strpad('Mg_TroponinC_Ca_Mg in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_STATES(:,36) = strpad('Ca_Calmodulin in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_STATES(:,37) = strpad('Ca_Myosin in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_STATES(:,38) = strpad('Mg_Myosin in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_STATES(:,39) = strpad('Ca_SRB in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,118) = strpad('Bmax_TroponinC in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,119) = strpad('Bmax_TroponinC_Ca_Mg_Ca in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,120) = strpad('Bmax_TroponinC_Ca_Mg_Mg in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,121) = strpad('Bmax_Calmodulin in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,122) = strpad('Bmax_Myosin_Ca in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,123) = strpad('Bmax_Myosin_Mg in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,124) = strpad('Bmax_SRB in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_CONSTANTS(:,125) = strpad('kon_TroponinC in component cytosolic_Ca_buffer (per_millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,126) = strpad('kon_TroponinC_Ca_Mg_Ca in component cytosolic_Ca_buffer (per_millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,127) = strpad('kon_TroponinC_Ca_Mg_Mg in component cytosolic_Ca_buffer (per_millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,128) = strpad('kon_Calmodulin in component cytosolic_Ca_buffer (per_millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,129) = strpad('kon_Myosin_Ca in component cytosolic_Ca_buffer (per_millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,130) = strpad('kon_Myosin_Mg in component cytosolic_Ca_buffer (per_millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,131) = strpad('kon_SRB in component cytosolic_Ca_buffer (per_millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,132) = strpad('koff_TroponinC in component cytosolic_Ca_buffer (per_millisecond)');
    LEGEND_CONSTANTS(:,133) = strpad('koff_TroponinC_Ca_Mg_Ca in component cytosolic_Ca_buffer (per_millisecond)');
    LEGEND_CONSTANTS(:,134) = strpad('koff_TroponinC_Ca_Mg_Mg in component cytosolic_Ca_buffer (per_millisecond)');
    LEGEND_CONSTANTS(:,135) = strpad('koff_Calmodulin in component cytosolic_Ca_buffer (per_millisecond)');
    LEGEND_CONSTANTS(:,136) = strpad('koff_Myosin_Ca in component cytosolic_Ca_buffer (per_millisecond)');
    LEGEND_CONSTANTS(:,137) = strpad('koff_Myosin_Mg in component cytosolic_Ca_buffer (per_millisecond)');
    LEGEND_CONSTANTS(:,138) = strpad('koff_SRB in component cytosolic_Ca_buffer (per_millisecond)');
    LEGEND_ALGEBRAIC(:,114) = strpad('dCa_TroponinC in component cytosolic_Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,117) = strpad('dCa_TroponinC_Ca_Mg in component cytosolic_Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,120) = strpad('dMg_TroponinC_Ca_Mg in component cytosolic_Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,123) = strpad('dCa_Calmodulin in component cytosolic_Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,125) = strpad('dCa_Myosin in component cytosolic_Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,126) = strpad('dMg_Myosin in component cytosolic_Ca_buffer (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,127) = strpad('dCa_SRB in component cytosolic_Ca_buffer (millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,139) = strpad('Indo1 in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_CONSTANTS(:,140) = strpad('Fluo3 in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_STATES(:,40) = strpad('Ca_Indo1_Cytosol in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_STATES(:,41) = strpad('Ca_Indo1_SL in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_STATES(:,42) = strpad('Ca_Indo1_jct in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_STATES(:,43) = strpad('Ca_Fluo3_Cytosol in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_STATES(:,44) = strpad('Ca_Fluo3_SL in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_STATES(:,45) = strpad('Ca_Fluo3_jct in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_CONSTANTS(:,141) = strpad('Bmax_Indo1_Cytosol in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_CONSTANTS(:,142) = strpad('Bmax_Indo1_SL in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_CONSTANTS(:,143) = strpad('Bmax_Indo1_jct in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_CONSTANTS(:,144) = strpad('Bmax_Fluo3_Cytosol in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_CONSTANTS(:,145) = strpad('Bmax_Fluo3_SL in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_CONSTANTS(:,146) = strpad('Bmax_Fluo3_jct in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_CONSTANTS(:,147) = strpad('kon_Indo1 in component indo_fluo_Ca_buffer_not_connected (per_millimolar2_per_millisecond)');
    LEGEND_CONSTANTS(:,148) = strpad('kon_Fluo3 in component indo_fluo_Ca_buffer_not_connected (per_millimolar2_per_millisecond)');
    LEGEND_CONSTANTS(:,149) = strpad('koff_Indo1 in component indo_fluo_Ca_buffer_not_connected (per_millisecond)');
    LEGEND_CONSTANTS(:,150) = strpad('koff_Fluo3 in component indo_fluo_Ca_buffer_not_connected (per_millisecond)');
    LEGEND_ALGEBRAIC(:,16) = strpad('Indo1Bound in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_ALGEBRAIC(:,17) = strpad('Fluo3Bound in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_ALGEBRAIC(:,31) = strpad('dCa_Indo1_Cytosol in component indo_fluo_Ca_buffer_not_connected (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,32) = strpad('dCa_Indo1_jct in component indo_fluo_Ca_buffer_not_connected (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,33) = strpad('dCa_Indo1_SL in component indo_fluo_Ca_buffer_not_connected (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,34) = strpad('dCa_Fluo3_Cytosol in component indo_fluo_Ca_buffer_not_connected (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,35) = strpad('dCa_Fluo3_jct in component indo_fluo_Ca_buffer_not_connected (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,36) = strpad('dCa_Fluo3_SL in component indo_fluo_Ca_buffer_not_connected (millimolar_per_millisecond)');
    LEGEND_RATES(:,1) = strpad('d/dt V in component cell (millivolt)');
    LEGEND_RATES(:,9) = strpad('d/dt h in component INa_h_gate (dimensionless)');
    LEGEND_RATES(:,10) = strpad('d/dt j in component INa_j_gate (dimensionless)');
    LEGEND_RATES(:,8) = strpad('d/dt m in component INa_m_gate (dimensionless)');
    LEGEND_RATES(:,11) = strpad('d/dt Xr in component IKr_Xr_gate (dimensionless)');
    LEGEND_RATES(:,12) = strpad('d/dt Xs in component IKs_Xs_gate (dimensionless)');
    LEGEND_RATES(:,14) = strpad('d/dt X_tos in component Itos_X_gate (dimensionless)');
    LEGEND_RATES(:,13) = strpad('d/dt Y_tos in component Itos_Y_gate (dimensionless)');
    LEGEND_RATES(:,15) = strpad('d/dt R_tos_other in component Itos_R_gate (dimensionless)');
    LEGEND_RATES(:,17) = strpad('d/dt X_tof in component Itof_X_gate (dimensionless)');
    LEGEND_RATES(:,16) = strpad('d/dt Y_tof in component Itof_Y_gate (dimensionless)');
    LEGEND_RATES(:,18) = strpad('d/dt d in component ICaL_d_gate (dimensionless)');
    LEGEND_RATES(:,19) = strpad('d/dt f in component ICaL_f_gate (dimensionless)');
    LEGEND_RATES(:,20) = strpad('d/dt fCaB_SL in component ICaL_fCa_gate (dimensionless)');
    LEGEND_RATES(:,21) = strpad('d/dt fCaB_jct in component ICaL_fCa_gate (dimensionless)');
    LEGEND_RATES(:,22) = strpad('d/dt R in component Jrel_SR (dimensionless)');
    LEGEND_RATES(:,24) = strpad('d/dt O in component Jrel_SR (dimensionless)');
    LEGEND_RATES(:,23) = strpad('d/dt I in component Jrel_SR (dimensionless)');
    LEGEND_RATES(:,27) = strpad('d/dt Na_jct_buf in component Na_buffer (millimolar)');
    LEGEND_RATES(:,26) = strpad('d/dt Na_SL_buf in component Na_buffer (millimolar)');
    LEGEND_RATES(:,3) = strpad('d/dt Na_jct in component Na_buffer (millimolar)');
    LEGEND_RATES(:,4) = strpad('d/dt Na_SL in component Na_buffer (millimolar)');
    LEGEND_RATES(:,2) = strpad('d/dt Nai in component Na_buffer (millimolar)');
    LEGEND_RATES(:,32) = strpad('d/dt Ca_Calsequestrin in component Ca_buffer (millimolar)');
    LEGEND_RATES(:,28) = strpad('d/dt Ca_SLB_SL in component Ca_buffer (millimolar)');
    LEGEND_RATES(:,29) = strpad('d/dt Ca_SLB_jct in component Ca_buffer (millimolar)');
    LEGEND_RATES(:,30) = strpad('d/dt Ca_SLHigh_SL in component Ca_buffer (millimolar)');
    LEGEND_RATES(:,31) = strpad('d/dt Ca_SLHigh_jct in component Ca_buffer (millimolar)');
    LEGEND_RATES(:,25) = strpad('d/dt Ca_SR in component Ca_buffer (millimolar)');
    LEGEND_RATES(:,6) = strpad('d/dt Ca_jct in component Ca_buffer (millimolar)');
    LEGEND_RATES(:,7) = strpad('d/dt Ca_SL in component Ca_buffer (millimolar)');
    LEGEND_RATES(:,5) = strpad('d/dt Cai in component Ca_buffer (millimolar)');
    LEGEND_RATES(:,33) = strpad('d/dt Ca_TroponinC in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_RATES(:,34) = strpad('d/dt Ca_TroponinC_Ca_Mg in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_RATES(:,35) = strpad('d/dt Mg_TroponinC_Ca_Mg in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_RATES(:,36) = strpad('d/dt Ca_Calmodulin in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_RATES(:,37) = strpad('d/dt Ca_Myosin in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_RATES(:,38) = strpad('d/dt Mg_Myosin in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_RATES(:,39) = strpad('d/dt Ca_SRB in component cytosolic_Ca_buffer (millimolar)');
    LEGEND_RATES(:,40) = strpad('d/dt Ca_Indo1_Cytosol in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_RATES(:,41) = strpad('d/dt Ca_Indo1_SL in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_RATES(:,42) = strpad('d/dt Ca_Indo1_jct in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_RATES(:,43) = strpad('d/dt Ca_Fluo3_Cytosol in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_RATES(:,44) = strpad('d/dt Ca_Fluo3_SL in component indo_fluo_Ca_buffer_not_connected (millimolar)');
    LEGEND_RATES(:,45) = strpad('d/dt Ca_Fluo3_jct in component indo_fluo_Ca_buffer_not_connected (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) = -85.719687955637;
    CONSTANTS(:,1) = 100;
    CONSTANTS(:,2) = 1000;
    CONSTANTS(:,3) = 5;
    CONSTANTS(:,4) = 9.5;
    CONSTANTS(:,5) = 5.4;
    CONSTANTS(:,6) = 140;
    CONSTANTS(:,7) = 1.8;
    CONSTANTS(:,8) = 150;
    CONSTANTS(:,9) = 135;
    CONSTANTS(:,10) = 1;
    CONSTANTS(:,11) = 1;
    CONSTANTS(:,12) = 15;
    CONSTANTS(:,13) = 8314.3;
    CONSTANTS(:,14) = 310;
    CONSTANTS(:,15) = 96486.7;
    CONSTANTS(:,16) = 2e-6;
    CONSTANTS(:,17) = 100;
    CONSTANTS(:,18) = 10.25;
    CONSTANTS(:,19) = 0.16;
    CONSTANTS(:,20) = 0.015;
    CONSTANTS(:,21) = 0.045;
    STATES(:,2) = 8.874461106492;
    STATES(:,3) = 8.872823559072;
    STATES(:,4) = 8.874077316753;
    STATES(:,5) = 0.000087350002;
    STATES(:,6) = 0.000174843061;
    STATES(:,7) = 0.000106395937;
    CONSTANTS(:,22) = 16;
    CONSTANTS(:,23) = 0.11;
    CONSTANTS(:,24) = 0.89;
    STATES(:,8) = 0.001370685156;
    STATES(:,9) = 0.987140350343;
    STATES(:,10) = 0.991822731369;
    CONSTANTS(:,25) = 0.297e-3;
    CONSTANTS(:,26) = 0.11;
    CONSTANTS(:,27) = 0.89;
    CONSTANTS(:,28) = 1.63;
    CONSTANTS(:,29) = 4;
    CONSTANTS(:,30) = 1.49;
    CONSTANTS(:,31) = 11;
    CONSTANTS(:,32) = 1.5;
    CONSTANTS(:,33) = 1.91;
    CONSTANTS(:,34) = 0.11;
    CONSTANTS(:,35) = 0.89;
    STATES(:,11) = 0.008471550841;
    CONSTANTS(:,36) = 0.11;
    CONSTANTS(:,37) = 0.89;
    CONSTANTS(:,38) = 0.01833;
    STATES(:,12) = 0.00687399199;
    CONSTANTS(:,39) = 0.02;
    STATES(:,13) = 0.293519921626;
    STATES(:,14) = 0.004011272375;
    STATES(:,15) = 0.383430556383;
    CONSTANTS(:,40) = 0.06;
    STATES(:,16) = 0.9946314893;
    STATES(:,17) = 0.00401120993;
    CONSTANTS(:,41) = 0.001;
    CONSTANTS(:,42) = 0.109625;
    CONSTANTS(:,43) = 0.1;
    CONSTANTS(:,44) = 0.11;
    CONSTANTS(:,45) = 0.89;
    CONSTANTS(:,46) = 0.009;
    CONSTANTS(:,47) = 5.4e-4;
    CONSTANTS(:,48) = 1.5e-8;
    CONSTANTS(:,49) = 2.7e-7;
    CONSTANTS(:,50) = 0.9;
    CONSTANTS(:,51) = 0.1;
    CONSTANTS(:,52) = 0.341;
    CONSTANTS(:,53) = 0.341;
    CONSTANTS(:,54) = 0.75;
    CONSTANTS(:,55) = 0.75;
    CONSTANTS(:,56) = 0.75;
    CONSTANTS(:,57) = 0.75;
    CONSTANTS(:,58) = 1.8;
    STATES(:,18) = 0.000006997531;
    STATES(:,19) = 1.000675515962;
    STATES(:,20) = 0.015352888928;
    STATES(:,21) = 0.024609183734;
    CONSTANTS(:,59) = 9;
    CONSTANTS(:,60) = 0.11;
    CONSTANTS(:,61) = 0.89;
    CONSTANTS(:,62) = 1.57;
    CONSTANTS(:,63) = 12.29;
    CONSTANTS(:,64) = 1.3;
    CONSTANTS(:,65) = 87.5;
    CONSTANTS(:,66) = 0.00359;
    CONSTANTS(:,67) = 0.000256;
    CONSTANTS(:,68) = 0.27;
    CONSTANTS(:,69) = 0.35;
    CONSTANTS(:,70) = 3;
    CONSTANTS(:,71) = 2.2e-6;
    CONSTANTS(:,72) = 0.11;
    CONSTANTS(:,73) = 0.89;
    CONSTANTS(:,74) = 2.35;
    CONSTANTS(:,75) = 0.0005;
    CONSTANTS(:,76) = 1.6;
    CONSTANTS(:,77) = 0.0673;
    CONSTANTS(:,78) = 0.0002513;
    CONSTANTS(:,79) = 0.11;
    CONSTANTS(:,80) = 0.89;
    CONSTANTS(:,81) = 15;
    CONSTANTS(:,82) = 1;
    CONSTANTS(:,83) = 0.45;
    STATES(:,22) = 0.884673513138;
    STATES(:,23) = 0.00000009272;
    STATES(:,24) = 0.000000711264;
    CONSTANTS(:,84) = 25;
    CONSTANTS(:,85) = 10;
    CONSTANTS(:,86) = 0.06;
    CONSTANTS(:,87) = 0.5;
    CONSTANTS(:,88) = 0.005;
    CONSTANTS(:,89) = 2.5;
    STATES(:,25) = 0.545611267699;
    CONSTANTS(:,90) = 5.348e-6;
    CONSTANTS(:,91) = 286e-6;
    CONSTANTS(:,92) = 2.6;
    CONSTANTS(:,93) = 0.000246;
    CONSTANTS(:,94) = 1.7;
    CONSTANTS(:,95) = 1.787;
    CONSTANTS(:,96) = 1.64e-6;
    CONSTANTS(:,97) = 1.22e-6;
    CONSTANTS(:,98) = 1.09e-5;
    CONSTANTS(:,99) = 1.79e-5;
    CONSTANTS(:,100) = 0.5;
    CONSTANTS(:,101) = 0.45;
    CONSTANTS(:,102) = 3.01e-6;
    CONSTANTS(:,103) = 1.3e-4;
    STATES(:,26) = 0.776121392467;
    STATES(:,27) = 3.557055389701;
    CONSTANTS(:,104) = 1.65;
    CONSTANTS(:,105) = 3.7;
    CONSTANTS(:,106) = 0.0001;
    CONSTANTS(:,107) = 1e-3;
    STATES(:,28) = 0.009868629147;
    STATES(:,29) = 0.007780801995;
    STATES(:,30) = 0.114438990328;
    STATES(:,31) = 0.077503874257;
    STATES(:,32) = 1.186496899338;
    CONSTANTS(:,108) = 0.0374;
    CONSTANTS(:,109) = 0.0046;
    CONSTANTS(:,110) = 0.0134;
    CONSTANTS(:,111) = 0.00165;
    CONSTANTS(:,112) = 0.14;
    CONSTANTS(:,113) = 100;
    CONSTANTS(:,114) = 100;
    CONSTANTS(:,115) = 1.3;
    CONSTANTS(:,116) = 30e-3;
    CONSTANTS(:,117) = 65;
    STATES(:,33) = 0.008963736337;
    STATES(:,34) = 0.117995194438;
    STATES(:,35) = 0.010337654274;
    STATES(:,36) = 0.000295961245;
    STATES(:,37) = 0.001984672275;
    STATES(:,38) = 0.137497736234;
    STATES(:,39) = 0.002177112381;
    CONSTANTS(:,118) = 0.07;
    CONSTANTS(:,119) = 0.14;
    CONSTANTS(:,120) = 0.14;
    CONSTANTS(:,121) = 0.024;
    CONSTANTS(:,122) = 0.14;
    CONSTANTS(:,123) = 0.14;
    CONSTANTS(:,124) = 0.019;
    CONSTANTS(:,125) = 32.7;
    CONSTANTS(:,126) = 2.37;
    CONSTANTS(:,127) = 3e-3;
    CONSTANTS(:,128) = 34;
    CONSTANTS(:,129) = 13.8;
    CONSTANTS(:,130) = 15.7e-3;
    CONSTANTS(:,131) = 100;
    CONSTANTS(:,132) = 19.6e-3;
    CONSTANTS(:,133) = 0.032e-3;
    CONSTANTS(:,134) = 3.33e-3;
    CONSTANTS(:,135) = 238e-3;
    CONSTANTS(:,136) = 0.46e-3;
    CONSTANTS(:,137) = 0.057e-3;
    CONSTANTS(:,138) = 60e-3;
    CONSTANTS(:,139) = 0;
    CONSTANTS(:,140) = 0;
    STATES(:,40) = 0;
    STATES(:,41) = 0;
    STATES(:,42) = 0;
    STATES(:,43) = 0;
    STATES(:,44) = 0;
    STATES(:,45) = 0;
    CONSTANTS(:,141) = 0.025;
    CONSTANTS(:,142) = 0.00077;
    CONSTANTS(:,143) = 0.00002;
    CONSTANTS(:,144) = 0.025;
    CONSTANTS(:,145) = 0.00077;
    CONSTANTS(:,146) = 0.00002;
    CONSTANTS(:,147) = 100;
    CONSTANTS(:,148) = 100;
    CONSTANTS(:,149) = 60e-3;
    CONSTANTS(:,150) = 110e-3;
    CONSTANTS(:,151) =  (( CONSTANTS(:,13).*CONSTANTS(:,14))./CONSTANTS(:,15)).*log(CONSTANTS(:,5)./CONSTANTS(:,9));
    CONSTANTS(:,152) =  ((  - CONSTANTS(:,13).*CONSTANTS(:,14))./CONSTANTS(:,15)).*log(CONSTANTS(:,8)./CONSTANTS(:,12));
    CONSTANTS(:,153) = power(CONSTANTS(:,28), (CONSTANTS(:,14) - 310.000)./10.0000);
    CONSTANTS(:,154) = power(CONSTANTS(:,30), (CONSTANTS(:,14) - 310.000)./10.0000);
    CONSTANTS(:,155) = (exp(CONSTANTS(:,6)./67.3000) - 1.00000)./7.00000;
    CONSTANTS(:,156) =  0.0300000.*power((CONSTANTS(:,5)./5.40000), 1.0 ./ 2);
    CONSTANTS(:,157) =  0.900000.*power((CONSTANTS(:,5)./5.40000), 1.0 ./ 2);
    CONSTANTS(:,158) = power(CONSTANTS(:,58), (CONSTANTS(:,14) - 310.000)./10.0000);
    CONSTANTS(:,159) = power(CONSTANTS(:,62), (CONSTANTS(:,14) - 310.000)./10.0000);
    CONSTANTS(:,160) = power(CONSTANTS(:,74), (CONSTANTS(:,14) - 310.000)./10.0000);
    CONSTANTS(:,161) = power(CONSTANTS(:,92), (CONSTANTS(:,14) - 310.000)./10.0000);
    CONSTANTS(:,162) = ( CONSTANTS(:,98).*CONSTANTS(:,102))./CONSTANTS(:,100);
    CONSTANTS(:,163) = ( CONSTANTS(:,99).*CONSTANTS(:,103))./CONSTANTS(:,101);
    CONSTANTS(:,164) = ( CONSTANTS(:,96).*CONSTANTS(:,102))./CONSTANTS(:,100);
    CONSTANTS(:,165) = ( CONSTANTS(:,97).*CONSTANTS(:,103))./CONSTANTS(:,101);
    CONSTANTS(:,166) = 1.83130e-14;
    CONSTANTS(:,167) = 1.63860e-12;
    CONSTANTS(:,168) = 8.24130e-13;
    CONSTANTS(:,169) = 3.72430e-12;
    CONSTANTS(:,170) = ( (( CONSTANTS(:,16).*2.00000.*CONSTANTS(:,18))./10000.0).* pi.*CONSTANTS(:,17))./10000.0;
    CONSTANTS(:,171) = ( 3.14159.*power(CONSTANTS(:,18)./1000.00, 2.00000).*CONSTANTS(:,17))./power(1000.00, 3.00000);
    CONSTANTS(:,172) =  0.0350000.*CONSTANTS(:,171);
    CONSTANTS(:,173) =  0.0200000.*CONSTANTS(:,171);
    CONSTANTS(:,174) =  0.000510000.*CONSTANTS(:,171);
    CONSTANTS(:,175) =  0.650000.*CONSTANTS(:,171);
    CONSTANTS(:,176) = CONSTANTS(:,171) - (CONSTANTS(:,172)+CONSTANTS(:,173)+CONSTANTS(:,174)+CONSTANTS(:,175));
    CONSTANTS(:,177) = ( CONSTANTS(:,71).*CONSTANTS(:,175).*2.00000.*CONSTANTS(:,15))./CONSTANTS(:,170);
    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(:,20) =  1.70000.*STATES(:,7).*(1.00000 - STATES(:,20)) -  11.9000.*STATES(:,20);
    RATES(:,21) =  1.70000.*STATES(:,6).*(1.00000 - STATES(:,21)) -  11.9000.*STATES(:,21);
    ALGEBRAIC(:,4) = 1.00000./(1.00000+exp( - (50.0000+STATES(:,1))./7.50000));
    ALGEBRAIC(:,21) = 1.00000./(( 0.00138000.*(STATES(:,1)+7.00000))./(1.00000 - exp(  - 0.123000.*(STATES(:,1)+7.00000)))+( 0.000610000.*(STATES(:,1)+10.0000))./(exp( 0.145000.*(STATES(:,1)+10.0000)) - 1.00000));
    RATES(:,11) = (ALGEBRAIC(:,4) - STATES(:,11))./ALGEBRAIC(:,21);
    ALGEBRAIC(:,8) = 1.00000./(1.00000+exp( - (STATES(:,1) - 1.50000)./16.7000));
    ALGEBRAIC(:,23) = 1.00000./(( 7.19000e-05.*(STATES(:,1)+30.0000))./(1.00000 - exp(  - 0.148000.*(STATES(:,1)+30.0000)))+( 0.000131000.*(STATES(:,1)+30.0000))./( - 1.00000+exp( 0.0687000.*(STATES(:,1)+30.0000))));
    RATES(:,12) = (ALGEBRAIC(:,8) - STATES(:,12))./ALGEBRAIC(:,23);
    ALGEBRAIC(:,9) = 1.00000./(1.00000+exp( - (STATES(:,1)+3.00000)./15.0000));
    ALGEBRAIC(:,24) = 9.00000./(1.00000+exp((STATES(:,1)+3.00000)./15.0000))+0.500000;
    RATES(:,14) = (ALGEBRAIC(:,9) - STATES(:,14))./ALGEBRAIC(:,24);
    ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,1)+33.5000)./10.0000));
    ALGEBRAIC(:,25) = 3000.00./(1.00000+exp((STATES(:,1)+60.0000)./10.0000))+30.0000;
    RATES(:,13) = (ALGEBRAIC(:,10) - STATES(:,13))./ALGEBRAIC(:,25);
    ALGEBRAIC(:,11) = 1.00000./(1.00000+exp( - (STATES(:,1)+3.00000)./15.0000));
    ALGEBRAIC(:,26) =  3.50000.*exp( - power(STATES(:,1)./30.0000, 2.00000))+1.50000;
    RATES(:,17) = (ALGEBRAIC(:,11) - STATES(:,17))./ALGEBRAIC(:,26);
    ALGEBRAIC(:,12) = 1.00000./(1.00000+exp((STATES(:,1)+33.5000)./10.0000));
    ALGEBRAIC(:,27) = 20.0000./(1.00000+exp((STATES(:,1)+33.5000)./10.0000))+20.0000;
    RATES(:,16) = (ALGEBRAIC(:,12) - STATES(:,16))./ALGEBRAIC(:,27);
    ALGEBRAIC(:,13) = 1.00000./(1.00000+exp( - (STATES(:,1)+14.5000)./6.00000));
    ALGEBRAIC(:,28) = ( 1.00000.*ALGEBRAIC(:,13).*(1.00000 - exp( - (STATES(:,1)+14.5000)./6.00000)))./( 0.0350000.*(STATES(:,1)+14.5000));
    RATES(:,18) = (ALGEBRAIC(:,13) - STATES(:,18))./ALGEBRAIC(:,28);
    ALGEBRAIC(:,14) = 1.00000./(1.00000+exp((STATES(:,1)+35.0600)./3.60000))+0.600000./(1.00000+exp((50.0000 - STATES(:,1))./20.0000));
    ALGEBRAIC(:,29) = 1.00000./( 0.0197000.*exp( - power( 0.0337000.*(STATES(:,1)+14.5000), 2.00000))+0.0200000);
    RATES(:,19) = (ALGEBRAIC(:,14) - STATES(:,19))./ALGEBRAIC(:,29);
    ALGEBRAIC(:,16) = STATES(:,40)+( STATES(:,42).*CONSTANTS(:,174))./CONSTANTS(:,175)+( STATES(:,41).*CONSTANTS(:,173))./CONSTANTS(:,175);
    ALGEBRAIC(:,31) =  CONSTANTS(:,147).*(CONSTANTS(:,139) - ALGEBRAIC(:,16)).*STATES(:,5).*(CONSTANTS(:,141) - STATES(:,40)) -  CONSTANTS(:,149).*STATES(:,40);
    RATES(:,40) = ALGEBRAIC(:,31);
    ALGEBRAIC(:,33) =  CONSTANTS(:,147).*(CONSTANTS(:,139) - ALGEBRAIC(:,16)).*STATES(:,7).*(( CONSTANTS(:,142).*CONSTANTS(:,175))./CONSTANTS(:,173) - STATES(:,41)) -  CONSTANTS(:,149).*STATES(:,41);
    RATES(:,41) = ALGEBRAIC(:,33);
    ALGEBRAIC(:,32) =  CONSTANTS(:,147).*(CONSTANTS(:,139) - ALGEBRAIC(:,16)).*STATES(:,6).*(( CONSTANTS(:,143).*CONSTANTS(:,175))./CONSTANTS(:,174) - STATES(:,42)) -  CONSTANTS(:,149).*STATES(:,42);
    RATES(:,42) = ALGEBRAIC(:,32);
    ALGEBRAIC(:,17) = STATES(:,43)+( STATES(:,45).*CONSTANTS(:,174))./CONSTANTS(:,175)+( STATES(:,44).*CONSTANTS(:,173))./CONSTANTS(:,175);
    ALGEBRAIC(:,34) =  CONSTANTS(:,148).*(CONSTANTS(:,140) - ALGEBRAIC(:,17)).*STATES(:,5).*(CONSTANTS(:,144) - STATES(:,43)) -  CONSTANTS(:,150).*STATES(:,43);
    RATES(:,43) = ALGEBRAIC(:,34);
    ALGEBRAIC(:,36) =  CONSTANTS(:,148).*(CONSTANTS(:,140) - ALGEBRAIC(:,17)).*STATES(:,7).*(( CONSTANTS(:,145).*CONSTANTS(:,175))./CONSTANTS(:,173) - STATES(:,44)) -  CONSTANTS(:,150).*STATES(:,44);
    RATES(:,44) = ALGEBRAIC(:,36);
    ALGEBRAIC(:,35) =  CONSTANTS(:,148).*(CONSTANTS(:,140) - ALGEBRAIC(:,17)).*STATES(:,6).*(( CONSTANTS(:,146).*CONSTANTS(:,175))./CONSTANTS(:,174) - STATES(:,45)) -  CONSTANTS(:,150).*STATES(:,45);
    RATES(:,45) = ALGEBRAIC(:,35);
    ALGEBRAIC(:,15) = CONSTANTS(:,81) - (CONSTANTS(:,81) - CONSTANTS(:,82))./(1.00000+power(CONSTANTS(:,83)./STATES(:,25), CONSTANTS(:,89)));
    ALGEBRAIC(:,30) = CONSTANTS(:,85)./ALGEBRAIC(:,15);
    ALGEBRAIC(:,41) =  CONSTANTS(:,87).*ALGEBRAIC(:,15);
    RATES(:,24) = ( ALGEBRAIC(:,30).*power(STATES(:,6), 2.00000).*STATES(:,22) -  CONSTANTS(:,86).*STATES(:,24)) - ( ALGEBRAIC(:,41).*STATES(:,6).*STATES(:,24) -  CONSTANTS(:,88).*STATES(:,23));
    ALGEBRAIC(:,1) = piecewise({STATES(:,1)< - 40.0000,  0.135000.*exp((80.0000+STATES(:,1))./ - 6.80000) }, 0.00000);
    ALGEBRAIC(:,18) = piecewise({STATES(:,1)< - 40.0000,  3.56000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.350000.*STATES(:,1)) }, 1.00000./( 0.130000.*(1.00000+exp((STATES(:,1)+10.6600)./ - 11.1000))));
    ALGEBRAIC(:,37) = 1.00000./(ALGEBRAIC(:,1)+ALGEBRAIC(:,18));
    ALGEBRAIC(:,42) = ALGEBRAIC(:,1)./(ALGEBRAIC(:,1)+ALGEBRAIC(:,18));
    RATES(:,9) = (ALGEBRAIC(:,42) - STATES(:,9))./ALGEBRAIC(:,37);
    ALGEBRAIC(:,2) = piecewise({STATES(:,1)< - 40.0000, (( (  - 127140..*exp( 0.244400.*STATES(:,1)) -  3.47400e-05.*exp(  - 0.0439100.*STATES(:,1))).*(STATES(:,1)+37.7800))./1.00000)./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300))) }, 0.00000);
    ALGEBRAIC(:,19) = piecewise({STATES(:,1)< - 40.0000, ( 0.121200.*exp(  - 0.0105200.*STATES(:,1)))./(1.00000+exp(  - 0.137800.*(STATES(:,1)+40.1400))) }, ( 0.300000.*exp(  - 2.53500e-07.*STATES(:,1)))./(1.00000+exp(  - 0.100000.*(STATES(:,1)+32.0000))));
    ALGEBRAIC(:,38) = 1.00000./(ALGEBRAIC(:,2)+ALGEBRAIC(:,19));
    ALGEBRAIC(:,43) = ALGEBRAIC(:,2)./(ALGEBRAIC(:,2)+ALGEBRAIC(:,19));
    RATES(:,10) = (ALGEBRAIC(:,43) - STATES(:,10))./ALGEBRAIC(:,38);
    ALGEBRAIC(:,3) = (( 0.320000.*(STATES(:,1)+47.1300))./1.00000)./(1.00000 - exp(  - 0.100000.*(STATES(:,1)+47.1300)));
    ALGEBRAIC(:,20) =  0.0800000.*exp( - STATES(:,1)./11.0000);
    ALGEBRAIC(:,39) = 1.00000./(ALGEBRAIC(:,3)+ALGEBRAIC(:,20));
    ALGEBRAIC(:,44) = ALGEBRAIC(:,3)./(ALGEBRAIC(:,3)+ALGEBRAIC(:,20));
    RATES(:,8) = (ALGEBRAIC(:,44) - STATES(:,8))./ALGEBRAIC(:,39);
    ALGEBRAIC(:,46) = ((1.00000 - STATES(:,22)) - STATES(:,24)) - STATES(:,23);
    RATES(:,22) = ( CONSTANTS(:,88).*ALGEBRAIC(:,46) -  ALGEBRAIC(:,41).*STATES(:,6).*STATES(:,22)) - ( ALGEBRAIC(:,30).*power(STATES(:,6), 2.00000).*STATES(:,22) -  CONSTANTS(:,86).*STATES(:,24));
    RATES(:,23) = ( ALGEBRAIC(:,41).*STATES(:,6).*STATES(:,24) -  CONSTANTS(:,88).*STATES(:,23)) - ( CONSTANTS(:,86).*STATES(:,23) -  ALGEBRAIC(:,30).*power(STATES(:,6), 2.00000).*ALGEBRAIC(:,46));
    ALGEBRAIC(:,69) = 1.00000./(1.00000+exp((STATES(:,1)+33.5000)./10.0000));
    ALGEBRAIC(:,71) = ALGEBRAIC(:,69);
    ALGEBRAIC(:,70) = 2800.00./(1.00000+exp((STATES(:,1)+60.0000)./10.0000))+220.000;
    RATES(:,15) = (ALGEBRAIC(:,69) - ALGEBRAIC(:,71))./ALGEBRAIC(:,70);
    ALGEBRAIC(:,98) =  CONSTANTS(:,106).*STATES(:,3).*(CONSTANTS(:,105) - STATES(:,27)) -  CONSTANTS(:,107).*STATES(:,27);
    RATES(:,27) = ALGEBRAIC(:,98);
    ALGEBRAIC(:,22) =  (( CONSTANTS(:,13).*CONSTANTS(:,14))./CONSTANTS(:,15)).*log(CONSTANTS(:,6)./STATES(:,3));
    ALGEBRAIC(:,48) =  power(STATES(:,8), 3.00000).*STATES(:,9).*STATES(:,10);
    ALGEBRAIC(:,49) =  CONSTANTS(:,23).*CONSTANTS(:,22).*ALGEBRAIC(:,48).*(STATES(:,1) - ALGEBRAIC(:,22));
    ALGEBRAIC(:,52) =  CONSTANTS(:,26).*CONSTANTS(:,25).*(STATES(:,1) - ALGEBRAIC(:,22));
    ALGEBRAIC(:,55) = 1.00000./(1.00000+ 0.124500.*exp((  - 0.100000.*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14)))+ 0.0365000.*CONSTANTS(:,155).*exp((  - STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))));
    ALGEBRAIC(:,56) = ( (( CONSTANTS(:,34).*CONSTANTS(:,153).*CONSTANTS(:,33).*ALGEBRAIC(:,55))./(1.00000+power(( CONSTANTS(:,154).*CONSTANTS(:,31))./STATES(:,3), CONSTANTS(:,29)))).*CONSTANTS(:,5))./(CONSTANTS(:,5)+CONSTANTS(:,32));
    ALGEBRAIC(:,85) = 1.00000 - STATES(:,21);
    ALGEBRAIC(:,81) = ( STATES(:,18).*STATES(:,19).*CONSTANTS(:,158).*STATES(:,1).*power(CONSTANTS(:,15), 2.00000))./( CONSTANTS(:,13).*CONSTANTS(:,14));
    ALGEBRAIC(:,87) = ( ALGEBRAIC(:,81).*ALGEBRAIC(:,85).*CONSTANTS(:,50).*CONSTANTS(:,48).*( CONSTANTS(:,54).*STATES(:,3).*exp(( STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) -  CONSTANTS(:,55).*CONSTANTS(:,6)))./(exp(( STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) - 1.00000);
    ALGEBRAIC(:,93) = 1.00000./(1.00000+power(CONSTANTS(:,67)./STATES(:,6), 3.00000));
    ALGEBRAIC(:,90) = ( exp(( CONSTANTS(:,69).*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))).*power(STATES(:,3), CONSTANTS(:,70)).*CONSTANTS(:,7) -  exp(( (CONSTANTS(:,69) - 1.00000).*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))).*power(CONSTANTS(:,6), CONSTANTS(:,70)).*STATES(:,6))./(1.00000+ CONSTANTS(:,68).*exp(( (CONSTANTS(:,69) - 1.00000).*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))));
    ALGEBRAIC(:,94) = ( CONSTANTS(:,60).*CONSTANTS(:,59).*ALGEBRAIC(:,93).*CONSTANTS(:,159).*ALGEBRAIC(:,90))./( CONSTANTS(:,66).*power(CONSTANTS(:,6), CONSTANTS(:,70)).*(1.00000+power(STATES(:,3)./CONSTANTS(:,63), CONSTANTS(:,70)))+ power(CONSTANTS(:,65), CONSTANTS(:,70)).*STATES(:,6).*(1.00000+STATES(:,6)./CONSTANTS(:,66))+ CONSTANTS(:,64).*power(STATES(:,3), CONSTANTS(:,70))+ power(STATES(:,3), CONSTANTS(:,70)).*CONSTANTS(:,7)+ power(CONSTANTS(:,6), CONSTANTS(:,70)).*STATES(:,6));
    ALGEBRAIC(:,96) =  (STATES(:,3) - STATES(:,4)).*CONSTANTS(:,162);
    RATES(:,3) = ((  - CONSTANTS(:,170).*(ALGEBRAIC(:,49)+ 3.00000.*ALGEBRAIC(:,94)+ALGEBRAIC(:,52)+ 3.00000.*ALGEBRAIC(:,56)+ALGEBRAIC(:,87)))./( CONSTANTS(:,174).*CONSTANTS(:,15)) - ALGEBRAIC(:,96)./CONSTANTS(:,174)) - ALGEBRAIC(:,98);
    ALGEBRAIC(:,99) =  (STATES(:,4) - STATES(:,2)).*CONSTANTS(:,163);
    RATES(:,2) = ALGEBRAIC(:,99)./CONSTANTS(:,175);
    ALGEBRAIC(:,101) =  CONSTANTS(:,106).*STATES(:,4).*(CONSTANTS(:,104) - STATES(:,26)) -  CONSTANTS(:,107).*STATES(:,26);
    RATES(:,26) = ALGEBRAIC(:,101);
    ALGEBRAIC(:,40) =  (( CONSTANTS(:,13).*CONSTANTS(:,14))./CONSTANTS(:,15)).*log(CONSTANTS(:,6)./STATES(:,4));
    ALGEBRAIC(:,50) =  CONSTANTS(:,24).*CONSTANTS(:,22).*ALGEBRAIC(:,48).*(STATES(:,1) - ALGEBRAIC(:,40));
    ALGEBRAIC(:,53) =  CONSTANTS(:,27).*CONSTANTS(:,25).*(STATES(:,1) - ALGEBRAIC(:,40));
    ALGEBRAIC(:,57) = ( (( CONSTANTS(:,35).*CONSTANTS(:,153).*CONSTANTS(:,33).*ALGEBRAIC(:,55))./(1.00000+power(( CONSTANTS(:,154).*CONSTANTS(:,31))./STATES(:,4), CONSTANTS(:,29)))).*CONSTANTS(:,5))./(CONSTANTS(:,5)+CONSTANTS(:,32));
    ALGEBRAIC(:,82) = 1.00000 - STATES(:,20);
    ALGEBRAIC(:,84) = ( ALGEBRAIC(:,81).*ALGEBRAIC(:,82).*CONSTANTS(:,51).*CONSTANTS(:,48).*( CONSTANTS(:,54).*STATES(:,4).*exp(( STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) -  CONSTANTS(:,55).*CONSTANTS(:,6)))./(exp(( STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) - 1.00000);
    ALGEBRAIC(:,92) = 1.00000./(1.00000+power(CONSTANTS(:,67)./STATES(:,7), 3.00000));
    ALGEBRAIC(:,91) = ( exp(( CONSTANTS(:,69).*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))).*power(STATES(:,4), CONSTANTS(:,70)).*CONSTANTS(:,7) -  exp(( (CONSTANTS(:,69) - 1.00000).*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))).*power(CONSTANTS(:,6), CONSTANTS(:,70)).*STATES(:,7))./(1.00000+ CONSTANTS(:,68).*exp(( (CONSTANTS(:,69) - 1.00000).*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))));
    ALGEBRAIC(:,95) = ( CONSTANTS(:,61).*CONSTANTS(:,59).*ALGEBRAIC(:,92).*CONSTANTS(:,159).*ALGEBRAIC(:,91))./( CONSTANTS(:,66).*power(CONSTANTS(:,6), CONSTANTS(:,70)).*(1.00000+power(STATES(:,4)./CONSTANTS(:,63), CONSTANTS(:,70)))+ power(CONSTANTS(:,65), CONSTANTS(:,70)).*STATES(:,7).*(1.00000+STATES(:,7)./CONSTANTS(:,66))+ CONSTANTS(:,64).*power(STATES(:,4), CONSTANTS(:,70))+ power(STATES(:,4), CONSTANTS(:,70)).*CONSTANTS(:,7)+ power(CONSTANTS(:,6), CONSTANTS(:,70)).*STATES(:,7));
    RATES(:,4) = ((  - CONSTANTS(:,170).*(ALGEBRAIC(:,50)+ 3.00000.*ALGEBRAIC(:,95)+ALGEBRAIC(:,53)+ 3.00000.*ALGEBRAIC(:,57)+ALGEBRAIC(:,84)))./( CONSTANTS(:,173).*CONSTANTS(:,15))+(ALGEBRAIC(:,96) - ALGEBRAIC(:,99))./CONSTANTS(:,173)) - ALGEBRAIC(:,101);
    ALGEBRAIC(:,51) = ALGEBRAIC(:,49)+ALGEBRAIC(:,50);
    ALGEBRAIC(:,54) = ALGEBRAIC(:,52)+ALGEBRAIC(:,53);
    ALGEBRAIC(:,58) = ALGEBRAIC(:,56)+ALGEBRAIC(:,57);
    ALGEBRAIC(:,59) = 1.00000./(1.00000+exp((33.0000+STATES(:,1))./22.4000));
    ALGEBRAIC(:,60) =  CONSTANTS(:,156).*STATES(:,11).*ALGEBRAIC(:,59).*(STATES(:,1) - CONSTANTS(:,151));
    ALGEBRAIC(:,61) =  - arbitrary_log(STATES(:,6)./1.00000+3.00000, 10);
    ALGEBRAIC(:,63) =  0.0700000.*(0.0570000+0.190000./(1.00000+exp( - 7.20000+ALGEBRAIC(:,61)./0.600000)));
    ALGEBRAIC(:,65) =  (( CONSTANTS(:,13).*CONSTANTS(:,14))./CONSTANTS(:,15)).*log((CONSTANTS(:,5)+ CONSTANTS(:,38).*CONSTANTS(:,6))./(CONSTANTS(:,9)+ CONSTANTS(:,38).*STATES(:,2)));
    ALGEBRAIC(:,66) =  CONSTANTS(:,36).*ALGEBRAIC(:,63).*power(STATES(:,12), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,62) =  - arbitrary_log(STATES(:,7)./1.00000+3.00000, 10);
    ALGEBRAIC(:,64) =  0.0700000.*(0.0570000+0.190000./(1.00000+exp( - 7.20000+ALGEBRAIC(:,62)./0.600000)));
    ALGEBRAIC(:,67) =  CONSTANTS(:,37).*ALGEBRAIC(:,64).*power(STATES(:,12), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,68) = ALGEBRAIC(:,66)+ALGEBRAIC(:,67);
    ALGEBRAIC(:,72) =  CONSTANTS(:,39).*STATES(:,14).*(STATES(:,13)+ 0.500000.*ALGEBRAIC(:,71)).*(STATES(:,1) - CONSTANTS(:,151));
    ALGEBRAIC(:,73) =  CONSTANTS(:,40).*STATES(:,17).*STATES(:,16).*(STATES(:,1) - CONSTANTS(:,151));
    ALGEBRAIC(:,74) = 1.02000./(1.00000+exp( 0.238500.*(STATES(:,1) - (CONSTANTS(:,151)+59.2150))));
    ALGEBRAIC(:,75) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1) - CONSTANTS(:,151))+5.47600))+ 1.00000.*exp( 0.0617500.*(STATES(:,1) - (CONSTANTS(:,151)+594.310))))./(1.00000+exp(  - 0.514300.*((STATES(:,1) - CONSTANTS(:,151))+4.75300)));
    ALGEBRAIC(:,76) = ALGEBRAIC(:,74)./(ALGEBRAIC(:,74)+ALGEBRAIC(:,75));
    ALGEBRAIC(:,77) =  CONSTANTS(:,157).*ALGEBRAIC(:,76).*(STATES(:,1) - CONSTANTS(:,151));
    ALGEBRAIC(:,78) = ( CONSTANTS(:,41).*(STATES(:,1) - CONSTANTS(:,151)))./(1.00000+exp(7.48800 - STATES(:,1)./5.98000));
    ALGEBRAIC(:,97) = ALGEBRAIC(:,94)+ALGEBRAIC(:,95);
    ALGEBRAIC(:,79) =  CONSTANTS(:,42).*(STATES(:,1) - CONSTANTS(:,152)).*(CONSTANTS(:,44)./(1.00000+CONSTANTS(:,43)./STATES(:,6))+CONSTANTS(:,45)./(1.00000+CONSTANTS(:,43)./STATES(:,7)));
    ALGEBRAIC(:,80) =  CONSTANTS(:,46).*(STATES(:,1) - CONSTANTS(:,152));
    ALGEBRAIC(:,83) = ( ALGEBRAIC(:,81).*ALGEBRAIC(:,82).*CONSTANTS(:,51).*CONSTANTS(:,47).*4.00000.*( CONSTANTS(:,52).*STATES(:,7).*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) -  CONSTANTS(:,53).*CONSTANTS(:,7)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) - 1.00000);
    ALGEBRAIC(:,86) = ( ALGEBRAIC(:,81).*ALGEBRAIC(:,85).*CONSTANTS(:,50).*CONSTANTS(:,47).*4.00000.*( CONSTANTS(:,52).*STATES(:,6).*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) -  CONSTANTS(:,53).*CONSTANTS(:,7)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) - 1.00000);
    ALGEBRAIC(:,88) = ( ALGEBRAIC(:,81).*( ALGEBRAIC(:,82).*CONSTANTS(:,51)+ ALGEBRAIC(:,85).*CONSTANTS(:,50)).*CONSTANTS(:,49).*( CONSTANTS(:,56).*CONSTANTS(:,9).*exp(( STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) -  CONSTANTS(:,57).*CONSTANTS(:,5)))./(exp(( STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) - 1.00000);
    ALGEBRAIC(:,89) = ALGEBRAIC(:,83)+ALGEBRAIC(:,86)+ALGEBRAIC(:,84)+ALGEBRAIC(:,87)+ALGEBRAIC(:,88);
    ALGEBRAIC(:,45) =  (( CONSTANTS(:,13).*CONSTANTS(:,14))./( 2.00000.*CONSTANTS(:,15))).*log(CONSTANTS(:,7)./STATES(:,6));
    ALGEBRAIC(:,104) =  CONSTANTS(:,78).*CONSTANTS(:,79).*(STATES(:,1) - ALGEBRAIC(:,45));
    ALGEBRAIC(:,47) =  (( CONSTANTS(:,13).*CONSTANTS(:,14))./( 2.00000.*CONSTANTS(:,15))).*log(CONSTANTS(:,7)./STATES(:,7));
    ALGEBRAIC(:,105) =  CONSTANTS(:,78).*CONSTANTS(:,80).*(STATES(:,1) - ALGEBRAIC(:,47));
    ALGEBRAIC(:,106) = ALGEBRAIC(:,105)+ALGEBRAIC(:,104);
    ALGEBRAIC(:,102) = ( CONSTANTS(:,160).*CONSTANTS(:,77).*CONSTANTS(:,73))./(1.00000+power(CONSTANTS(:,75)./STATES(:,7), CONSTANTS(:,76)));
    ALGEBRAIC(:,100) = ( CONSTANTS(:,160).*CONSTANTS(:,77).*CONSTANTS(:,72))./(1.00000+power(CONSTANTS(:,75)./STATES(:,6), CONSTANTS(:,76)));
    ALGEBRAIC(:,103) = ALGEBRAIC(:,100)+ALGEBRAIC(:,102);
    ALGEBRAIC(:,7) = piecewise({VOI -  floor(VOI./CONSTANTS(:,2)).*CONSTANTS(:,2)>=CONSTANTS(:,1)&VOI -  floor(VOI./CONSTANTS(:,2)).*CONSTANTS(:,2)<=CONSTANTS(:,1)+CONSTANTS(:,3),  - CONSTANTS(:,4) }, 0.00000);
    RATES(:,1) =  - (ALGEBRAIC(:,51)+ALGEBRAIC(:,54)+ALGEBRAIC(:,58)+ALGEBRAIC(:,60)+ALGEBRAIC(:,68)+ALGEBRAIC(:,72)+ALGEBRAIC(:,73)+ALGEBRAIC(:,77)+ALGEBRAIC(:,78)+ALGEBRAIC(:,97)+ALGEBRAIC(:,79)+ALGEBRAIC(:,80)+ALGEBRAIC(:,89)+ALGEBRAIC(:,106)+ALGEBRAIC(:,103)+ALGEBRAIC(:,7));
    ALGEBRAIC(:,110) =  CONSTANTS(:,114).*STATES(:,25).*(( CONSTANTS(:,112).*CONSTANTS(:,175))./CONSTANTS(:,172) - STATES(:,32)) -  CONSTANTS(:,117).*STATES(:,32);
    RATES(:,32) = ALGEBRAIC(:,110);
    ALGEBRAIC(:,107) =  CONSTANTS(:,84).*STATES(:,24).*(STATES(:,25) - STATES(:,6));
    ALGEBRAIC(:,108) =  CONSTANTS(:,90).*(STATES(:,25) - STATES(:,6));
    ALGEBRAIC(:,109) = ( (( CONSTANTS(:,161).*CONSTANTS(:,91).*CONSTANTS(:,175))./CONSTANTS(:,172)).*(power(STATES(:,5)./CONSTANTS(:,93), CONSTANTS(:,95)) - power(STATES(:,25)./CONSTANTS(:,94), CONSTANTS(:,95))))./(1.00000+power(STATES(:,5)./CONSTANTS(:,93), CONSTANTS(:,95))+power(STATES(:,25)./CONSTANTS(:,94), CONSTANTS(:,95)));
    RATES(:,25) = (ALGEBRAIC(:,109) - (( ALGEBRAIC(:,108).*CONSTANTS(:,175))./CONSTANTS(:,172)+ALGEBRAIC(:,107))) - ALGEBRAIC(:,110);
    ALGEBRAIC(:,113) =  CONSTANTS(:,113).*STATES(:,6).*(( CONSTANTS(:,109).*CONSTANTS(:,175))./CONSTANTS(:,174) - STATES(:,29)) -  CONSTANTS(:,115).*STATES(:,29);
    RATES(:,29) = ALGEBRAIC(:,113);
    ALGEBRAIC(:,115) =  CONSTANTS(:,113).*STATES(:,7).*(( CONSTANTS(:,108).*CONSTANTS(:,175))./CONSTANTS(:,173) - STATES(:,28)) -  CONSTANTS(:,115).*STATES(:,28);
    RATES(:,28) = ALGEBRAIC(:,115);
    ALGEBRAIC(:,116) =  CONSTANTS(:,113).*STATES(:,6).*(( CONSTANTS(:,111).*CONSTANTS(:,175))./CONSTANTS(:,174) - STATES(:,31)) -  CONSTANTS(:,116).*STATES(:,31);
    RATES(:,31) = ALGEBRAIC(:,116);
    ALGEBRAIC(:,114) =  CONSTANTS(:,125).*STATES(:,5).*(CONSTANTS(:,118) - STATES(:,33)) -  CONSTANTS(:,132).*STATES(:,33);
    RATES(:,33) = ALGEBRAIC(:,114);
    ALGEBRAIC(:,118) =  CONSTANTS(:,113).*STATES(:,7).*(( CONSTANTS(:,110).*CONSTANTS(:,175))./CONSTANTS(:,173) - STATES(:,30)) -  CONSTANTS(:,116).*STATES(:,30);
    RATES(:,30) = ALGEBRAIC(:,118);
    ALGEBRAIC(:,117) =  CONSTANTS(:,126).*STATES(:,5).*(CONSTANTS(:,119) - (STATES(:,34)+STATES(:,35))) -  CONSTANTS(:,133).*STATES(:,34);
    RATES(:,34) = ALGEBRAIC(:,117);
    ALGEBRAIC(:,111) =  (STATES(:,6) - STATES(:,7)).*CONSTANTS(:,164);
    ALGEBRAIC(:,119) = ALGEBRAIC(:,113)+ALGEBRAIC(:,116);
    ALGEBRAIC(:,121) = (ALGEBRAIC(:,86) -  2.00000.*ALGEBRAIC(:,94))+ALGEBRAIC(:,104)+ALGEBRAIC(:,100);
    RATES(:,6) = (((  - ALGEBRAIC(:,121).*CONSTANTS(:,170))./( CONSTANTS(:,174).*2.00000.*CONSTANTS(:,15)) - ALGEBRAIC(:,111)./CONSTANTS(:,174))+( ALGEBRAIC(:,107).*CONSTANTS(:,172))./CONSTANTS(:,174)+( ALGEBRAIC(:,108).*CONSTANTS(:,175))./CONSTANTS(:,174)) -  1.00000.*ALGEBRAIC(:,119);
    ALGEBRAIC(:,120) =  CONSTANTS(:,127).*CONSTANTS(:,10).*(CONSTANTS(:,120) - (STATES(:,34)+STATES(:,35))) -  CONSTANTS(:,134).*STATES(:,35);
    RATES(:,35) = ALGEBRAIC(:,120);
    ALGEBRAIC(:,112) =  (STATES(:,7) - STATES(:,5)).*CONSTANTS(:,165);
    ALGEBRAIC(:,122) = ALGEBRAIC(:,115)+ALGEBRAIC(:,118);
    ALGEBRAIC(:,124) = (ALGEBRAIC(:,83) -  2.00000.*ALGEBRAIC(:,95))+ALGEBRAIC(:,105)+ALGEBRAIC(:,102);
    RATES(:,7) = ((  - ALGEBRAIC(:,124).*CONSTANTS(:,170))./( CONSTANTS(:,173).*2.00000.*CONSTANTS(:,15))+(ALGEBRAIC(:,111) - ALGEBRAIC(:,112))./CONSTANTS(:,173)) -  1.00000.*ALGEBRAIC(:,122);
    ALGEBRAIC(:,123) =  CONSTANTS(:,128).*STATES(:,5).*(CONSTANTS(:,121) - STATES(:,36)) -  CONSTANTS(:,135).*STATES(:,36);
    RATES(:,36) = ALGEBRAIC(:,123);
    ALGEBRAIC(:,125) =  CONSTANTS(:,129).*STATES(:,5).*(CONSTANTS(:,122) - (STATES(:,37)+STATES(:,38))) -  CONSTANTS(:,136).*STATES(:,37);
    RATES(:,37) = ALGEBRAIC(:,125);
    ALGEBRAIC(:,126) =  CONSTANTS(:,130).*CONSTANTS(:,10).*(CONSTANTS(:,123) - (STATES(:,37)+STATES(:,38))) -  CONSTANTS(:,137).*STATES(:,38);
    RATES(:,38) = ALGEBRAIC(:,126);
    ALGEBRAIC(:,127) =  CONSTANTS(:,131).*STATES(:,5).*(CONSTANTS(:,124) - STATES(:,39)) -  CONSTANTS(:,138).*STATES(:,39);
    RATES(:,39) = ALGEBRAIC(:,127);
    ALGEBRAIC(:,128) = ALGEBRAIC(:,114)+ALGEBRAIC(:,117)+ALGEBRAIC(:,120)+ALGEBRAIC(:,123)+ALGEBRAIC(:,125)+ALGEBRAIC(:,126)+ALGEBRAIC(:,127);
    RATES(:,5) = ((  - ALGEBRAIC(:,109).*CONSTANTS(:,172))./CONSTANTS(:,175)+ALGEBRAIC(:,112)./CONSTANTS(:,175)) -  1.00000.*ALGEBRAIC(:,128);
   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) = 1.00000./(1.00000+exp( - (50.0000+STATES(:,1))./7.50000));
    ALGEBRAIC(:,21) = 1.00000./(( 0.00138000.*(STATES(:,1)+7.00000))./(1.00000 - exp(  - 0.123000.*(STATES(:,1)+7.00000)))+( 0.000610000.*(STATES(:,1)+10.0000))./(exp( 0.145000.*(STATES(:,1)+10.0000)) - 1.00000));
    ALGEBRAIC(:,8) = 1.00000./(1.00000+exp( - (STATES(:,1) - 1.50000)./16.7000));
    ALGEBRAIC(:,23) = 1.00000./(( 7.19000e-05.*(STATES(:,1)+30.0000))./(1.00000 - exp(  - 0.148000.*(STATES(:,1)+30.0000)))+( 0.000131000.*(STATES(:,1)+30.0000))./( - 1.00000+exp( 0.0687000.*(STATES(:,1)+30.0000))));
    ALGEBRAIC(:,9) = 1.00000./(1.00000+exp( - (STATES(:,1)+3.00000)./15.0000));
    ALGEBRAIC(:,24) = 9.00000./(1.00000+exp((STATES(:,1)+3.00000)./15.0000))+0.500000;
    ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,1)+33.5000)./10.0000));
    ALGEBRAIC(:,25) = 3000.00./(1.00000+exp((STATES(:,1)+60.0000)./10.0000))+30.0000;
    ALGEBRAIC(:,11) = 1.00000./(1.00000+exp( - (STATES(:,1)+3.00000)./15.0000));
    ALGEBRAIC(:,26) =  3.50000.*exp( - power(STATES(:,1)./30.0000, 2.00000))+1.50000;
    ALGEBRAIC(:,12) = 1.00000./(1.00000+exp((STATES(:,1)+33.5000)./10.0000));
    ALGEBRAIC(:,27) = 20.0000./(1.00000+exp((STATES(:,1)+33.5000)./10.0000))+20.0000;
    ALGEBRAIC(:,13) = 1.00000./(1.00000+exp( - (STATES(:,1)+14.5000)./6.00000));
    ALGEBRAIC(:,28) = ( 1.00000.*ALGEBRAIC(:,13).*(1.00000 - exp( - (STATES(:,1)+14.5000)./6.00000)))./( 0.0350000.*(STATES(:,1)+14.5000));
    ALGEBRAIC(:,14) = 1.00000./(1.00000+exp((STATES(:,1)+35.0600)./3.60000))+0.600000./(1.00000+exp((50.0000 - STATES(:,1))./20.0000));
    ALGEBRAIC(:,29) = 1.00000./( 0.0197000.*exp( - power( 0.0337000.*(STATES(:,1)+14.5000), 2.00000))+0.0200000);
    ALGEBRAIC(:,16) = STATES(:,40)+( STATES(:,42).*CONSTANTS(:,174))./CONSTANTS(:,175)+( STATES(:,41).*CONSTANTS(:,173))./CONSTANTS(:,175);
    ALGEBRAIC(:,31) =  CONSTANTS(:,147).*(CONSTANTS(:,139) - ALGEBRAIC(:,16)).*STATES(:,5).*(CONSTANTS(:,141) - STATES(:,40)) -  CONSTANTS(:,149).*STATES(:,40);
    ALGEBRAIC(:,33) =  CONSTANTS(:,147).*(CONSTANTS(:,139) - ALGEBRAIC(:,16)).*STATES(:,7).*(( CONSTANTS(:,142).*CONSTANTS(:,175))./CONSTANTS(:,173) - STATES(:,41)) -  CONSTANTS(:,149).*STATES(:,41);
    ALGEBRAIC(:,32) =  CONSTANTS(:,147).*(CONSTANTS(:,139) - ALGEBRAIC(:,16)).*STATES(:,6).*(( CONSTANTS(:,143).*CONSTANTS(:,175))./CONSTANTS(:,174) - STATES(:,42)) -  CONSTANTS(:,149).*STATES(:,42);
    ALGEBRAIC(:,17) = STATES(:,43)+( STATES(:,45).*CONSTANTS(:,174))./CONSTANTS(:,175)+( STATES(:,44).*CONSTANTS(:,173))./CONSTANTS(:,175);
    ALGEBRAIC(:,34) =  CONSTANTS(:,148).*(CONSTANTS(:,140) - ALGEBRAIC(:,17)).*STATES(:,5).*(CONSTANTS(:,144) - STATES(:,43)) -  CONSTANTS(:,150).*STATES(:,43);
    ALGEBRAIC(:,36) =  CONSTANTS(:,148).*(CONSTANTS(:,140) - ALGEBRAIC(:,17)).*STATES(:,7).*(( CONSTANTS(:,145).*CONSTANTS(:,175))./CONSTANTS(:,173) - STATES(:,44)) -  CONSTANTS(:,150).*STATES(:,44);
    ALGEBRAIC(:,35) =  CONSTANTS(:,148).*(CONSTANTS(:,140) - ALGEBRAIC(:,17)).*STATES(:,6).*(( CONSTANTS(:,146).*CONSTANTS(:,175))./CONSTANTS(:,174) - STATES(:,45)) -  CONSTANTS(:,150).*STATES(:,45);
    ALGEBRAIC(:,15) = CONSTANTS(:,81) - (CONSTANTS(:,81) - CONSTANTS(:,82))./(1.00000+power(CONSTANTS(:,83)./STATES(:,25), CONSTANTS(:,89)));
    ALGEBRAIC(:,30) = CONSTANTS(:,85)./ALGEBRAIC(:,15);
    ALGEBRAIC(:,41) =  CONSTANTS(:,87).*ALGEBRAIC(:,15);
    ALGEBRAIC(:,1) = piecewise({STATES(:,1)< - 40.0000,  0.135000.*exp((80.0000+STATES(:,1))./ - 6.80000) }, 0.00000);
    ALGEBRAIC(:,18) = piecewise({STATES(:,1)< - 40.0000,  3.56000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.350000.*STATES(:,1)) }, 1.00000./( 0.130000.*(1.00000+exp((STATES(:,1)+10.6600)./ - 11.1000))));
    ALGEBRAIC(:,37) = 1.00000./(ALGEBRAIC(:,1)+ALGEBRAIC(:,18));
    ALGEBRAIC(:,42) = ALGEBRAIC(:,1)./(ALGEBRAIC(:,1)+ALGEBRAIC(:,18));
    ALGEBRAIC(:,2) = piecewise({STATES(:,1)< - 40.0000, (( (  - 127140..*exp( 0.244400.*STATES(:,1)) -  3.47400e-05.*exp(  - 0.0439100.*STATES(:,1))).*(STATES(:,1)+37.7800))./1.00000)./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300))) }, 0.00000);
    ALGEBRAIC(:,19) = piecewise({STATES(:,1)< - 40.0000, ( 0.121200.*exp(  - 0.0105200.*STATES(:,1)))./(1.00000+exp(  - 0.137800.*(STATES(:,1)+40.1400))) }, ( 0.300000.*exp(  - 2.53500e-07.*STATES(:,1)))./(1.00000+exp(  - 0.100000.*(STATES(:,1)+32.0000))));
    ALGEBRAIC(:,38) = 1.00000./(ALGEBRAIC(:,2)+ALGEBRAIC(:,19));
    ALGEBRAIC(:,43) = ALGEBRAIC(:,2)./(ALGEBRAIC(:,2)+ALGEBRAIC(:,19));
    ALGEBRAIC(:,3) = (( 0.320000.*(STATES(:,1)+47.1300))./1.00000)./(1.00000 - exp(  - 0.100000.*(STATES(:,1)+47.1300)));
    ALGEBRAIC(:,20) =  0.0800000.*exp( - STATES(:,1)./11.0000);
    ALGEBRAIC(:,39) = 1.00000./(ALGEBRAIC(:,3)+ALGEBRAIC(:,20));
    ALGEBRAIC(:,44) = ALGEBRAIC(:,3)./(ALGEBRAIC(:,3)+ALGEBRAIC(:,20));
    ALGEBRAIC(:,46) = ((1.00000 - STATES(:,22)) - STATES(:,24)) - STATES(:,23);
    ALGEBRAIC(:,69) = 1.00000./(1.00000+exp((STATES(:,1)+33.5000)./10.0000));
    ALGEBRAIC(:,71) = ALGEBRAIC(:,69);
    ALGEBRAIC(:,70) = 2800.00./(1.00000+exp((STATES(:,1)+60.0000)./10.0000))+220.000;
    ALGEBRAIC(:,98) =  CONSTANTS(:,106).*STATES(:,3).*(CONSTANTS(:,105) - STATES(:,27)) -  CONSTANTS(:,107).*STATES(:,27);
    ALGEBRAIC(:,22) =  (( CONSTANTS(:,13).*CONSTANTS(:,14))./CONSTANTS(:,15)).*log(CONSTANTS(:,6)./STATES(:,3));
    ALGEBRAIC(:,48) =  power(STATES(:,8), 3.00000).*STATES(:,9).*STATES(:,10);
    ALGEBRAIC(:,49) =  CONSTANTS(:,23).*CONSTANTS(:,22).*ALGEBRAIC(:,48).*(STATES(:,1) - ALGEBRAIC(:,22));
    ALGEBRAIC(:,52) =  CONSTANTS(:,26).*CONSTANTS(:,25).*(STATES(:,1) - ALGEBRAIC(:,22));
    ALGEBRAIC(:,55) = 1.00000./(1.00000+ 0.124500.*exp((  - 0.100000.*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14)))+ 0.0365000.*CONSTANTS(:,155).*exp((  - STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))));
    ALGEBRAIC(:,56) = ( (( CONSTANTS(:,34).*CONSTANTS(:,153).*CONSTANTS(:,33).*ALGEBRAIC(:,55))./(1.00000+power(( CONSTANTS(:,154).*CONSTANTS(:,31))./STATES(:,3), CONSTANTS(:,29)))).*CONSTANTS(:,5))./(CONSTANTS(:,5)+CONSTANTS(:,32));
    ALGEBRAIC(:,85) = 1.00000 - STATES(:,21);
    ALGEBRAIC(:,81) = ( STATES(:,18).*STATES(:,19).*CONSTANTS(:,158).*STATES(:,1).*power(CONSTANTS(:,15), 2.00000))./( CONSTANTS(:,13).*CONSTANTS(:,14));
    ALGEBRAIC(:,87) = ( ALGEBRAIC(:,81).*ALGEBRAIC(:,85).*CONSTANTS(:,50).*CONSTANTS(:,48).*( CONSTANTS(:,54).*STATES(:,3).*exp(( STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) -  CONSTANTS(:,55).*CONSTANTS(:,6)))./(exp(( STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) - 1.00000);
    ALGEBRAIC(:,93) = 1.00000./(1.00000+power(CONSTANTS(:,67)./STATES(:,6), 3.00000));
    ALGEBRAIC(:,90) = ( exp(( CONSTANTS(:,69).*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))).*power(STATES(:,3), CONSTANTS(:,70)).*CONSTANTS(:,7) -  exp(( (CONSTANTS(:,69) - 1.00000).*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))).*power(CONSTANTS(:,6), CONSTANTS(:,70)).*STATES(:,6))./(1.00000+ CONSTANTS(:,68).*exp(( (CONSTANTS(:,69) - 1.00000).*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))));
    ALGEBRAIC(:,94) = ( CONSTANTS(:,60).*CONSTANTS(:,59).*ALGEBRAIC(:,93).*CONSTANTS(:,159).*ALGEBRAIC(:,90))./( CONSTANTS(:,66).*power(CONSTANTS(:,6), CONSTANTS(:,70)).*(1.00000+power(STATES(:,3)./CONSTANTS(:,63), CONSTANTS(:,70)))+ power(CONSTANTS(:,65), CONSTANTS(:,70)).*STATES(:,6).*(1.00000+STATES(:,6)./CONSTANTS(:,66))+ CONSTANTS(:,64).*power(STATES(:,3), CONSTANTS(:,70))+ power(STATES(:,3), CONSTANTS(:,70)).*CONSTANTS(:,7)+ power(CONSTANTS(:,6), CONSTANTS(:,70)).*STATES(:,6));
    ALGEBRAIC(:,96) =  (STATES(:,3) - STATES(:,4)).*CONSTANTS(:,162);
    ALGEBRAIC(:,99) =  (STATES(:,4) - STATES(:,2)).*CONSTANTS(:,163);
    ALGEBRAIC(:,101) =  CONSTANTS(:,106).*STATES(:,4).*(CONSTANTS(:,104) - STATES(:,26)) -  CONSTANTS(:,107).*STATES(:,26);
    ALGEBRAIC(:,40) =  (( CONSTANTS(:,13).*CONSTANTS(:,14))./CONSTANTS(:,15)).*log(CONSTANTS(:,6)./STATES(:,4));
    ALGEBRAIC(:,50) =  CONSTANTS(:,24).*CONSTANTS(:,22).*ALGEBRAIC(:,48).*(STATES(:,1) - ALGEBRAIC(:,40));
    ALGEBRAIC(:,53) =  CONSTANTS(:,27).*CONSTANTS(:,25).*(STATES(:,1) - ALGEBRAIC(:,40));
    ALGEBRAIC(:,57) = ( (( CONSTANTS(:,35).*CONSTANTS(:,153).*CONSTANTS(:,33).*ALGEBRAIC(:,55))./(1.00000+power(( CONSTANTS(:,154).*CONSTANTS(:,31))./STATES(:,4), CONSTANTS(:,29)))).*CONSTANTS(:,5))./(CONSTANTS(:,5)+CONSTANTS(:,32));
    ALGEBRAIC(:,82) = 1.00000 - STATES(:,20);
    ALGEBRAIC(:,84) = ( ALGEBRAIC(:,81).*ALGEBRAIC(:,82).*CONSTANTS(:,51).*CONSTANTS(:,48).*( CONSTANTS(:,54).*STATES(:,4).*exp(( STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) -  CONSTANTS(:,55).*CONSTANTS(:,6)))./(exp(( STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) - 1.00000);
    ALGEBRAIC(:,92) = 1.00000./(1.00000+power(CONSTANTS(:,67)./STATES(:,7), 3.00000));
    ALGEBRAIC(:,91) = ( exp(( CONSTANTS(:,69).*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))).*power(STATES(:,4), CONSTANTS(:,70)).*CONSTANTS(:,7) -  exp(( (CONSTANTS(:,69) - 1.00000).*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))).*power(CONSTANTS(:,6), CONSTANTS(:,70)).*STATES(:,7))./(1.00000+ CONSTANTS(:,68).*exp(( (CONSTANTS(:,69) - 1.00000).*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))));
    ALGEBRAIC(:,95) = ( CONSTANTS(:,61).*CONSTANTS(:,59).*ALGEBRAIC(:,92).*CONSTANTS(:,159).*ALGEBRAIC(:,91))./( CONSTANTS(:,66).*power(CONSTANTS(:,6), CONSTANTS(:,70)).*(1.00000+power(STATES(:,4)./CONSTANTS(:,63), CONSTANTS(:,70)))+ power(CONSTANTS(:,65), CONSTANTS(:,70)).*STATES(:,7).*(1.00000+STATES(:,7)./CONSTANTS(:,66))+ CONSTANTS(:,64).*power(STATES(:,4), CONSTANTS(:,70))+ power(STATES(:,4), CONSTANTS(:,70)).*CONSTANTS(:,7)+ power(CONSTANTS(:,6), CONSTANTS(:,70)).*STATES(:,7));
    ALGEBRAIC(:,51) = ALGEBRAIC(:,49)+ALGEBRAIC(:,50);
    ALGEBRAIC(:,54) = ALGEBRAIC(:,52)+ALGEBRAIC(:,53);
    ALGEBRAIC(:,58) = ALGEBRAIC(:,56)+ALGEBRAIC(:,57);
    ALGEBRAIC(:,59) = 1.00000./(1.00000+exp((33.0000+STATES(:,1))./22.4000));
    ALGEBRAIC(:,60) =  CONSTANTS(:,156).*STATES(:,11).*ALGEBRAIC(:,59).*(STATES(:,1) - CONSTANTS(:,151));
    ALGEBRAIC(:,61) =  - arbitrary_log(STATES(:,6)./1.00000+3.00000, 10);
    ALGEBRAIC(:,63) =  0.0700000.*(0.0570000+0.190000./(1.00000+exp( - 7.20000+ALGEBRAIC(:,61)./0.600000)));
    ALGEBRAIC(:,65) =  (( CONSTANTS(:,13).*CONSTANTS(:,14))./CONSTANTS(:,15)).*log((CONSTANTS(:,5)+ CONSTANTS(:,38).*CONSTANTS(:,6))./(CONSTANTS(:,9)+ CONSTANTS(:,38).*STATES(:,2)));
    ALGEBRAIC(:,66) =  CONSTANTS(:,36).*ALGEBRAIC(:,63).*power(STATES(:,12), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,62) =  - arbitrary_log(STATES(:,7)./1.00000+3.00000, 10);
    ALGEBRAIC(:,64) =  0.0700000.*(0.0570000+0.190000./(1.00000+exp( - 7.20000+ALGEBRAIC(:,62)./0.600000)));
    ALGEBRAIC(:,67) =  CONSTANTS(:,37).*ALGEBRAIC(:,64).*power(STATES(:,12), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,68) = ALGEBRAIC(:,66)+ALGEBRAIC(:,67);
    ALGEBRAIC(:,72) =  CONSTANTS(:,39).*STATES(:,14).*(STATES(:,13)+ 0.500000.*ALGEBRAIC(:,71)).*(STATES(:,1) - CONSTANTS(:,151));
    ALGEBRAIC(:,73) =  CONSTANTS(:,40).*STATES(:,17).*STATES(:,16).*(STATES(:,1) - CONSTANTS(:,151));
    ALGEBRAIC(:,74) = 1.02000./(1.00000+exp( 0.238500.*(STATES(:,1) - (CONSTANTS(:,151)+59.2150))));
    ALGEBRAIC(:,75) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1) - CONSTANTS(:,151))+5.47600))+ 1.00000.*exp( 0.0617500.*(STATES(:,1) - (CONSTANTS(:,151)+594.310))))./(1.00000+exp(  - 0.514300.*((STATES(:,1) - CONSTANTS(:,151))+4.75300)));
    ALGEBRAIC(:,76) = ALGEBRAIC(:,74)./(ALGEBRAIC(:,74)+ALGEBRAIC(:,75));
    ALGEBRAIC(:,77) =  CONSTANTS(:,157).*ALGEBRAIC(:,76).*(STATES(:,1) - CONSTANTS(:,151));
    ALGEBRAIC(:,78) = ( CONSTANTS(:,41).*(STATES(:,1) - CONSTANTS(:,151)))./(1.00000+exp(7.48800 - STATES(:,1)./5.98000));
    ALGEBRAIC(:,97) = ALGEBRAIC(:,94)+ALGEBRAIC(:,95);
    ALGEBRAIC(:,79) =  CONSTANTS(:,42).*(STATES(:,1) - CONSTANTS(:,152)).*(CONSTANTS(:,44)./(1.00000+CONSTANTS(:,43)./STATES(:,6))+CONSTANTS(:,45)./(1.00000+CONSTANTS(:,43)./STATES(:,7)));
    ALGEBRAIC(:,80) =  CONSTANTS(:,46).*(STATES(:,1) - CONSTANTS(:,152));
    ALGEBRAIC(:,83) = ( ALGEBRAIC(:,81).*ALGEBRAIC(:,82).*CONSTANTS(:,51).*CONSTANTS(:,47).*4.00000.*( CONSTANTS(:,52).*STATES(:,7).*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) -  CONSTANTS(:,53).*CONSTANTS(:,7)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) - 1.00000);
    ALGEBRAIC(:,86) = ( ALGEBRAIC(:,81).*ALGEBRAIC(:,85).*CONSTANTS(:,50).*CONSTANTS(:,47).*4.00000.*( CONSTANTS(:,52).*STATES(:,6).*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) -  CONSTANTS(:,53).*CONSTANTS(:,7)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) - 1.00000);
    ALGEBRAIC(:,88) = ( ALGEBRAIC(:,81).*( ALGEBRAIC(:,82).*CONSTANTS(:,51)+ ALGEBRAIC(:,85).*CONSTANTS(:,50)).*CONSTANTS(:,49).*( CONSTANTS(:,56).*CONSTANTS(:,9).*exp(( STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) -  CONSTANTS(:,57).*CONSTANTS(:,5)))./(exp(( STATES(:,1).*CONSTANTS(:,15))./( CONSTANTS(:,13).*CONSTANTS(:,14))) - 1.00000);
    ALGEBRAIC(:,89) = ALGEBRAIC(:,83)+ALGEBRAIC(:,86)+ALGEBRAIC(:,84)+ALGEBRAIC(:,87)+ALGEBRAIC(:,88);
    ALGEBRAIC(:,45) =  (( CONSTANTS(:,13).*CONSTANTS(:,14))./( 2.00000.*CONSTANTS(:,15))).*log(CONSTANTS(:,7)./STATES(:,6));
    ALGEBRAIC(:,104) =  CONSTANTS(:,78).*CONSTANTS(:,79).*(STATES(:,1) - ALGEBRAIC(:,45));
    ALGEBRAIC(:,47) =  (( CONSTANTS(:,13).*CONSTANTS(:,14))./( 2.00000.*CONSTANTS(:,15))).*log(CONSTANTS(:,7)./STATES(:,7));
    ALGEBRAIC(:,105) =  CONSTANTS(:,78).*CONSTANTS(:,80).*(STATES(:,1) - ALGEBRAIC(:,47));
    ALGEBRAIC(:,106) = ALGEBRAIC(:,105)+ALGEBRAIC(:,104);
    ALGEBRAIC(:,102) = ( CONSTANTS(:,160).*CONSTANTS(:,77).*CONSTANTS(:,73))./(1.00000+power(CONSTANTS(:,75)./STATES(:,7), CONSTANTS(:,76)));
    ALGEBRAIC(:,100) = ( CONSTANTS(:,160).*CONSTANTS(:,77).*CONSTANTS(:,72))./(1.00000+power(CONSTANTS(:,75)./STATES(:,6), CONSTANTS(:,76)));
    ALGEBRAIC(:,103) = ALGEBRAIC(:,100)+ALGEBRAIC(:,102);
    ALGEBRAIC(:,7) = piecewise({VOI -  floor(VOI./CONSTANTS(:,2)).*CONSTANTS(:,2)>=CONSTANTS(:,1)&VOI -  floor(VOI./CONSTANTS(:,2)).*CONSTANTS(:,2)<=CONSTANTS(:,1)+CONSTANTS(:,3),  - CONSTANTS(:,4) }, 0.00000);
    ALGEBRAIC(:,110) =  CONSTANTS(:,114).*STATES(:,25).*(( CONSTANTS(:,112).*CONSTANTS(:,175))./CONSTANTS(:,172) - STATES(:,32)) -  CONSTANTS(:,117).*STATES(:,32);
    ALGEBRAIC(:,107) =  CONSTANTS(:,84).*STATES(:,24).*(STATES(:,25) - STATES(:,6));
    ALGEBRAIC(:,108) =  CONSTANTS(:,90).*(STATES(:,25) - STATES(:,6));
    ALGEBRAIC(:,109) = ( (( CONSTANTS(:,161).*CONSTANTS(:,91).*CONSTANTS(:,175))./CONSTANTS(:,172)).*(power(STATES(:,5)./CONSTANTS(:,93), CONSTANTS(:,95)) - power(STATES(:,25)./CONSTANTS(:,94), CONSTANTS(:,95))))./(1.00000+power(STATES(:,5)./CONSTANTS(:,93), CONSTANTS(:,95))+power(STATES(:,25)./CONSTANTS(:,94), CONSTANTS(:,95)));
    ALGEBRAIC(:,113) =  CONSTANTS(:,113).*STATES(:,6).*(( CONSTANTS(:,109).*CONSTANTS(:,175))./CONSTANTS(:,174) - STATES(:,29)) -  CONSTANTS(:,115).*STATES(:,29);
    ALGEBRAIC(:,115) =  CONSTANTS(:,113).*STATES(:,7).*(( CONSTANTS(:,108).*CONSTANTS(:,175))./CONSTANTS(:,173) - STATES(:,28)) -  CONSTANTS(:,115).*STATES(:,28);
    ALGEBRAIC(:,116) =  CONSTANTS(:,113).*STATES(:,6).*(( CONSTANTS(:,111).*CONSTANTS(:,175))./CONSTANTS(:,174) - STATES(:,31)) -  CONSTANTS(:,116).*STATES(:,31);
    ALGEBRAIC(:,114) =  CONSTANTS(:,125).*STATES(:,5).*(CONSTANTS(:,118) - STATES(:,33)) -  CONSTANTS(:,132).*STATES(:,33);
    ALGEBRAIC(:,118) =  CONSTANTS(:,113).*STATES(:,7).*(( CONSTANTS(:,110).*CONSTANTS(:,175))./CONSTANTS(:,173) - STATES(:,30)) -  CONSTANTS(:,116).*STATES(:,30);
    ALGEBRAIC(:,117) =  CONSTANTS(:,126).*STATES(:,5).*(CONSTANTS(:,119) - (STATES(:,34)+STATES(:,35))) -  CONSTANTS(:,133).*STATES(:,34);
    ALGEBRAIC(:,111) =  (STATES(:,6) - STATES(:,7)).*CONSTANTS(:,164);
    ALGEBRAIC(:,119) = ALGEBRAIC(:,113)+ALGEBRAIC(:,116);
    ALGEBRAIC(:,121) = (ALGEBRAIC(:,86) -  2.00000.*ALGEBRAIC(:,94))+ALGEBRAIC(:,104)+ALGEBRAIC(:,100);
    ALGEBRAIC(:,120) =  CONSTANTS(:,127).*CONSTANTS(:,10).*(CONSTANTS(:,120) - (STATES(:,34)+STATES(:,35))) -  CONSTANTS(:,134).*STATES(:,35);
    ALGEBRAIC(:,112) =  (STATES(:,7) - STATES(:,5)).*CONSTANTS(:,165);
    ALGEBRAIC(:,122) = ALGEBRAIC(:,115)+ALGEBRAIC(:,118);
    ALGEBRAIC(:,124) = (ALGEBRAIC(:,83) -  2.00000.*ALGEBRAIC(:,95))+ALGEBRAIC(:,105)+ALGEBRAIC(:,102);
    ALGEBRAIC(:,123) =  CONSTANTS(:,128).*STATES(:,5).*(CONSTANTS(:,121) - STATES(:,36)) -  CONSTANTS(:,135).*STATES(:,36);
    ALGEBRAIC(:,125) =  CONSTANTS(:,129).*STATES(:,5).*(CONSTANTS(:,122) - (STATES(:,37)+STATES(:,38))) -  CONSTANTS(:,136).*STATES(:,37);
    ALGEBRAIC(:,126) =  CONSTANTS(:,130).*CONSTANTS(:,10).*(CONSTANTS(:,123) - (STATES(:,37)+STATES(:,38))) -  CONSTANTS(:,137).*STATES(:,38);
    ALGEBRAIC(:,127) =  CONSTANTS(:,131).*STATES(:,5).*(CONSTANTS(:,124) - STATES(:,39)) -  CONSTANTS(:,138).*STATES(:,39);
    ALGEBRAIC(:,128) = ALGEBRAIC(:,114)+ALGEBRAIC(:,117)+ALGEBRAIC(:,120)+ALGEBRAIC(:,123)+ALGEBRAIC(:,125)+ALGEBRAIC(:,126)+ALGEBRAIC(:,127);
    ALGEBRAIC(:,5) =  (( CONSTANTS(:,13).*CONSTANTS(:,14))./CONSTANTS(:,15)).*log((CONSTANTS(:,5)+ CONSTANTS(:,38).*CONSTANTS(:,6))./(CONSTANTS(:,9)+ CONSTANTS(:,38).*STATES(:,3)));
    ALGEBRAIC(:,6) =  (( CONSTANTS(:,13).*CONSTANTS(:,14))./CONSTANTS(:,15)).*log((CONSTANTS(:,5)+ CONSTANTS(:,38).*CONSTANTS(:,6))./(CONSTANTS(:,9)+ CONSTANTS(:,38).*STATES(:,4)));
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

% Compute a logarithm to any base" +
function x = arbitrary_log(a, base)
    x = log(a) ./ log(base);
end

% Pad out or shorten strings to a set length
function strout = strpad(strin)
    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