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 =114;
end
% There are a total of 39 entries in each of the rate and state variable arrays.
% There are a total of 128 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 (msec)');
    LEGEND_STATES(:,1) = strpad('V_m in component membrane_potential (mV)');
    LEGEND_CONSTANTS(:,5) = strpad('epi in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,6) = strpad('R in component parameters (joule_per_kelvin_per_kilomole)');
    LEGEND_CONSTANTS(:,100) = strpad('Frdy in component parameters (coulomb_per_mole)');
    LEGEND_CONSTANTS(:,110) = strpad('Temp in component parameters (kelvin)');
    LEGEND_CONSTANTS(:,114) = strpad('FoRT in component parameters (per_mV)');
    LEGEND_CONSTANTS(:,7) = strpad('Cmem in component parameters (farad)');
    LEGEND_CONSTANTS(:,115) = strpad('Qpow in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,8) = strpad('cellLength in component parameters (um)');
    LEGEND_CONSTANTS(:,101) = strpad('cellRadius in component parameters (um)');
    LEGEND_CONSTANTS(:,9) = strpad('junctionLength in component parameters (um)');
    LEGEND_CONSTANTS(:,102) = strpad('junctionRadius in component parameters (um)');
    LEGEND_CONSTANTS(:,10) = strpad('distSLcyto in component parameters (um)');
    LEGEND_CONSTANTS(:,11) = strpad('distJuncSL in component parameters (um)');
    LEGEND_CONSTANTS(:,12) = strpad('DcaJuncSL in component parameters (cm2_per_sec)');
    LEGEND_CONSTANTS(:,13) = strpad('DcaSLcyto in component parameters (cm2_per_sec)');
    LEGEND_CONSTANTS(:,14) = strpad('DnaJuncSL in component parameters (cm2_per_sec)');
    LEGEND_CONSTANTS(:,15) = strpad('DnaSLcyto in component parameters (cm2_per_sec)');
    LEGEND_CONSTANTS(:,111) = strpad('Vcell in component parameters (liter)');
    LEGEND_CONSTANTS(:,116) = strpad('Vmyo in component parameters (liter)');
    LEGEND_CONSTANTS(:,117) = strpad('Vsr in component parameters (liter)');
    LEGEND_CONSTANTS(:,118) = strpad('Vsl in component parameters (liter)');
    LEGEND_CONSTANTS(:,119) = strpad('Vjunc in component parameters (liter)');
    LEGEND_CONSTANTS(:,112) = strpad('SAjunc in component parameters (um2)');
    LEGEND_CONSTANTS(:,113) = strpad('SAsl in component parameters (um2)');
    LEGEND_CONSTANTS(:,16) = strpad('J_ca_juncsl in component parameters (liters_per_msec)');
    LEGEND_CONSTANTS(:,17) = strpad('J_ca_slmyo in component parameters (liters_per_msec)');
    LEGEND_CONSTANTS(:,18) = strpad('J_na_juncsl in component parameters (liters_per_msec)');
    LEGEND_CONSTANTS(:,19) = strpad('J_na_slmyo in component parameters (liters_per_msec)');
    LEGEND_CONSTANTS(:,20) = strpad('Fjunc in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,103) = strpad('Fsl in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,21) = strpad('Fjunc_CaL in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,104) = strpad('Fsl_CaL in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,120) = strpad('Cli in component parameters (mM)');
    LEGEND_CONSTANTS(:,121) = strpad('Clo in component parameters (mM)');
    LEGEND_CONSTANTS(:,22) = strpad('Ko in component parameters (mM)');
    LEGEND_CONSTANTS(:,23) = strpad('Nao in component parameters (mM)');
    LEGEND_CONSTANTS(:,24) = strpad('Cao in component parameters (mM)');
    LEGEND_CONSTANTS(:,25) = strpad('Mgi in component parameters (mM)');
    LEGEND_ALGEBRAIC(:,10) = strpad('ena_junc in component parameters (mV)');
    LEGEND_ALGEBRAIC(:,23) = strpad('ena_sl in component parameters (mV)');
    LEGEND_ALGEBRAIC(:,27) = strpad('ek in component parameters (mV)');
    LEGEND_ALGEBRAIC(:,31) = strpad('eca_junc in component parameters (mV)');
    LEGEND_ALGEBRAIC(:,33) = strpad('eca_sl in component parameters (mV)');
    LEGEND_CONSTANTS(:,127) = strpad('ecl in component parameters (mV)');
    LEGEND_CONSTANTS(:,26) = strpad('GNa in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,27) = strpad('GNaB in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,28) = strpad('IbarNaK in component parameters (uA_per_uF)');
    LEGEND_CONSTANTS(:,29) = strpad('KmNaip in component parameters (mM)');
    LEGEND_CONSTANTS(:,30) = strpad('KmKo in component parameters (mM)');
    LEGEND_CONSTANTS(:,31) = strpad('Q10NaK in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,32) = strpad('Q10KmNai in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,33) = strpad('pNaK in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,34) = strpad('gkp in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,35) = strpad('GClCa in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,36) = strpad('GClB in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,37) = strpad('KdClCa in component parameters (mM)');
    LEGEND_CONSTANTS(:,38) = strpad('pNa in component parameters (cm_per_sec)');
    LEGEND_CONSTANTS(:,39) = strpad('pCa in component parameters (cm_per_sec)');
    LEGEND_CONSTANTS(:,40) = strpad('pK in component parameters (cm_per_sec)');
    LEGEND_CONSTANTS(:,41) = strpad('Q10CaL in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,42) = strpad('IbarNCX in component parameters (uA_per_uF)');
    LEGEND_CONSTANTS(:,43) = strpad('KmCai in component parameters (mM)');
    LEGEND_CONSTANTS(:,44) = strpad('KmCao in component parameters (mM)');
    LEGEND_CONSTANTS(:,45) = strpad('KmNai in component parameters (mM)');
    LEGEND_CONSTANTS(:,46) = strpad('KmNao in component parameters (mM)');
    LEGEND_CONSTANTS(:,47) = strpad('ksat in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,48) = strpad('nu in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,49) = strpad('Kdact in component parameters (mM)');
    LEGEND_CONSTANTS(:,50) = strpad('Q10NCX in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,51) = strpad('IbarSLCaP in component parameters (uA_per_uF)');
    LEGEND_CONSTANTS(:,52) = strpad('KmPCa in component parameters (mM)');
    LEGEND_CONSTANTS(:,53) = strpad('GCaB in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,54) = strpad('Q10SLCaP in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,55) = strpad('Q10SRCaP in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,56) = strpad('Vmax_SRCaP in component parameters (mM_per_msec)');
    LEGEND_CONSTANTS(:,57) = strpad('Kmf in component parameters (mM)');
    LEGEND_CONSTANTS(:,58) = strpad('Kmr in component parameters (mM)');
    LEGEND_CONSTANTS(:,59) = strpad('hillSRCaP in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,60) = strpad('ks in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,61) = strpad('koCa in component parameters (per_mM2_per_msec)');
    LEGEND_CONSTANTS(:,62) = strpad('kom in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,109) = strpad('kiCa in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,63) = strpad('kim in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,64) = strpad('ec50SR in component parameters (mM)');
    LEGEND_CONSTANTS(:,65) = strpad('Bmax_Naj in component parameters (mM)');
    LEGEND_CONSTANTS(:,66) = strpad('Bmax_Nasl in component parameters (mM)');
    LEGEND_CONSTANTS(:,67) = strpad('koff_na in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,68) = strpad('kon_na in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,69) = strpad('Bmax_TnClow in component parameters (mM)');
    LEGEND_CONSTANTS(:,70) = strpad('koff_tncl in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,71) = strpad('kon_tncl in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,72) = strpad('Bmax_TnChigh in component parameters (mM)');
    LEGEND_CONSTANTS(:,73) = strpad('koff_tnchca in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,74) = strpad('kon_tnchca in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,75) = strpad('koff_tnchmg in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,76) = strpad('kon_tnchmg in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,77) = strpad('Bmax_CaM in component parameters (mM)');
    LEGEND_CONSTANTS(:,78) = strpad('koff_cam in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,79) = strpad('kon_cam in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,80) = strpad('Bmax_myosin in component parameters (mM)');
    LEGEND_CONSTANTS(:,81) = strpad('koff_myoca in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,82) = strpad('kon_myoca in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,83) = strpad('koff_myomg in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,84) = strpad('kon_myomg in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,85) = strpad('Bmax_SR in component parameters (mM)');
    LEGEND_CONSTANTS(:,86) = strpad('koff_sr in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,87) = strpad('kon_sr in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,122) = strpad('Bmax_SLlowsl in component parameters (mM)');
    LEGEND_CONSTANTS(:,123) = strpad('Bmax_SLlowj in component parameters (mM)');
    LEGEND_CONSTANTS(:,88) = strpad('koff_sll in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,89) = strpad('kon_sll in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,124) = strpad('Bmax_SLhighsl in component parameters (mM)');
    LEGEND_CONSTANTS(:,125) = strpad('Bmax_SLhighj in component parameters (mM)');
    LEGEND_CONSTANTS(:,90) = strpad('koff_slh in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,91) = strpad('kon_slh in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,126) = strpad('Bmax_Csqn in component parameters (mM)');
    LEGEND_CONSTANTS(:,92) = strpad('koff_csqn in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,93) = strpad('kon_csqn in component parameters (per_mM_per_msec)');
    LEGEND_STATES(:,2) = strpad('Na_j in component Na_Concentrations (mM)');
    LEGEND_STATES(:,3) = strpad('Na_sl in component Na_Concentrations (mM)');
    LEGEND_STATES(:,4) = strpad('K_i in component K_Concentration (mM)');
    LEGEND_STATES(:,5) = strpad('Ca_j in component Ca_Concentrations (mM)');
    LEGEND_STATES(:,6) = strpad('Ca_sl in component Ca_Concentrations (mM)');
    LEGEND_ALGEBRAIC(:,1) = strpad('mss in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,12) = strpad('taum in component I_Na (msec)');
    LEGEND_ALGEBRAIC(:,2) = strpad('ah in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,13) = strpad('bh in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,25) = strpad('tauh in component I_Na (msec)');
    LEGEND_ALGEBRAIC(:,29) = strpad('hss in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,3) = strpad('aj in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,14) = strpad('bj in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,26) = strpad('tauj in component I_Na (msec)');
    LEGEND_ALGEBRAIC(:,30) = strpad('jss in component I_Na (dimensionless)');
    LEGEND_STATES(:,7) = strpad('m in component I_Na (dimensionless)');
    LEGEND_STATES(:,8) = strpad('h in component I_Na (dimensionless)');
    LEGEND_STATES(:,9) = strpad('j in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,34) = strpad('I_Na_junc in component I_Na (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,35) = strpad('I_Na_sl in component I_Na (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,36) = strpad('I_Na in component I_Na (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,37) = strpad('I_nabk_junc in component I_NaBK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,38) = strpad('I_nabk_sl in component I_NaBK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,39) = strpad('I_nabk in component I_NaBK (uA_per_uF)');
    LEGEND_CONSTANTS(:,105) = strpad('sigma in component I_NaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,40) = strpad('fnak in component I_NaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,41) = strpad('I_nak_junc in component I_NaK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,42) = strpad('I_nak_sl in component I_NaK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,43) = strpad('I_nak in component I_NaK (uA_per_uF)');
    LEGEND_CONSTANTS(:,106) = strpad('gkr in component I_Kr (mS_per_uF)');
    LEGEND_ALGEBRAIC(:,4) = strpad('xrss in component I_Kr (dimensionless)');
    LEGEND_ALGEBRAIC(:,15) = strpad('tauxr in component I_Kr (msec)');
    LEGEND_STATES(:,10) = strpad('x_kr in component I_Kr (dimensionless)');
    LEGEND_ALGEBRAIC(:,44) = strpad('rkr in component I_Kr (dimensionless)');
    LEGEND_ALGEBRAIC(:,45) = strpad('I_kr in component I_Kr (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,46) = strpad('kp_kp in component I_Kp (dimensionless)');
    LEGEND_ALGEBRAIC(:,47) = strpad('I_kp_junc in component I_Kp (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,48) = strpad('I_kp_sl in component I_Kp (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,49) = strpad('I_kp in component I_Kp (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,50) = strpad('eks in component I_Ks (mV)');
    LEGEND_CONSTANTS(:,94) = strpad('gks_junc in component I_Ks (mS_per_uF)');
    LEGEND_CONSTANTS(:,95) = strpad('gks_sl in component I_Ks (mS_per_uF)');
    LEGEND_ALGEBRAIC(:,5) = strpad('xsss in component I_Ks (dimensionless)');
    LEGEND_ALGEBRAIC(:,16) = strpad('tauxs in component I_Ks (msec)');
    LEGEND_STATES(:,11) = strpad('x_ks in component I_Ks (dimensionless)');
    LEGEND_ALGEBRAIC(:,51) = strpad('I_ks_junc in component I_Ks (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,52) = strpad('I_ks_sl in component I_Ks (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,53) = strpad('I_ks in component I_Ks (uA_per_uF)');
    LEGEND_STATES(:,12) = strpad('Na_i in component Na_Concentrations (mM)');
    LEGEND_CONSTANTS(:,107) = strpad('GtoSlow in component I_to (mS_per_uF)');
    LEGEND_CONSTANTS(:,108) = strpad('GtoFast in component I_to (mS_per_uF)');
    LEGEND_ALGEBRAIC(:,6) = strpad('xtoss in component I_to (dimensionless)');
    LEGEND_ALGEBRAIC(:,7) = strpad('ytoss in component I_to (dimensionless)');
    LEGEND_ALGEBRAIC(:,17) = strpad('tauxtos in component I_to (msec)');
    LEGEND_ALGEBRAIC(:,18) = strpad('tauytos in component I_to (msec)');
    LEGEND_STATES(:,13) = strpad('x_to_s in component I_to (dimensionless)');
    LEGEND_STATES(:,14) = strpad('y_to_s in component I_to (dimensionless)');
    LEGEND_ALGEBRAIC(:,54) = strpad('I_tos in component I_to (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,19) = strpad('tauxtof in component I_to (msec)');
    LEGEND_ALGEBRAIC(:,20) = strpad('tauytof in component I_to (msec)');
    LEGEND_STATES(:,15) = strpad('x_to_f in component I_to (dimensionless)');
    LEGEND_STATES(:,16) = strpad('y_to_f in component I_to (dimensionless)');
    LEGEND_ALGEBRAIC(:,55) = strpad('I_tof in component I_to (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,56) = strpad('I_to in component I_to (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,57) = strpad('aki in component I_Ki (dimensionless)');
    LEGEND_ALGEBRAIC(:,58) = strpad('bki in component I_Ki (dimensionless)');
    LEGEND_ALGEBRAIC(:,59) = strpad('kiss in component I_Ki (dimensionless)');
    LEGEND_ALGEBRAIC(:,60) = strpad('I_ki in component I_Ki (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,61) = strpad('I_ClCa_junc in component I_ClCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,62) = strpad('I_ClCa_sl in component I_ClCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,63) = strpad('I_ClCa in component I_ClCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,64) = strpad('I_Clbk in component I_ClCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,8) = strpad('fss in component I_Ca (dimensionless)');
    LEGEND_ALGEBRAIC(:,9) = strpad('dss in component I_Ca (dimensionless)');
    LEGEND_ALGEBRAIC(:,21) = strpad('taud in component I_Ca (msec)');
    LEGEND_ALGEBRAIC(:,22) = strpad('tauf in component I_Ca (msec)');
    LEGEND_STATES(:,17) = strpad('d in component I_Ca (dimensionless)');
    LEGEND_STATES(:,18) = strpad('f in component I_Ca (dimensionless)');
    LEGEND_STATES(:,19) = strpad('f_Ca_Bj in component I_Ca (dimensionless)');
    LEGEND_STATES(:,20) = strpad('f_Ca_Bsl in component I_Ca (dimensionless)');
    LEGEND_CONSTANTS(:,96) = strpad('fcaCaMSL in component I_Ca (dimensionless)');
    LEGEND_CONSTANTS(:,97) = strpad('fcaCaj in component I_Ca (dimensionless)');
    LEGEND_ALGEBRAIC(:,65) = strpad('ibarca_j in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,66) = strpad('ibarca_sl in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,67) = strpad('ibark in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,68) = strpad('ibarna_j in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,69) = strpad('ibarna_sl in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,70) = strpad('I_Ca_junc in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,71) = strpad('I_Ca_sl in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,72) = strpad('I_Ca in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,73) = strpad('I_CaK in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,74) = strpad('I_CaNa_junc in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,75) = strpad('I_CaNa_sl in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,76) = strpad('I_CaNa in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,78) = strpad('I_Catot in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,77) = strpad('Ka_junc in component I_NCX (dimensionless)');
    LEGEND_ALGEBRAIC(:,79) = strpad('Ka_sl in component I_NCX (dimensionless)');
    LEGEND_ALGEBRAIC(:,80) = strpad('s1_junc in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,81) = strpad('s1_sl in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,82) = strpad('s2_junc in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,83) = strpad('s3_junc in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,84) = strpad('s2_sl in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,85) = strpad('s3_sl in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,86) = strpad('I_ncx_junc in component I_NCX (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,87) = strpad('I_ncx_sl in component I_NCX (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,89) = strpad('I_ncx in component I_NCX (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,90) = strpad('I_pca_junc in component I_PCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,92) = strpad('I_pca_sl in component I_PCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,93) = strpad('I_pca in component I_PCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,94) = strpad('I_cabk_junc in component I_CaBK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,95) = strpad('I_cabk_sl in component I_CaBK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,96) = strpad('I_cabk in component I_CaBK (uA_per_uF)');
    LEGEND_CONSTANTS(:,98) = strpad('MaxSR in component SR_Fluxes (dimensionless)');
    LEGEND_CONSTANTS(:,99) = strpad('MinSR in component SR_Fluxes (dimensionless)');
    LEGEND_ALGEBRAIC(:,11) = strpad('kCaSR in component SR_Fluxes (dimensionless)');
    LEGEND_ALGEBRAIC(:,24) = strpad('koSRCa in component SR_Fluxes (per_mM2_per_msec)');
    LEGEND_ALGEBRAIC(:,28) = strpad('kiSRCa in component SR_Fluxes (per_mM_per_msec)');
    LEGEND_ALGEBRAIC(:,32) = strpad('RI in component SR_Fluxes (mM)');
    LEGEND_STATES(:,21) = strpad('Ry_Rr in component SR_Fluxes (mM)');
    LEGEND_STATES(:,22) = strpad('Ry_Ro in component SR_Fluxes (mM)');
    LEGEND_STATES(:,23) = strpad('Ry_Ri in component SR_Fluxes (mM)');
    LEGEND_ALGEBRAIC(:,97) = strpad('J_SRCarel in component SR_Fluxes (mM_per_msec)');
    LEGEND_ALGEBRAIC(:,98) = strpad('J_serca in component SR_Fluxes (mM_per_msec)');
    LEGEND_ALGEBRAIC(:,99) = strpad('J_SRleak in component SR_Fluxes (mM_per_msec)');
    LEGEND_STATES(:,24) = strpad('Ca_sr in component SR_Ca_Concentrations (mM)');
    LEGEND_STATES(:,25) = strpad('Ca_i in component Ca_Concentrations (mM)');
    LEGEND_STATES(:,26) = strpad('Na_Bj in component Na_Buffers (mM)');
    LEGEND_STATES(:,27) = strpad('Na_Bsl in component Na_Buffers (mM)');
    LEGEND_ALGEBRAIC(:,101) = strpad('dNa_Bj_dt in component Na_Buffers (mM_per_msec)');
    LEGEND_ALGEBRAIC(:,102) = strpad('dNa_Bsl_dt in component Na_Buffers (mM_per_msec)');
    LEGEND_STATES(:,28) = strpad('Tn_CL in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_STATES(:,29) = strpad('Tn_CHc in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_STATES(:,30) = strpad('Tn_CHm in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_STATES(:,31) = strpad('CaM in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_STATES(:,32) = strpad('Myo_c in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_STATES(:,33) = strpad('Myo_m in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_STATES(:,34) = strpad('SRB in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_ALGEBRAIC(:,100) = strpad('J_CaB_cytosol in component Cytosolic_Ca_Buffers (mM_per_msec)');
    LEGEND_STATES(:,35) = strpad('SLL_j in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_STATES(:,36) = strpad('SLL_sl in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_STATES(:,37) = strpad('SLH_j in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_STATES(:,38) = strpad('SLH_sl in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_ALGEBRAIC(:,103) = strpad('J_CaB_junction in component Junctional_and_SL_Ca_Buffers (mM_per_msec)');
    LEGEND_ALGEBRAIC(:,104) = strpad('J_CaB_sl in component Junctional_and_SL_Ca_Buffers (mM_per_msec)');
    LEGEND_STATES(:,39) = strpad('Csqn_b in component SR_Ca_Concentrations (mM)');
    LEGEND_ALGEBRAIC(:,105) = strpad('I_Na_tot_junc in component Na_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,106) = strpad('I_Na_tot_sl in component Na_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,91) = strpad('I_Na_tot_sl2 in component Na_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,88) = strpad('I_Na_tot_junc2 in component Na_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,107) = strpad('I_K_tot in component K_Concentration (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,108) = strpad('I_Ca_tot_junc in component Ca_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,109) = strpad('I_Ca_tot_sl in component Ca_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,111) = strpad('I_Na_tot in component membrane_potential (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,112) = strpad('I_Cl_tot in component membrane_potential (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,113) = strpad('I_Ca_tot in component membrane_potential (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,114) = strpad('I_tot in component membrane_potential (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,110) = strpad('i_Stim in component membrane_potential (uA_per_uF)');
    LEGEND_CONSTANTS(:,1) = strpad('stim_start in component membrane_potential (msec)');
    LEGEND_CONSTANTS(:,2) = strpad('stim_period in component membrane_potential (msec)');
    LEGEND_CONSTANTS(:,3) = strpad('stim_duration in component membrane_potential (msec)');
    LEGEND_CONSTANTS(:,4) = strpad('stim_amplitude in component membrane_potential (uA_per_uF)');
    LEGEND_RATES(:,7) = strpad('d/dt m in component I_Na (dimensionless)');
    LEGEND_RATES(:,8) = strpad('d/dt h in component I_Na (dimensionless)');
    LEGEND_RATES(:,9) = strpad('d/dt j in component I_Na (dimensionless)');
    LEGEND_RATES(:,10) = strpad('d/dt x_kr in component I_Kr (dimensionless)');
    LEGEND_RATES(:,11) = strpad('d/dt x_ks in component I_Ks (dimensionless)');
    LEGEND_RATES(:,13) = strpad('d/dt x_to_s in component I_to (dimensionless)');
    LEGEND_RATES(:,14) = strpad('d/dt y_to_s in component I_to (dimensionless)');
    LEGEND_RATES(:,15) = strpad('d/dt x_to_f in component I_to (dimensionless)');
    LEGEND_RATES(:,16) = strpad('d/dt y_to_f in component I_to (dimensionless)');
    LEGEND_RATES(:,17) = strpad('d/dt d in component I_Ca (dimensionless)');
    LEGEND_RATES(:,18) = strpad('d/dt f in component I_Ca (dimensionless)');
    LEGEND_RATES(:,19) = strpad('d/dt f_Ca_Bj in component I_Ca (dimensionless)');
    LEGEND_RATES(:,20) = strpad('d/dt f_Ca_Bsl in component I_Ca (dimensionless)');
    LEGEND_RATES(:,21) = strpad('d/dt Ry_Rr in component SR_Fluxes (mM)');
    LEGEND_RATES(:,22) = strpad('d/dt Ry_Ro in component SR_Fluxes (mM)');
    LEGEND_RATES(:,23) = strpad('d/dt Ry_Ri in component SR_Fluxes (mM)');
    LEGEND_RATES(:,26) = strpad('d/dt Na_Bj in component Na_Buffers (mM)');
    LEGEND_RATES(:,27) = strpad('d/dt Na_Bsl in component Na_Buffers (mM)');
    LEGEND_RATES(:,28) = strpad('d/dt Tn_CL in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,29) = strpad('d/dt Tn_CHc in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,30) = strpad('d/dt Tn_CHm in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,31) = strpad('d/dt CaM in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,32) = strpad('d/dt Myo_c in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,33) = strpad('d/dt Myo_m in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,34) = strpad('d/dt SRB in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,35) = strpad('d/dt SLL_j in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_RATES(:,36) = strpad('d/dt SLL_sl in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_RATES(:,37) = strpad('d/dt SLH_j in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_RATES(:,38) = strpad('d/dt SLH_sl in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_RATES(:,39) = strpad('d/dt Csqn_b in component SR_Ca_Concentrations (mM)');
    LEGEND_RATES(:,24) = strpad('d/dt Ca_sr in component SR_Ca_Concentrations (mM)');
    LEGEND_RATES(:,2) = strpad('d/dt Na_j in component Na_Concentrations (mM)');
    LEGEND_RATES(:,3) = strpad('d/dt Na_sl in component Na_Concentrations (mM)');
    LEGEND_RATES(:,12) = strpad('d/dt Na_i in component Na_Concentrations (mM)');
    LEGEND_RATES(:,4) = strpad('d/dt K_i in component K_Concentration (mM)');
    LEGEND_RATES(:,5) = strpad('d/dt Ca_j in component Ca_Concentrations (mM)');
    LEGEND_RATES(:,6) = strpad('d/dt Ca_sl in component Ca_Concentrations (mM)');
    LEGEND_RATES(:,25) = strpad('d/dt Ca_i in component Ca_Concentrations (mM)');
    LEGEND_RATES(:,1) = strpad('d/dt V_m in component membrane_potential (mV)');
    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) = -81.4552030512661;
    STATES(:,2) = 8.40537012592918;
    STATES(:,3) = 8.40491910001025;
    STATES(:,4) = 120;
    STATES(:,5) = 0.000175882395147342;
    STATES(:,6) = 0.000106779509977354;
    STATES(:,7) = 0.003793087414436;
    STATES(:,8) = 0.626221949492493;
    STATES(:,9) = 0.624553572490432;
    STATES(:,10) = 0.0210022533039071;
    STATES(:,11) = 0.00428016666258923;
    STATES(:,12) = 8.40513364344858;
    STATES(:,13) = 0.000440445885642567;
    STATES(:,14) = 0.785115828275182;
    STATES(:,15) = 0.000440438103758954;
    STATES(:,16) = 0.999995844038706;
    STATES(:,17) = 2.92407183949469e-6;
    STATES(:,18) = 0.995135796703515;
    STATES(:,19) = 0.0246760872105795;
    STATES(:,20) = 0.0152723084239416;
    STATES(:,21) = 0.890806040818203;
    STATES(:,22) = 7.40481128853622e-7;
    STATES(:,23) = 9.07666168960848e-8;
    STATES(:,24) = 0.554760499828172;
    STATES(:,25) = 8.72509677797499e-5;
    STATES(:,26) = 3.4543773303328;
    STATES(:,27) = 0.753740951477775;
    STATES(:,28) = 0.00893455096919132;
    STATES(:,29) = 0.117412025936615;
    STATES(:,30) = 0.0106160166692932;
    STATES(:,31) = 0.000295573424135051;
    STATES(:,32) = 0.00192322252438022;
    STATES(:,33) = 0.137560495022823;
    STATES(:,34) = 0.00217360235649355;
    STATES(:,35) = 0.00740524521680039;
    STATES(:,36) = 0.00990339304377132;
    STATES(:,37) = 0.0735890020284214;
    STATES(:,38) = 0.114583623436917;
    STATES(:,39) = 1.19723145924432;
    CONSTANTS(:,1) = 10;
    CONSTANTS(:,2) = 1000;
    CONSTANTS(:,3) = 5;
    CONSTANTS(:,4) = 9.5;
    CONSTANTS(:,5) = 1.00000;
    CONSTANTS(:,6) = 8314.00;
    CONSTANTS(:,7) = 1.38100e-10;
    CONSTANTS(:,8) = 100.000;
    CONSTANTS(:,9) = 0.160000;
    CONSTANTS(:,10) = 0.450000;
    CONSTANTS(:,11) = 0.500000;
    CONSTANTS(:,12) = 1.64000e-06;
    CONSTANTS(:,13) = 1.22000e-06;
    CONSTANTS(:,14) = 1.09000e-05;
    CONSTANTS(:,15) = 1.79000e-05;
    CONSTANTS(:,16) = 8.24130e-13;
    CONSTANTS(:,17) = 3.72430e-12;
    CONSTANTS(:,18) = 1.83130e-14;
    CONSTANTS(:,19) = 1.63860e-12;
    CONSTANTS(:,20) = 0.110000;
    CONSTANTS(:,21) = 0.900000;
    CONSTANTS(:,22) = 5.40000;
    CONSTANTS(:,23) = 140.000;
    CONSTANTS(:,24) = 1.80000;
    CONSTANTS(:,25) = 1.00000;
    CONSTANTS(:,26) = 23.0000;
    CONSTANTS(:,27) = 0.000597000;
    CONSTANTS(:,28) =  1.00000.*1.80000;
    CONSTANTS(:,29) = 11.0000;
    CONSTANTS(:,30) = 1.50000;
    CONSTANTS(:,31) = 1.63000;
    CONSTANTS(:,32) = 1.39000;
    CONSTANTS(:,33) = 0.0183300;
    CONSTANTS(:,34) =  2.00000.*0.00100000;
    CONSTANTS(:,35) =  0.500000.*0.109625;
    CONSTANTS(:,36) =  1.00000.*0.00900000;
    CONSTANTS(:,37) = 0.100000;
    CONSTANTS(:,38) =  0.500000.*1.50000e-08;
    CONSTANTS(:,39) =  0.500000.*0.000540000;
    CONSTANTS(:,40) =  0.500000.*2.70000e-07;
    CONSTANTS(:,41) = 1.80000;
    CONSTANTS(:,42) =  1.00000.*4.50000;
    CONSTANTS(:,43) = 0.00359000;
    CONSTANTS(:,44) = 1.30000;
    CONSTANTS(:,45) = 12.2900;
    CONSTANTS(:,46) = 87.5000;
    CONSTANTS(:,47) = 0.320000;
    CONSTANTS(:,48) = 0.270000;
    CONSTANTS(:,49) = 0.000150000;
    CONSTANTS(:,50) = 1.57000;
    CONSTANTS(:,51) = 0.0673000;
    CONSTANTS(:,52) = 0.000500000;
    CONSTANTS(:,53) = 0.000551300;
    CONSTANTS(:,54) = 2.35000;
    CONSTANTS(:,55) = 2.60000;
    CONSTANTS(:,56) = 0.00531140;
    CONSTANTS(:,57) = 0.000246000;
    CONSTANTS(:,58) = 1.70000;
    CONSTANTS(:,59) = 1.78700;
    CONSTANTS(:,60) = 25.0000;
    CONSTANTS(:,61) = 10.0000;
    CONSTANTS(:,62) = 0.0600000;
    CONSTANTS(:,63) = 0.00500000;
    CONSTANTS(:,64) = 0.450000;
    CONSTANTS(:,65) = 7.56100;
    CONSTANTS(:,66) = 1.65000;
    CONSTANTS(:,67) = 0.00100000;
    CONSTANTS(:,68) = 0.000100000;
    CONSTANTS(:,69) = 0.0700000;
    CONSTANTS(:,70) = 0.0196000;
    CONSTANTS(:,71) = 32.7000;
    CONSTANTS(:,72) = 0.140000;
    CONSTANTS(:,73) = 3.20000e-05;
    CONSTANTS(:,74) = 2.37000;
    CONSTANTS(:,75) = 0.00333000;
    CONSTANTS(:,76) = 0.00300000;
    CONSTANTS(:,77) = 0.0240000;
    CONSTANTS(:,78) = 0.238000;
    CONSTANTS(:,79) = 34.0000;
    CONSTANTS(:,80) = 0.140000;
    CONSTANTS(:,81) = 0.000460000;
    CONSTANTS(:,82) = 13.8000;
    CONSTANTS(:,83) = 5.70000e-05;
    CONSTANTS(:,84) = 0.0157000;
    CONSTANTS(:,85) =  19.0000.*0.000900000;
    CONSTANTS(:,86) = 0.0600000;
    CONSTANTS(:,87) = 100.000;
    CONSTANTS(:,88) = 1.30000;
    CONSTANTS(:,89) = 100.000;
    CONSTANTS(:,90) = 0.0300000;
    CONSTANTS(:,91) = 100.000;
    CONSTANTS(:,92) = 65.0000;
    CONSTANTS(:,93) = 100.000;
    CONSTANTS(:,94) = 0.00350000;
    CONSTANTS(:,95) = 0.00350000;
    CONSTANTS(:,96) = 0.00000;
    CONSTANTS(:,97) = 0.00000;
    CONSTANTS(:,98) = 15.0000;
    CONSTANTS(:,99) = 1.00000;
    CONSTANTS(:,127) = 0.00000;
    CONSTANTS(:,100) = 96485.0;
    CONSTANTS(:,101) = 10.2500;
    CONSTANTS(:,102) = 0.0150000;
    CONSTANTS(:,103) = 1.00000 - CONSTANTS(:,20);
    CONSTANTS(:,104) = 1.00000 - CONSTANTS(:,21);
    CONSTANTS(:,105) = (exp(CONSTANTS(:,23)./67.3000) - 1.00000)./7.00000;
    CONSTANTS(:,106) =  0.0350000.*power((CONSTANTS(:,22)./5.40000), 1.0 ./ 2);
    CONSTANTS(:,107) = piecewise({CONSTANTS(:,5)==1.00000,  1.00000.*0.130000.*0.120000 },  0.130000.*0.300000.*0.964000);
    CONSTANTS(:,108) = piecewise({CONSTANTS(:,5)==1.00000,  1.00000.*0.130000.*0.880000 },  0.130000.*0.300000.*0.0360000);
    CONSTANTS(:,109) = 0.500000;
    CONSTANTS(:,110) = 310.000;
    CONSTANTS(:,111) =   pi.*power(CONSTANTS(:,101), 2.00000).*CONSTANTS(:,8).*1.00000e-15;
    CONSTANTS(:,112) =  20150.0.* pi.*2.00000.*CONSTANTS(:,9).*CONSTANTS(:,102);
    CONSTANTS(:,113) =   pi.*2.00000.*CONSTANTS(:,101).*CONSTANTS(:,8);
    CONSTANTS(:,114) = CONSTANTS(:,100)./( CONSTANTS(:,6).*CONSTANTS(:,110));
    CONSTANTS(:,115) = (CONSTANTS(:,110) - 310.000)./10.0000;
    CONSTANTS(:,116) =  0.650000.*CONSTANTS(:,111);
    CONSTANTS(:,117) =  0.0350000.*CONSTANTS(:,111);
    CONSTANTS(:,118) =  0.0200000.*CONSTANTS(:,111);
    CONSTANTS(:,119) =  0.0539000.*0.0100000.*CONSTANTS(:,111);
    CONSTANTS(:,120) = 15.0000;
    CONSTANTS(:,121) = 150.000;
    CONSTANTS(:,122) = ( 0.0374000.*CONSTANTS(:,116))./CONSTANTS(:,118);
    CONSTANTS(:,123) =  (( 0.00460000.*CONSTANTS(:,116))./CONSTANTS(:,119)).*0.100000;
    CONSTANTS(:,124) = ( 0.0134000.*CONSTANTS(:,116))./CONSTANTS(:,118);
    CONSTANTS(:,125) =  (( 0.00165000.*CONSTANTS(:,116))./CONSTANTS(:,119)).*0.100000;
    CONSTANTS(:,126) = ( 0.140000.*CONSTANTS(:,116))./CONSTANTS(:,117);
    CONSTANTS(:,127) =  (1.00000./CONSTANTS(:,114)).*log(CONSTANTS(:,120)./CONSTANTS(:,121));
    if (isempty(STATES)), warning('Initial values for states not set');, end
end

function [RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS)
    global algebraicVariableCount;
    statesSize = size(STATES);
    statesColumnCount = statesSize(2);
    if ( statesColumnCount == 1)
        STATES = STATES';
        ALGEBRAIC = zeros(1, algebraicVariableCount);
    else
        statesRowCount = statesSize(1);
        ALGEBRAIC = zeros(statesRowCount, algebraicVariableCount);
        RATES = zeros(statesRowCount, statesColumnCount);
    end
    RATES(:,4) = CONSTANTS(:,127);
    RATES(:,19) =  (( 1.70000.*STATES(:,5))./1.00000).*(1.00000 - STATES(:,19)) -  0.0119000.*STATES(:,19);
    RATES(:,20) =  (( 1.70000.*STATES(:,6))./1.00000).*(1.00000 - STATES(:,20)) -  0.0119000.*STATES(:,20);
    RATES(:,28) =  CONSTANTS(:,71).*STATES(:,25).*(CONSTANTS(:,69) - STATES(:,28)) -  CONSTANTS(:,70).*STATES(:,28);
    RATES(:,29) =  CONSTANTS(:,74).*STATES(:,25).*((CONSTANTS(:,72) - STATES(:,29)) - STATES(:,30)) -  CONSTANTS(:,73).*STATES(:,29);
    RATES(:,30) =  CONSTANTS(:,76).*CONSTANTS(:,25).*((CONSTANTS(:,72) - STATES(:,29)) - STATES(:,30)) -  CONSTANTS(:,75).*STATES(:,30);
    RATES(:,31) =  CONSTANTS(:,79).*STATES(:,25).*(CONSTANTS(:,77) - STATES(:,31)) -  CONSTANTS(:,78).*STATES(:,31);
    RATES(:,32) =  CONSTANTS(:,82).*STATES(:,25).*((CONSTANTS(:,80) - STATES(:,32)) - STATES(:,33)) -  CONSTANTS(:,81).*STATES(:,32);
    RATES(:,33) =  CONSTANTS(:,84).*CONSTANTS(:,25).*((CONSTANTS(:,80) - STATES(:,32)) - STATES(:,33)) -  CONSTANTS(:,83).*STATES(:,33);
    RATES(:,34) =  CONSTANTS(:,87).*STATES(:,25).*(CONSTANTS(:,85) - STATES(:,34)) -  CONSTANTS(:,86).*STATES(:,34);
    RATES(:,35) =  CONSTANTS(:,89).*STATES(:,5).*(CONSTANTS(:,123) - STATES(:,35)) -  CONSTANTS(:,88).*STATES(:,35);
    RATES(:,36) =  CONSTANTS(:,89).*STATES(:,6).*(CONSTANTS(:,122) - STATES(:,36)) -  CONSTANTS(:,88).*STATES(:,36);
    RATES(:,37) =  CONSTANTS(:,91).*STATES(:,5).*(CONSTANTS(:,125) - STATES(:,37)) -  CONSTANTS(:,90).*STATES(:,37);
    RATES(:,38) =  CONSTANTS(:,91).*STATES(:,6).*(CONSTANTS(:,124) - STATES(:,38)) -  CONSTANTS(:,90).*STATES(:,38);
    RATES(:,39) =  CONSTANTS(:,93).*STATES(:,24).*(CONSTANTS(:,126) - STATES(:,39)) -  CONSTANTS(:,92).*STATES(:,39);
    RATES(:,12) =  (CONSTANTS(:,19)./CONSTANTS(:,116)).*(STATES(:,3) - STATES(:,12));
    ALGEBRAIC(:,1) = 1.00000./power(1.00000+exp( - (56.8600+STATES(:,1))./9.03000), 2.00000);
    ALGEBRAIC(:,12) =  0.129200.*exp( - power((STATES(:,1)+45.7900)./15.5400, 2.00000))+ 0.0648700.*exp( - power((STATES(:,1) - 4.82300)./51.1200, 2.00000));
    RATES(:,7) = (ALGEBRAIC(:,1) - STATES(:,7))./ALGEBRAIC(:,12);
    ALGEBRAIC(:,4) = 1.00000./(1.00000+exp( - (STATES(:,1)+10.0000)./5.00000));
    ALGEBRAIC(:,15) = ( (550.000./(1.00000+exp(( - 22.0000 - STATES(:,1))./9.00000))).*6.00000)./(1.00000+exp((STATES(:,1) -  - 11.0000)./9.00000))+230.000./(1.00000+exp((STATES(:,1) -  - 40.0000)./20.0000));
    RATES(:,10) = (ALGEBRAIC(:,4) - STATES(:,10))./ALGEBRAIC(:,15);
    ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1)+3.80000)./14.2500));
    ALGEBRAIC(:,16) = 990.100./(1.00000+exp( - (STATES(:,1)+2.43600)./14.1200));
    RATES(:,11) = (ALGEBRAIC(:,5) - STATES(:,11))./ALGEBRAIC(:,16);
    ALGEBRAIC(:,6) = 1.00000./(1.00000+exp( - (STATES(:,1) - 19.0000)./13.0000));
    ALGEBRAIC(:,17) = 9.00000./(1.00000+exp((STATES(:,1)+3.00000)./15.0000))+0.500000;
    RATES(:,13) = (ALGEBRAIC(:,6) - STATES(:,13))./ALGEBRAIC(:,17);
    ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,1)+19.5000)./5.00000));
    ALGEBRAIC(:,18) = 800.000./(1.00000+exp((STATES(:,1)+60.0000)./10.0000))+30.0000;
    RATES(:,14) = (ALGEBRAIC(:,7) - STATES(:,14))./ALGEBRAIC(:,18);
    ALGEBRAIC(:,19) =  8.50000.*exp( - power((STATES(:,1)+45.0000)./50.0000, 2.00000))+0.500000;
    RATES(:,15) = (ALGEBRAIC(:,6) - STATES(:,15))./ALGEBRAIC(:,19);
    ALGEBRAIC(:,20) =  85.0000.*exp( - power(STATES(:,1)+40.0000, 2.00000)./220.000)+7.00000;
    RATES(:,16) = (ALGEBRAIC(:,7) - STATES(:,16))./ALGEBRAIC(:,20);
    ALGEBRAIC(:,9) = 1.00000./(1.00000+exp( - (STATES(:,1)+5.00000)./6.00000));
    ALGEBRAIC(:,21) = ( 1.00000.*ALGEBRAIC(:,9).*(1.00000 - exp( - (STATES(:,1)+5.00000)./6.00000)))./( 0.0350000.*(STATES(:,1)+5.00000));
    RATES(:,17) = (ALGEBRAIC(:,9) - STATES(:,17))./ALGEBRAIC(:,21);
    ALGEBRAIC(:,8) = 1.00000./(1.00000+exp((STATES(:,1)+35.0000)./9.00000))+0.600000./(1.00000+exp((50.0000 - STATES(:,1))./20.0000));
    ALGEBRAIC(:,22) = 1.00000./( 0.0197000.*exp( - power( 0.0337000.*(STATES(:,1)+14.5000), 2.00000))+0.0200000);
    RATES(:,18) = (ALGEBRAIC(:,8) - STATES(:,18))./ALGEBRAIC(:,22);
    ALGEBRAIC(:,11) = CONSTANTS(:,98) - (CONSTANTS(:,98) - CONSTANTS(:,99))./(1.00000+power(CONSTANTS(:,64)./STATES(:,24), 2.50000));
    ALGEBRAIC(:,24) = CONSTANTS(:,61)./ALGEBRAIC(:,11);
    ALGEBRAIC(:,28) =  CONSTANTS(:,109).*ALGEBRAIC(:,11);
    RATES(:,22) = ( ALGEBRAIC(:,24).*power(STATES(:,5), 2.00000).*STATES(:,21) -  CONSTANTS(:,62).*STATES(:,22)) - ( ALGEBRAIC(:,28).*STATES(:,5).*STATES(:,22) -  CONSTANTS(:,63).*STATES(:,23));
    ALGEBRAIC(:,2) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 },  0.0570000.*exp( - (STATES(:,1)+80.0000)./6.80000));
    ALGEBRAIC(:,13) = piecewise({STATES(:,1)>= - 40.0000, 0.770000./( 0.130000.*(1.00000+exp( - (STATES(:,1)+10.6600)./11.1000))) },  2.70000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.348500.*STATES(:,1)));
    ALGEBRAIC(:,25) = 1.00000./(ALGEBRAIC(:,2)+ALGEBRAIC(:,13));
    ALGEBRAIC(:,29) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000);
    RATES(:,8) = (ALGEBRAIC(:,29) - STATES(:,8))./ALGEBRAIC(:,25);
    ALGEBRAIC(:,3) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 }, ( (  - 25428.0.*exp( 0.244400.*STATES(:,1)) -  6.94800e-06.*exp(  - 0.0439100.*STATES(:,1))).*(STATES(:,1)+37.7800))./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300))));
    ALGEBRAIC(:,14) = piecewise({STATES(:,1)>= - 40.0000, ( 0.600000.*exp( 0.0570000.*STATES(:,1)))./(1.00000+exp(  - 0.100000.*(STATES(:,1)+32.0000))) }, ( 0.0242400.*exp(  - 0.0105200.*STATES(:,1)))./(1.00000+exp(  - 0.137800.*(STATES(:,1)+40.1400))));
    ALGEBRAIC(:,26) = 1.00000./(ALGEBRAIC(:,3)+ALGEBRAIC(:,14));
    ALGEBRAIC(:,30) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000);
    RATES(:,9) = (ALGEBRAIC(:,30) - STATES(:,9))./ALGEBRAIC(:,26);
    ALGEBRAIC(:,32) = ((1.00000 - STATES(:,21)) - STATES(:,22)) - STATES(:,23);
    RATES(:,21) = ( CONSTANTS(:,63).*ALGEBRAIC(:,32) -  ALGEBRAIC(:,28).*STATES(:,5).*STATES(:,21)) - ( ALGEBRAIC(:,24).*power(STATES(:,5), 2.00000).*STATES(:,21) -  CONSTANTS(:,62).*STATES(:,22));
    RATES(:,23) = ( ALGEBRAIC(:,28).*STATES(:,5).*STATES(:,22) -  CONSTANTS(:,63).*STATES(:,23)) - ( CONSTANTS(:,62).*STATES(:,23) -  ALGEBRAIC(:,24).*power(STATES(:,5), 2.00000).*ALGEBRAIC(:,32));
    ALGEBRAIC(:,97) =  (( CONSTANTS(:,60).*STATES(:,22))./1.00000).*(STATES(:,24) - STATES(:,5));
    ALGEBRAIC(:,98) = ( power(CONSTANTS(:,55), CONSTANTS(:,115)).*CONSTANTS(:,56).*(power(STATES(:,25)./CONSTANTS(:,57), CONSTANTS(:,59)) - power(STATES(:,24)./CONSTANTS(:,58), CONSTANTS(:,59))))./(1.00000+power(STATES(:,25)./CONSTANTS(:,57), CONSTANTS(:,59))+power(STATES(:,24)./CONSTANTS(:,58), CONSTANTS(:,59)));
    ALGEBRAIC(:,99) =  5.34800e-06.*(STATES(:,24) - STATES(:,5));
    RATES(:,24) = (ALGEBRAIC(:,98) - (( ALGEBRAIC(:,99).*CONSTANTS(:,116))./CONSTANTS(:,117)+ALGEBRAIC(:,97))) - ( CONSTANTS(:,93).*STATES(:,24).*(CONSTANTS(:,126) - STATES(:,39)) -  CONSTANTS(:,92).*STATES(:,39));
    ALGEBRAIC(:,100) = ((((((((((( CONSTANTS(:,71).*STATES(:,25).*(CONSTANTS(:,69) - STATES(:,28)) -  CONSTANTS(:,70).*STATES(:,28))+ CONSTANTS(:,74).*STATES(:,25).*((CONSTANTS(:,72) - STATES(:,29)) - STATES(:,30))) -  CONSTANTS(:,73).*STATES(:,29))+ CONSTANTS(:,76).*CONSTANTS(:,25).*((CONSTANTS(:,72) - STATES(:,29)) - STATES(:,30))) -  CONSTANTS(:,75).*STATES(:,30))+ CONSTANTS(:,79).*STATES(:,25).*(CONSTANTS(:,77) - STATES(:,31))) -  CONSTANTS(:,78).*STATES(:,31))+ CONSTANTS(:,82).*STATES(:,25).*((CONSTANTS(:,80) - STATES(:,32)) - STATES(:,33))) -  CONSTANTS(:,81).*STATES(:,32))+ CONSTANTS(:,84).*CONSTANTS(:,25).*((CONSTANTS(:,80) - STATES(:,32)) - STATES(:,33))) -  CONSTANTS(:,83).*STATES(:,33))+( CONSTANTS(:,87).*STATES(:,25).*(CONSTANTS(:,85) - STATES(:,34)) -  CONSTANTS(:,86).*STATES(:,34));
    RATES(:,25) = ((  - ALGEBRAIC(:,98).*CONSTANTS(:,117))./CONSTANTS(:,116) - ALGEBRAIC(:,100))+ (CONSTANTS(:,17)./CONSTANTS(:,116)).*(STATES(:,6) - STATES(:,25));
    ALGEBRAIC(:,101) =  CONSTANTS(:,68).*STATES(:,2).*(CONSTANTS(:,65) - STATES(:,26)) -  CONSTANTS(:,67).*STATES(:,26);
    RATES(:,26) = ALGEBRAIC(:,101);
    ALGEBRAIC(:,102) =  CONSTANTS(:,68).*STATES(:,3).*(CONSTANTS(:,66) - STATES(:,27)) -  CONSTANTS(:,67).*STATES(:,27);
    RATES(:,27) = ALGEBRAIC(:,102);
    ALGEBRAIC(:,10) =  (1.00000./CONSTANTS(:,114)).*log(CONSTANTS(:,23)./STATES(:,2));
    ALGEBRAIC(:,34) =  CONSTANTS(:,20).*CONSTANTS(:,26).*power(STATES(:,7), 3.00000).*STATES(:,8).*STATES(:,9).*(STATES(:,1) - ALGEBRAIC(:,10));
    ALGEBRAIC(:,37) =  CONSTANTS(:,20).*CONSTANTS(:,27).*(STATES(:,1) - ALGEBRAIC(:,10));
    ALGEBRAIC(:,40) = 1.00000./(1.00000+ 0.124500.*exp(  - 0.100000.*STATES(:,1).*CONSTANTS(:,114))+ 0.0365000.*CONSTANTS(:,105).*exp(  - STATES(:,1).*CONSTANTS(:,114)));
    ALGEBRAIC(:,41) = (( CONSTANTS(:,20).*CONSTANTS(:,28).*ALGEBRAIC(:,40).*CONSTANTS(:,22))./(1.00000+power(CONSTANTS(:,29)./STATES(:,2), 4.00000)))./(CONSTANTS(:,22)+CONSTANTS(:,30));
    ALGEBRAIC(:,68) = ( CONSTANTS(:,38).*STATES(:,1).*CONSTANTS(:,100).*CONSTANTS(:,114).*( 0.750000.*STATES(:,2).*exp( STATES(:,1).*CONSTANTS(:,114)) -  0.750000.*CONSTANTS(:,23)))./(exp( STATES(:,1).*CONSTANTS(:,114)) - 1.00000);
    ALGEBRAIC(:,74) =  CONSTANTS(:,21).*ALGEBRAIC(:,68).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,19))+CONSTANTS(:,97)).*power(CONSTANTS(:,41), CONSTANTS(:,115)).*0.450000.*1.00000;
    ALGEBRAIC(:,77) = 1.00000./(1.00000+power(CONSTANTS(:,49)./STATES(:,5), 2.00000));
    ALGEBRAIC(:,80) =  exp( CONSTANTS(:,48).*STATES(:,1).*CONSTANTS(:,114)).*power(STATES(:,2), 3.00000).*CONSTANTS(:,24);
    ALGEBRAIC(:,82) =  exp( (CONSTANTS(:,48) - 1.00000).*STATES(:,1).*CONSTANTS(:,114)).*power(CONSTANTS(:,23), 3.00000).*STATES(:,5);
    ALGEBRAIC(:,83) =  CONSTANTS(:,43).*power(CONSTANTS(:,23), 3.00000).*(1.00000+power(STATES(:,2)./CONSTANTS(:,45), 3.00000))+ power(CONSTANTS(:,46), 3.00000).*STATES(:,5).*(1.00000+STATES(:,5)./CONSTANTS(:,43))+ CONSTANTS(:,44).*power(STATES(:,2), 3.00000)+ power(STATES(:,2), 3.00000).*CONSTANTS(:,24)+ power(CONSTANTS(:,23), 3.00000).*STATES(:,5);
    ALGEBRAIC(:,86) = (( CONSTANTS(:,20).*CONSTANTS(:,42).*power(CONSTANTS(:,50), CONSTANTS(:,115)).*ALGEBRAIC(:,77).*(ALGEBRAIC(:,80) - ALGEBRAIC(:,82)))./ALGEBRAIC(:,83))./(1.00000+ CONSTANTS(:,47).*exp( (CONSTANTS(:,48) - 1.00000).*STATES(:,1).*CONSTANTS(:,114)));
    ALGEBRAIC(:,105) = ALGEBRAIC(:,34)+ALGEBRAIC(:,37)+ 3.00000.*ALGEBRAIC(:,86)+ 3.00000.*ALGEBRAIC(:,41)+ALGEBRAIC(:,74);
    RATES(:,2) = ((  - ALGEBRAIC(:,105).*CONSTANTS(:,7))./( CONSTANTS(:,119).*CONSTANTS(:,100))+ (CONSTANTS(:,18)./CONSTANTS(:,119)).*(STATES(:,3) - STATES(:,2))) - ALGEBRAIC(:,101);
    ALGEBRAIC(:,23) =  (1.00000./CONSTANTS(:,114)).*log(CONSTANTS(:,23)./STATES(:,3));
    ALGEBRAIC(:,35) =  CONSTANTS(:,103).*CONSTANTS(:,26).*power(STATES(:,7), 3.00000).*STATES(:,8).*STATES(:,9).*(STATES(:,1) - ALGEBRAIC(:,23));
    ALGEBRAIC(:,38) =  CONSTANTS(:,103).*CONSTANTS(:,27).*(STATES(:,1) - ALGEBRAIC(:,23));
    ALGEBRAIC(:,42) = (( CONSTANTS(:,103).*CONSTANTS(:,28).*ALGEBRAIC(:,40).*CONSTANTS(:,22))./(1.00000+power(CONSTANTS(:,29)./STATES(:,3), 4.00000)))./(CONSTANTS(:,22)+CONSTANTS(:,30));
    ALGEBRAIC(:,69) = ( CONSTANTS(:,38).*STATES(:,1).*CONSTANTS(:,100).*CONSTANTS(:,114).*( 0.750000.*STATES(:,3).*exp( STATES(:,1).*CONSTANTS(:,114)) -  0.750000.*CONSTANTS(:,23)))./(exp( STATES(:,1).*CONSTANTS(:,114)) - 1.00000);
    ALGEBRAIC(:,75) =  CONSTANTS(:,104).*ALGEBRAIC(:,69).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,20))+CONSTANTS(:,96)).*power(CONSTANTS(:,41), CONSTANTS(:,115)).*0.450000.*1.00000;
    ALGEBRAIC(:,79) = 1.00000./(1.00000+power(CONSTANTS(:,49)./STATES(:,6), 2.00000));
    ALGEBRAIC(:,81) =  exp( CONSTANTS(:,48).*STATES(:,1).*CONSTANTS(:,114)).*power(STATES(:,3), 3.00000).*CONSTANTS(:,24);
    ALGEBRAIC(:,84) =  exp( (CONSTANTS(:,48) - 1.00000).*STATES(:,1).*CONSTANTS(:,114)).*power(CONSTANTS(:,23), 3.00000).*STATES(:,6);
    ALGEBRAIC(:,85) =  CONSTANTS(:,43).*power(CONSTANTS(:,23), 3.00000).*(1.00000+power(STATES(:,3)./CONSTANTS(:,45), 3.00000))+ power(CONSTANTS(:,46), 3.00000).*STATES(:,6).*(1.00000+STATES(:,6)./CONSTANTS(:,43))+ CONSTANTS(:,44).*power(STATES(:,3), 3.00000)+ power(STATES(:,3), 3.00000).*CONSTANTS(:,24)+ power(CONSTANTS(:,23), 3.00000).*STATES(:,6);
    ALGEBRAIC(:,87) = (( CONSTANTS(:,103).*CONSTANTS(:,42).*power(CONSTANTS(:,50), CONSTANTS(:,115)).*ALGEBRAIC(:,79).*(ALGEBRAIC(:,81) - ALGEBRAIC(:,84)))./ALGEBRAIC(:,85))./(1.00000+ CONSTANTS(:,47).*exp( (CONSTANTS(:,48) - 1.00000).*STATES(:,1).*CONSTANTS(:,114)));
    ALGEBRAIC(:,106) = ALGEBRAIC(:,35)+ALGEBRAIC(:,38)+ 3.00000.*ALGEBRAIC(:,87)+ 3.00000.*ALGEBRAIC(:,42)+ALGEBRAIC(:,75);
    RATES(:,3) = ((  - ALGEBRAIC(:,106).*CONSTANTS(:,7))./( CONSTANTS(:,118).*CONSTANTS(:,100))+ (CONSTANTS(:,18)./CONSTANTS(:,118)).*(STATES(:,2) - STATES(:,3))+ (CONSTANTS(:,19)./CONSTANTS(:,118)).*(STATES(:,12) - STATES(:,3))) - ALGEBRAIC(:,102);
    ALGEBRAIC(:,103) = ( CONSTANTS(:,89).*STATES(:,5).*(CONSTANTS(:,123) - STATES(:,35)) -  CONSTANTS(:,88).*STATES(:,35))+( CONSTANTS(:,91).*STATES(:,5).*(CONSTANTS(:,125) - STATES(:,37)) -  CONSTANTS(:,90).*STATES(:,37));
    ALGEBRAIC(:,65) = ( CONSTANTS(:,39).*4.00000.*STATES(:,1).*CONSTANTS(:,100).*CONSTANTS(:,114).*( 0.341000.*STATES(:,5).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,114)) -  0.341000.*CONSTANTS(:,24)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,114)) - 1.00000);
    ALGEBRAIC(:,70) =  CONSTANTS(:,21).*ALGEBRAIC(:,65).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,19))+CONSTANTS(:,97)).*power(CONSTANTS(:,41), CONSTANTS(:,115)).*0.450000.*1.00000;
    ALGEBRAIC(:,90) = ( CONSTANTS(:,20).*power(CONSTANTS(:,54), CONSTANTS(:,115)).*CONSTANTS(:,51).*power(STATES(:,5), 1.60000))./(power(CONSTANTS(:,52), 1.60000)+power(STATES(:,5), 1.60000));
    ALGEBRAIC(:,31) =  ((1.00000./CONSTANTS(:,114))./2.00000).*log(CONSTANTS(:,24)./STATES(:,5));
    ALGEBRAIC(:,94) =  CONSTANTS(:,20).*CONSTANTS(:,53).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,108) = (ALGEBRAIC(:,70)+ALGEBRAIC(:,94)+ALGEBRAIC(:,90)) -  2.00000.*ALGEBRAIC(:,86);
    RATES(:,5) = (((  - ALGEBRAIC(:,108).*CONSTANTS(:,7))./( CONSTANTS(:,119).*2.00000.*CONSTANTS(:,100))+ (CONSTANTS(:,16)./CONSTANTS(:,119)).*(STATES(:,6) - STATES(:,5))) - ALGEBRAIC(:,103))+( ALGEBRAIC(:,97).*CONSTANTS(:,117))./CONSTANTS(:,119)+( ALGEBRAIC(:,99).*CONSTANTS(:,116))./CONSTANTS(:,119);
    ALGEBRAIC(:,104) = ( CONSTANTS(:,89).*STATES(:,6).*(CONSTANTS(:,122) - STATES(:,36)) -  CONSTANTS(:,88).*STATES(:,36))+( CONSTANTS(:,91).*STATES(:,6).*(CONSTANTS(:,124) - STATES(:,38)) -  CONSTANTS(:,90).*STATES(:,38));
    ALGEBRAIC(:,66) = ( CONSTANTS(:,39).*4.00000.*STATES(:,1).*CONSTANTS(:,100).*CONSTANTS(:,114).*( 0.341000.*STATES(:,6).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,114)) -  0.341000.*CONSTANTS(:,24)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,114)) - 1.00000);
    ALGEBRAIC(:,71) =  CONSTANTS(:,104).*ALGEBRAIC(:,66).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,20))+CONSTANTS(:,96)).*power(CONSTANTS(:,41), CONSTANTS(:,115)).*0.450000.*1.00000;
    ALGEBRAIC(:,92) = ( CONSTANTS(:,103).*power(CONSTANTS(:,54), CONSTANTS(:,115)).*CONSTANTS(:,51).*power(STATES(:,6), 1.60000))./(power(CONSTANTS(:,52), 1.60000)+power(STATES(:,6), 1.60000));
    ALGEBRAIC(:,33) =  ((1.00000./CONSTANTS(:,114))./2.00000).*log(CONSTANTS(:,24)./STATES(:,6));
    ALGEBRAIC(:,95) =  CONSTANTS(:,103).*CONSTANTS(:,53).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,109) = (ALGEBRAIC(:,71)+ALGEBRAIC(:,95)+ALGEBRAIC(:,92)) -  2.00000.*ALGEBRAIC(:,87);
    RATES(:,6) = ((  - ALGEBRAIC(:,109).*CONSTANTS(:,7))./( CONSTANTS(:,118).*2.00000.*CONSTANTS(:,100))+ (CONSTANTS(:,16)./CONSTANTS(:,118)).*(STATES(:,5) - STATES(:,6))+ (CONSTANTS(:,17)./CONSTANTS(:,118)).*(STATES(:,25) - STATES(:,6))) - ALGEBRAIC(:,104);
    ALGEBRAIC(:,43) = ALGEBRAIC(:,41)+ALGEBRAIC(:,42);
    ALGEBRAIC(:,27) =  (1.00000./CONSTANTS(:,114)).*log(CONSTANTS(:,22)./STATES(:,4));
    ALGEBRAIC(:,44) = 1.00000./(1.00000+exp((STATES(:,1)+74.0000)./24.0000));
    ALGEBRAIC(:,45) =  CONSTANTS(:,106).*STATES(:,10).*ALGEBRAIC(:,44).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,46) = 1.00000./(1.00000+exp(7.48800 - STATES(:,1)./5.98000));
    ALGEBRAIC(:,47) =  CONSTANTS(:,20).*CONSTANTS(:,34).*ALGEBRAIC(:,46).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,48) =  CONSTANTS(:,103).*CONSTANTS(:,34).*ALGEBRAIC(:,46).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,49) = ALGEBRAIC(:,47)+ALGEBRAIC(:,48);
    ALGEBRAIC(:,50) =  (1.00000./CONSTANTS(:,114)).*log((CONSTANTS(:,22)+ CONSTANTS(:,33).*CONSTANTS(:,23))./(STATES(:,4)+ CONSTANTS(:,33).*STATES(:,12)));
    ALGEBRAIC(:,51) =  CONSTANTS(:,20).*CONSTANTS(:,94).*power(STATES(:,11), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,50));
    ALGEBRAIC(:,52) =  CONSTANTS(:,103).*CONSTANTS(:,95).*power(STATES(:,11), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,50));
    ALGEBRAIC(:,53) = ALGEBRAIC(:,51)+ALGEBRAIC(:,52);
    ALGEBRAIC(:,54) =  CONSTANTS(:,107).*STATES(:,13).*STATES(:,14).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,55) =  CONSTANTS(:,108).*STATES(:,15).*STATES(:,16).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,56) = ALGEBRAIC(:,54)+ALGEBRAIC(:,55);
    ALGEBRAIC(:,57) = 1.02000./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,27)) - 59.2150)));
    ALGEBRAIC(:,58) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1)+5.47600) - ALGEBRAIC(:,27)))+exp( 0.0617500.*((STATES(:,1) - ALGEBRAIC(:,27)) - 594.310)))./(1.00000+exp(  - 0.514300.*((STATES(:,1) - ALGEBRAIC(:,27))+4.75300)));
    ALGEBRAIC(:,59) = ALGEBRAIC(:,57)./(ALGEBRAIC(:,57)+ALGEBRAIC(:,58));
    ALGEBRAIC(:,60) =  1.00000.*0.350000.*power((CONSTANTS(:,22)./5.40000), 1.0 ./ 2).*ALGEBRAIC(:,59).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,67) = ( CONSTANTS(:,40).*STATES(:,1).*CONSTANTS(:,100).*CONSTANTS(:,114).*( 0.750000.*STATES(:,4).*exp( STATES(:,1).*CONSTANTS(:,114)) -  0.750000.*CONSTANTS(:,22)))./(exp( STATES(:,1).*CONSTANTS(:,114)) - 1.00000);
    ALGEBRAIC(:,73) =  ALGEBRAIC(:,67).*STATES(:,17).*STATES(:,18).*( CONSTANTS(:,21).*(CONSTANTS(:,97)+(1.00000 - STATES(:,19)))+ CONSTANTS(:,104).*(CONSTANTS(:,96)+(1.00000 - STATES(:,20)))).*power(CONSTANTS(:,41), CONSTANTS(:,115)).*0.450000.*1.00000;
    ALGEBRAIC(:,107) = ((ALGEBRAIC(:,56)+ALGEBRAIC(:,45)+ALGEBRAIC(:,53)+ALGEBRAIC(:,60)) -  2.00000.*ALGEBRAIC(:,43))+ALGEBRAIC(:,73)+ALGEBRAIC(:,49);
    ALGEBRAIC(:,111) = ALGEBRAIC(:,105)+ALGEBRAIC(:,106);
    ALGEBRAIC(:,61) =  (( CONSTANTS(:,20).*CONSTANTS(:,35))./(1.00000+CONSTANTS(:,37)./STATES(:,5))).*(STATES(:,1) - CONSTANTS(:,127));
    ALGEBRAIC(:,62) =  (( CONSTANTS(:,103).*CONSTANTS(:,35))./(1.00000+CONSTANTS(:,37)./STATES(:,6))).*(STATES(:,1) - CONSTANTS(:,127));
    ALGEBRAIC(:,63) = ALGEBRAIC(:,61)+ALGEBRAIC(:,62);
    ALGEBRAIC(:,64) =  CONSTANTS(:,36).*(STATES(:,1) - CONSTANTS(:,127));
    ALGEBRAIC(:,112) = ALGEBRAIC(:,63)+ALGEBRAIC(:,64);
    ALGEBRAIC(:,113) = ALGEBRAIC(:,108)+ALGEBRAIC(:,109);
    ALGEBRAIC(:,114) = ALGEBRAIC(:,111)+ALGEBRAIC(:,112)+ALGEBRAIC(:,113)+ALGEBRAIC(:,107);
    ALGEBRAIC(:,110) = 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(:,114)+ALGEBRAIC(:,110));
   RATES = RATES';
end

% Calculate algebraic variables
function ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI)
    ALGEBRAIC(:,1) = 1.00000./power(1.00000+exp( - (56.8600+STATES(:,1))./9.03000), 2.00000);
    ALGEBRAIC(:,12) =  0.129200.*exp( - power((STATES(:,1)+45.7900)./15.5400, 2.00000))+ 0.0648700.*exp( - power((STATES(:,1) - 4.82300)./51.1200, 2.00000));
    ALGEBRAIC(:,4) = 1.00000./(1.00000+exp( - (STATES(:,1)+10.0000)./5.00000));
    ALGEBRAIC(:,15) = ( (550.000./(1.00000+exp(( - 22.0000 - STATES(:,1))./9.00000))).*6.00000)./(1.00000+exp((STATES(:,1) -  - 11.0000)./9.00000))+230.000./(1.00000+exp((STATES(:,1) -  - 40.0000)./20.0000));
    ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1)+3.80000)./14.2500));
    ALGEBRAIC(:,16) = 990.100./(1.00000+exp( - (STATES(:,1)+2.43600)./14.1200));
    ALGEBRAIC(:,6) = 1.00000./(1.00000+exp( - (STATES(:,1) - 19.0000)./13.0000));
    ALGEBRAIC(:,17) = 9.00000./(1.00000+exp((STATES(:,1)+3.00000)./15.0000))+0.500000;
    ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,1)+19.5000)./5.00000));
    ALGEBRAIC(:,18) = 800.000./(1.00000+exp((STATES(:,1)+60.0000)./10.0000))+30.0000;
    ALGEBRAIC(:,19) =  8.50000.*exp( - power((STATES(:,1)+45.0000)./50.0000, 2.00000))+0.500000;
    ALGEBRAIC(:,20) =  85.0000.*exp( - power(STATES(:,1)+40.0000, 2.00000)./220.000)+7.00000;
    ALGEBRAIC(:,9) = 1.00000./(1.00000+exp( - (STATES(:,1)+5.00000)./6.00000));
    ALGEBRAIC(:,21) = ( 1.00000.*ALGEBRAIC(:,9).*(1.00000 - exp( - (STATES(:,1)+5.00000)./6.00000)))./( 0.0350000.*(STATES(:,1)+5.00000));
    ALGEBRAIC(:,8) = 1.00000./(1.00000+exp((STATES(:,1)+35.0000)./9.00000))+0.600000./(1.00000+exp((50.0000 - STATES(:,1))./20.0000));
    ALGEBRAIC(:,22) = 1.00000./( 0.0197000.*exp( - power( 0.0337000.*(STATES(:,1)+14.5000), 2.00000))+0.0200000);
    ALGEBRAIC(:,11) = CONSTANTS(:,98) - (CONSTANTS(:,98) - CONSTANTS(:,99))./(1.00000+power(CONSTANTS(:,64)./STATES(:,24), 2.50000));
    ALGEBRAIC(:,24) = CONSTANTS(:,61)./ALGEBRAIC(:,11);
    ALGEBRAIC(:,28) =  CONSTANTS(:,109).*ALGEBRAIC(:,11);
    ALGEBRAIC(:,2) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 },  0.0570000.*exp( - (STATES(:,1)+80.0000)./6.80000));
    ALGEBRAIC(:,13) = piecewise({STATES(:,1)>= - 40.0000, 0.770000./( 0.130000.*(1.00000+exp( - (STATES(:,1)+10.6600)./11.1000))) },  2.70000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.348500.*STATES(:,1)));
    ALGEBRAIC(:,25) = 1.00000./(ALGEBRAIC(:,2)+ALGEBRAIC(:,13));
    ALGEBRAIC(:,29) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000);
    ALGEBRAIC(:,3) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 }, ( (  - 25428.0.*exp( 0.244400.*STATES(:,1)) -  6.94800e-06.*exp(  - 0.0439100.*STATES(:,1))).*(STATES(:,1)+37.7800))./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300))));
    ALGEBRAIC(:,14) = piecewise({STATES(:,1)>= - 40.0000, ( 0.600000.*exp( 0.0570000.*STATES(:,1)))./(1.00000+exp(  - 0.100000.*(STATES(:,1)+32.0000))) }, ( 0.0242400.*exp(  - 0.0105200.*STATES(:,1)))./(1.00000+exp(  - 0.137800.*(STATES(:,1)+40.1400))));
    ALGEBRAIC(:,26) = 1.00000./(ALGEBRAIC(:,3)+ALGEBRAIC(:,14));
    ALGEBRAIC(:,30) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000);
    ALGEBRAIC(:,32) = ((1.00000 - STATES(:,21)) - STATES(:,22)) - STATES(:,23);
    ALGEBRAIC(:,97) =  (( CONSTANTS(:,60).*STATES(:,22))./1.00000).*(STATES(:,24) - STATES(:,5));
    ALGEBRAIC(:,98) = ( power(CONSTANTS(:,55), CONSTANTS(:,115)).*CONSTANTS(:,56).*(power(STATES(:,25)./CONSTANTS(:,57), CONSTANTS(:,59)) - power(STATES(:,24)./CONSTANTS(:,58), CONSTANTS(:,59))))./(1.00000+power(STATES(:,25)./CONSTANTS(:,57), CONSTANTS(:,59))+power(STATES(:,24)./CONSTANTS(:,58), CONSTANTS(:,59)));
    ALGEBRAIC(:,99) =  5.34800e-06.*(STATES(:,24) - STATES(:,5));
    ALGEBRAIC(:,100) = ((((((((((( CONSTANTS(:,71).*STATES(:,25).*(CONSTANTS(:,69) - STATES(:,28)) -  CONSTANTS(:,70).*STATES(:,28))+ CONSTANTS(:,74).*STATES(:,25).*((CONSTANTS(:,72) - STATES(:,29)) - STATES(:,30))) -  CONSTANTS(:,73).*STATES(:,29))+ CONSTANTS(:,76).*CONSTANTS(:,25).*((CONSTANTS(:,72) - STATES(:,29)) - STATES(:,30))) -  CONSTANTS(:,75).*STATES(:,30))+ CONSTANTS(:,79).*STATES(:,25).*(CONSTANTS(:,77) - STATES(:,31))) -  CONSTANTS(:,78).*STATES(:,31))+ CONSTANTS(:,82).*STATES(:,25).*((CONSTANTS(:,80) - STATES(:,32)) - STATES(:,33))) -  CONSTANTS(:,81).*STATES(:,32))+ CONSTANTS(:,84).*CONSTANTS(:,25).*((CONSTANTS(:,80) - STATES(:,32)) - STATES(:,33))) -  CONSTANTS(:,83).*STATES(:,33))+( CONSTANTS(:,87).*STATES(:,25).*(CONSTANTS(:,85) - STATES(:,34)) -  CONSTANTS(:,86).*STATES(:,34));
    ALGEBRAIC(:,101) =  CONSTANTS(:,68).*STATES(:,2).*(CONSTANTS(:,65) - STATES(:,26)) -  CONSTANTS(:,67).*STATES(:,26);
    ALGEBRAIC(:,102) =  CONSTANTS(:,68).*STATES(:,3).*(CONSTANTS(:,66) - STATES(:,27)) -  CONSTANTS(:,67).*STATES(:,27);
    ALGEBRAIC(:,10) =  (1.00000./CONSTANTS(:,114)).*log(CONSTANTS(:,23)./STATES(:,2));
    ALGEBRAIC(:,34) =  CONSTANTS(:,20).*CONSTANTS(:,26).*power(STATES(:,7), 3.00000).*STATES(:,8).*STATES(:,9).*(STATES(:,1) - ALGEBRAIC(:,10));
    ALGEBRAIC(:,37) =  CONSTANTS(:,20).*CONSTANTS(:,27).*(STATES(:,1) - ALGEBRAIC(:,10));
    ALGEBRAIC(:,40) = 1.00000./(1.00000+ 0.124500.*exp(  - 0.100000.*STATES(:,1).*CONSTANTS(:,114))+ 0.0365000.*CONSTANTS(:,105).*exp(  - STATES(:,1).*CONSTANTS(:,114)));
    ALGEBRAIC(:,41) = (( CONSTANTS(:,20).*CONSTANTS(:,28).*ALGEBRAIC(:,40).*CONSTANTS(:,22))./(1.00000+power(CONSTANTS(:,29)./STATES(:,2), 4.00000)))./(CONSTANTS(:,22)+CONSTANTS(:,30));
    ALGEBRAIC(:,68) = ( CONSTANTS(:,38).*STATES(:,1).*CONSTANTS(:,100).*CONSTANTS(:,114).*( 0.750000.*STATES(:,2).*exp( STATES(:,1).*CONSTANTS(:,114)) -  0.750000.*CONSTANTS(:,23)))./(exp( STATES(:,1).*CONSTANTS(:,114)) - 1.00000);
    ALGEBRAIC(:,74) =  CONSTANTS(:,21).*ALGEBRAIC(:,68).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,19))+CONSTANTS(:,97)).*power(CONSTANTS(:,41), CONSTANTS(:,115)).*0.450000.*1.00000;
    ALGEBRAIC(:,77) = 1.00000./(1.00000+power(CONSTANTS(:,49)./STATES(:,5), 2.00000));
    ALGEBRAIC(:,80) =  exp( CONSTANTS(:,48).*STATES(:,1).*CONSTANTS(:,114)).*power(STATES(:,2), 3.00000).*CONSTANTS(:,24);
    ALGEBRAIC(:,82) =  exp( (CONSTANTS(:,48) - 1.00000).*STATES(:,1).*CONSTANTS(:,114)).*power(CONSTANTS(:,23), 3.00000).*STATES(:,5);
    ALGEBRAIC(:,83) =  CONSTANTS(:,43).*power(CONSTANTS(:,23), 3.00000).*(1.00000+power(STATES(:,2)./CONSTANTS(:,45), 3.00000))+ power(CONSTANTS(:,46), 3.00000).*STATES(:,5).*(1.00000+STATES(:,5)./CONSTANTS(:,43))+ CONSTANTS(:,44).*power(STATES(:,2), 3.00000)+ power(STATES(:,2), 3.00000).*CONSTANTS(:,24)+ power(CONSTANTS(:,23), 3.00000).*STATES(:,5);
    ALGEBRAIC(:,86) = (( CONSTANTS(:,20).*CONSTANTS(:,42).*power(CONSTANTS(:,50), CONSTANTS(:,115)).*ALGEBRAIC(:,77).*(ALGEBRAIC(:,80) - ALGEBRAIC(:,82)))./ALGEBRAIC(:,83))./(1.00000+ CONSTANTS(:,47).*exp( (CONSTANTS(:,48) - 1.00000).*STATES(:,1).*CONSTANTS(:,114)));
    ALGEBRAIC(:,105) = ALGEBRAIC(:,34)+ALGEBRAIC(:,37)+ 3.00000.*ALGEBRAIC(:,86)+ 3.00000.*ALGEBRAIC(:,41)+ALGEBRAIC(:,74);
    ALGEBRAIC(:,23) =  (1.00000./CONSTANTS(:,114)).*log(CONSTANTS(:,23)./STATES(:,3));
    ALGEBRAIC(:,35) =  CONSTANTS(:,103).*CONSTANTS(:,26).*power(STATES(:,7), 3.00000).*STATES(:,8).*STATES(:,9).*(STATES(:,1) - ALGEBRAIC(:,23));
    ALGEBRAIC(:,38) =  CONSTANTS(:,103).*CONSTANTS(:,27).*(STATES(:,1) - ALGEBRAIC(:,23));
    ALGEBRAIC(:,42) = (( CONSTANTS(:,103).*CONSTANTS(:,28).*ALGEBRAIC(:,40).*CONSTANTS(:,22))./(1.00000+power(CONSTANTS(:,29)./STATES(:,3), 4.00000)))./(CONSTANTS(:,22)+CONSTANTS(:,30));
    ALGEBRAIC(:,69) = ( CONSTANTS(:,38).*STATES(:,1).*CONSTANTS(:,100).*CONSTANTS(:,114).*( 0.750000.*STATES(:,3).*exp( STATES(:,1).*CONSTANTS(:,114)) -  0.750000.*CONSTANTS(:,23)))./(exp( STATES(:,1).*CONSTANTS(:,114)) - 1.00000);
    ALGEBRAIC(:,75) =  CONSTANTS(:,104).*ALGEBRAIC(:,69).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,20))+CONSTANTS(:,96)).*power(CONSTANTS(:,41), CONSTANTS(:,115)).*0.450000.*1.00000;
    ALGEBRAIC(:,79) = 1.00000./(1.00000+power(CONSTANTS(:,49)./STATES(:,6), 2.00000));
    ALGEBRAIC(:,81) =  exp( CONSTANTS(:,48).*STATES(:,1).*CONSTANTS(:,114)).*power(STATES(:,3), 3.00000).*CONSTANTS(:,24);
    ALGEBRAIC(:,84) =  exp( (CONSTANTS(:,48) - 1.00000).*STATES(:,1).*CONSTANTS(:,114)).*power(CONSTANTS(:,23), 3.00000).*STATES(:,6);
    ALGEBRAIC(:,85) =  CONSTANTS(:,43).*power(CONSTANTS(:,23), 3.00000).*(1.00000+power(STATES(:,3)./CONSTANTS(:,45), 3.00000))+ power(CONSTANTS(:,46), 3.00000).*STATES(:,6).*(1.00000+STATES(:,6)./CONSTANTS(:,43))+ CONSTANTS(:,44).*power(STATES(:,3), 3.00000)+ power(STATES(:,3), 3.00000).*CONSTANTS(:,24)+ power(CONSTANTS(:,23), 3.00000).*STATES(:,6);
    ALGEBRAIC(:,87) = (( CONSTANTS(:,103).*CONSTANTS(:,42).*power(CONSTANTS(:,50), CONSTANTS(:,115)).*ALGEBRAIC(:,79).*(ALGEBRAIC(:,81) - ALGEBRAIC(:,84)))./ALGEBRAIC(:,85))./(1.00000+ CONSTANTS(:,47).*exp( (CONSTANTS(:,48) - 1.00000).*STATES(:,1).*CONSTANTS(:,114)));
    ALGEBRAIC(:,106) = ALGEBRAIC(:,35)+ALGEBRAIC(:,38)+ 3.00000.*ALGEBRAIC(:,87)+ 3.00000.*ALGEBRAIC(:,42)+ALGEBRAIC(:,75);
    ALGEBRAIC(:,103) = ( CONSTANTS(:,89).*STATES(:,5).*(CONSTANTS(:,123) - STATES(:,35)) -  CONSTANTS(:,88).*STATES(:,35))+( CONSTANTS(:,91).*STATES(:,5).*(CONSTANTS(:,125) - STATES(:,37)) -  CONSTANTS(:,90).*STATES(:,37));
    ALGEBRAIC(:,65) = ( CONSTANTS(:,39).*4.00000.*STATES(:,1).*CONSTANTS(:,100).*CONSTANTS(:,114).*( 0.341000.*STATES(:,5).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,114)) -  0.341000.*CONSTANTS(:,24)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,114)) - 1.00000);
    ALGEBRAIC(:,70) =  CONSTANTS(:,21).*ALGEBRAIC(:,65).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,19))+CONSTANTS(:,97)).*power(CONSTANTS(:,41), CONSTANTS(:,115)).*0.450000.*1.00000;
    ALGEBRAIC(:,90) = ( CONSTANTS(:,20).*power(CONSTANTS(:,54), CONSTANTS(:,115)).*CONSTANTS(:,51).*power(STATES(:,5), 1.60000))./(power(CONSTANTS(:,52), 1.60000)+power(STATES(:,5), 1.60000));
    ALGEBRAIC(:,31) =  ((1.00000./CONSTANTS(:,114))./2.00000).*log(CONSTANTS(:,24)./STATES(:,5));
    ALGEBRAIC(:,94) =  CONSTANTS(:,20).*CONSTANTS(:,53).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,108) = (ALGEBRAIC(:,70)+ALGEBRAIC(:,94)+ALGEBRAIC(:,90)) -  2.00000.*ALGEBRAIC(:,86);
    ALGEBRAIC(:,104) = ( CONSTANTS(:,89).*STATES(:,6).*(CONSTANTS(:,122) - STATES(:,36)) -  CONSTANTS(:,88).*STATES(:,36))+( CONSTANTS(:,91).*STATES(:,6).*(CONSTANTS(:,124) - STATES(:,38)) -  CONSTANTS(:,90).*STATES(:,38));
    ALGEBRAIC(:,66) = ( CONSTANTS(:,39).*4.00000.*STATES(:,1).*CONSTANTS(:,100).*CONSTANTS(:,114).*( 0.341000.*STATES(:,6).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,114)) -  0.341000.*CONSTANTS(:,24)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,114)) - 1.00000);
    ALGEBRAIC(:,71) =  CONSTANTS(:,104).*ALGEBRAIC(:,66).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,20))+CONSTANTS(:,96)).*power(CONSTANTS(:,41), CONSTANTS(:,115)).*0.450000.*1.00000;
    ALGEBRAIC(:,92) = ( CONSTANTS(:,103).*power(CONSTANTS(:,54), CONSTANTS(:,115)).*CONSTANTS(:,51).*power(STATES(:,6), 1.60000))./(power(CONSTANTS(:,52), 1.60000)+power(STATES(:,6), 1.60000));
    ALGEBRAIC(:,33) =  ((1.00000./CONSTANTS(:,114))./2.00000).*log(CONSTANTS(:,24)./STATES(:,6));
    ALGEBRAIC(:,95) =  CONSTANTS(:,103).*CONSTANTS(:,53).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,109) = (ALGEBRAIC(:,71)+ALGEBRAIC(:,95)+ALGEBRAIC(:,92)) -  2.00000.*ALGEBRAIC(:,87);
    ALGEBRAIC(:,43) = ALGEBRAIC(:,41)+ALGEBRAIC(:,42);
    ALGEBRAIC(:,27) =  (1.00000./CONSTANTS(:,114)).*log(CONSTANTS(:,22)./STATES(:,4));
    ALGEBRAIC(:,44) = 1.00000./(1.00000+exp((STATES(:,1)+74.0000)./24.0000));
    ALGEBRAIC(:,45) =  CONSTANTS(:,106).*STATES(:,10).*ALGEBRAIC(:,44).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,46) = 1.00000./(1.00000+exp(7.48800 - STATES(:,1)./5.98000));
    ALGEBRAIC(:,47) =  CONSTANTS(:,20).*CONSTANTS(:,34).*ALGEBRAIC(:,46).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,48) =  CONSTANTS(:,103).*CONSTANTS(:,34).*ALGEBRAIC(:,46).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,49) = ALGEBRAIC(:,47)+ALGEBRAIC(:,48);
    ALGEBRAIC(:,50) =  (1.00000./CONSTANTS(:,114)).*log((CONSTANTS(:,22)+ CONSTANTS(:,33).*CONSTANTS(:,23))./(STATES(:,4)+ CONSTANTS(:,33).*STATES(:,12)));
    ALGEBRAIC(:,51) =  CONSTANTS(:,20).*CONSTANTS(:,94).*power(STATES(:,11), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,50));
    ALGEBRAIC(:,52) =  CONSTANTS(:,103).*CONSTANTS(:,95).*power(STATES(:,11), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,50));
    ALGEBRAIC(:,53) = ALGEBRAIC(:,51)+ALGEBRAIC(:,52);
    ALGEBRAIC(:,54) =  CONSTANTS(:,107).*STATES(:,13).*STATES(:,14).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,55) =  CONSTANTS(:,108).*STATES(:,15).*STATES(:,16).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,56) = ALGEBRAIC(:,54)+ALGEBRAIC(:,55);
    ALGEBRAIC(:,57) = 1.02000./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,27)) - 59.2150)));
    ALGEBRAIC(:,58) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1)+5.47600) - ALGEBRAIC(:,27)))+exp( 0.0617500.*((STATES(:,1) - ALGEBRAIC(:,27)) - 594.310)))./(1.00000+exp(  - 0.514300.*((STATES(:,1) - ALGEBRAIC(:,27))+4.75300)));
    ALGEBRAIC(:,59) = ALGEBRAIC(:,57)./(ALGEBRAIC(:,57)+ALGEBRAIC(:,58));
    ALGEBRAIC(:,60) =  1.00000.*0.350000.*power((CONSTANTS(:,22)./5.40000), 1.0 ./ 2).*ALGEBRAIC(:,59).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,67) = ( CONSTANTS(:,40).*STATES(:,1).*CONSTANTS(:,100).*CONSTANTS(:,114).*( 0.750000.*STATES(:,4).*exp( STATES(:,1).*CONSTANTS(:,114)) -  0.750000.*CONSTANTS(:,22)))./(exp( STATES(:,1).*CONSTANTS(:,114)) - 1.00000);
    ALGEBRAIC(:,73) =  ALGEBRAIC(:,67).*STATES(:,17).*STATES(:,18).*( CONSTANTS(:,21).*(CONSTANTS(:,97)+(1.00000 - STATES(:,19)))+ CONSTANTS(:,104).*(CONSTANTS(:,96)+(1.00000 - STATES(:,20)))).*power(CONSTANTS(:,41), CONSTANTS(:,115)).*0.450000.*1.00000;
    ALGEBRAIC(:,107) = ((ALGEBRAIC(:,56)+ALGEBRAIC(:,45)+ALGEBRAIC(:,53)+ALGEBRAIC(:,60)) -  2.00000.*ALGEBRAIC(:,43))+ALGEBRAIC(:,73)+ALGEBRAIC(:,49);
    ALGEBRAIC(:,111) = ALGEBRAIC(:,105)+ALGEBRAIC(:,106);
    ALGEBRAIC(:,61) =  (( CONSTANTS(:,20).*CONSTANTS(:,35))./(1.00000+CONSTANTS(:,37)./STATES(:,5))).*(STATES(:,1) - CONSTANTS(:,127));
    ALGEBRAIC(:,62) =  (( CONSTANTS(:,103).*CONSTANTS(:,35))./(1.00000+CONSTANTS(:,37)./STATES(:,6))).*(STATES(:,1) - CONSTANTS(:,127));
    ALGEBRAIC(:,63) = ALGEBRAIC(:,61)+ALGEBRAIC(:,62);
    ALGEBRAIC(:,64) =  CONSTANTS(:,36).*(STATES(:,1) - CONSTANTS(:,127));
    ALGEBRAIC(:,112) = ALGEBRAIC(:,63)+ALGEBRAIC(:,64);
    ALGEBRAIC(:,113) = ALGEBRAIC(:,108)+ALGEBRAIC(:,109);
    ALGEBRAIC(:,114) = ALGEBRAIC(:,111)+ALGEBRAIC(:,112)+ALGEBRAIC(:,113)+ALGEBRAIC(:,107);
    ALGEBRAIC(:,110) = 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(:,36) = ALGEBRAIC(:,34)+ALGEBRAIC(:,35);
    ALGEBRAIC(:,39) = ALGEBRAIC(:,37)+ALGEBRAIC(:,38);
    ALGEBRAIC(:,72) = ALGEBRAIC(:,70)+ALGEBRAIC(:,71);
    ALGEBRAIC(:,76) = ALGEBRAIC(:,74)+ALGEBRAIC(:,75);
    ALGEBRAIC(:,78) = ALGEBRAIC(:,72)+ALGEBRAIC(:,73)+ALGEBRAIC(:,76);
    ALGEBRAIC(:,88) =  3.00000.*ALGEBRAIC(:,86)+ 3.00000.*ALGEBRAIC(:,41)+ALGEBRAIC(:,74);
    ALGEBRAIC(:,89) = ALGEBRAIC(:,86)+ALGEBRAIC(:,87);
    ALGEBRAIC(:,91) =  3.00000.*ALGEBRAIC(:,87)+ 3.00000.*ALGEBRAIC(:,42)+ALGEBRAIC(:,75);
    ALGEBRAIC(:,93) = ALGEBRAIC(:,90)+ALGEBRAIC(:,92);
    ALGEBRAIC(:,96) = ALGEBRAIC(:,94)+ALGEBRAIC(:,95);
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
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