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 =115;
end
% There are a total of 39 entries in each of the rate and state variable arrays.
% There are a total of 127 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_ALGEBRAIC(:,23) = strpad('I_app in component Protocol (uA_per_uF)');
    LEGEND_VOI = strpad('time in component environment (msec)');
    LEGEND_CONSTANTS(:,1) = strpad('V_hold in component Protocol (mV)');
    LEGEND_CONSTANTS(:,2) = strpad('V_test in component Protocol (mV)');
    LEGEND_ALGEBRAIC(:,10) = strpad('V_clamp in component Protocol (mV)');
    LEGEND_STATES(:,1) = strpad('V_m in component membrane_potential (mV)');
    LEGEND_CONSTANTS(:,3) = strpad('R_clamp in component Protocol (uF_per_mS)');
    LEGEND_CONSTANTS(:,4) = strpad('epi in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,5) = strpad('R in component parameters (joule_per_kelvin_per_kilomole)');
    LEGEND_CONSTANTS(:,99) = strpad('Frdy in component parameters (coulomb_per_mole)');
    LEGEND_CONSTANTS(:,109) = strpad('Temp in component parameters (kelvin)');
    LEGEND_CONSTANTS(:,113) = strpad('FoRT in component parameters (per_mV)');
    LEGEND_CONSTANTS(:,6) = strpad('Cmem in component parameters (farad)');
    LEGEND_CONSTANTS(:,114) = strpad('Qpow in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,7) = strpad('cellLength in component parameters (um)');
    LEGEND_CONSTANTS(:,100) = strpad('cellRadius in component parameters (um)');
    LEGEND_CONSTANTS(:,8) = strpad('junctionLength in component parameters (um)');
    LEGEND_CONSTANTS(:,101) = strpad('junctionRadius in component parameters (um)');
    LEGEND_CONSTANTS(:,9) = strpad('distSLcyto in component parameters (um)');
    LEGEND_CONSTANTS(:,10) = strpad('distJuncSL in component parameters (um)');
    LEGEND_CONSTANTS(:,11) = strpad('DcaJuncSL in component parameters (cm2_per_sec)');
    LEGEND_CONSTANTS(:,12) = strpad('DcaSLcyto in component parameters (cm2_per_sec)');
    LEGEND_CONSTANTS(:,13) = strpad('DnaJuncSL in component parameters (cm2_per_sec)');
    LEGEND_CONSTANTS(:,14) = strpad('DnaSLcyto in component parameters (cm2_per_sec)');
    LEGEND_CONSTANTS(:,110) = strpad('Vcell in component parameters (liter)');
    LEGEND_CONSTANTS(:,115) = strpad('Vmyo in component parameters (liter)');
    LEGEND_CONSTANTS(:,116) = strpad('Vsr in component parameters (liter)');
    LEGEND_CONSTANTS(:,117) = strpad('Vsl in component parameters (liter)');
    LEGEND_CONSTANTS(:,118) = strpad('Vjunc in component parameters (liter)');
    LEGEND_CONSTANTS(:,111) = strpad('SAjunc in component parameters (um2)');
    LEGEND_CONSTANTS(:,112) = strpad('SAsl in component parameters (um2)');
    LEGEND_CONSTANTS(:,15) = strpad('J_ca_juncsl in component parameters (liters_per_msec)');
    LEGEND_CONSTANTS(:,16) = strpad('J_ca_slmyo in component parameters (liters_per_msec)');
    LEGEND_CONSTANTS(:,17) = strpad('J_na_juncsl in component parameters (liters_per_msec)');
    LEGEND_CONSTANTS(:,18) = strpad('J_na_slmyo in component parameters (liters_per_msec)');
    LEGEND_CONSTANTS(:,19) = strpad('Fjunc in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,102) = strpad('Fsl in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,20) = strpad('Fjunc_CaL in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,103) = strpad('Fsl_CaL in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,119) = strpad('Cli in component parameters (mM)');
    LEGEND_CONSTANTS(:,120) = strpad('Clo in component parameters (mM)');
    LEGEND_CONSTANTS(:,21) = strpad('Ko in component parameters (mM)');
    LEGEND_CONSTANTS(:,22) = strpad('Nao in component parameters (mM)');
    LEGEND_CONSTANTS(:,23) = strpad('Cao in component parameters (mM)');
    LEGEND_CONSTANTS(:,24) = strpad('Mgi in component parameters (mM)');
    LEGEND_ALGEBRAIC(:,27) = strpad('ena_junc in component parameters (mV)');
    LEGEND_ALGEBRAIC(:,31) = strpad('ena_sl in component parameters (mV)');
    LEGEND_ALGEBRAIC(:,33) = strpad('ek in component parameters (mV)');
    LEGEND_ALGEBRAIC(:,34) = strpad('eca_junc in component parameters (mV)');
    LEGEND_ALGEBRAIC(:,35) = strpad('eca_sl in component parameters (mV)');
    LEGEND_CONSTANTS(:,126) = strpad('ecl in component parameters (mV)');
    LEGEND_CONSTANTS(:,25) = strpad('GNa in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,26) = strpad('GNaB in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,27) = strpad('IbarNaK in component parameters (uA_per_uF)');
    LEGEND_CONSTANTS(:,28) = strpad('KmNaip in component parameters (mM)');
    LEGEND_CONSTANTS(:,29) = strpad('KmKo in component parameters (mM)');
    LEGEND_CONSTANTS(:,30) = strpad('Q10NaK in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,31) = strpad('Q10KmNai in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,32) = strpad('pNaK in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,33) = strpad('gkp in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,34) = strpad('GClCa in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,35) = strpad('GClB in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,36) = strpad('KdClCa in component parameters (mM)');
    LEGEND_CONSTANTS(:,37) = strpad('pNa in component parameters (cm_per_sec)');
    LEGEND_CONSTANTS(:,38) = strpad('pCa in component parameters (cm_per_sec)');
    LEGEND_CONSTANTS(:,39) = strpad('pK in component parameters (cm_per_sec)');
    LEGEND_CONSTANTS(:,40) = strpad('Q10CaL in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,41) = strpad('IbarNCX in component parameters (uA_per_uF)');
    LEGEND_CONSTANTS(:,42) = strpad('KmCai in component parameters (mM)');
    LEGEND_CONSTANTS(:,43) = strpad('KmCao in component parameters (mM)');
    LEGEND_CONSTANTS(:,44) = strpad('KmNai in component parameters (mM)');
    LEGEND_CONSTANTS(:,45) = strpad('KmNao in component parameters (mM)');
    LEGEND_CONSTANTS(:,46) = strpad('ksat in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,47) = strpad('nu in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,48) = strpad('Kdact in component parameters (mM)');
    LEGEND_CONSTANTS(:,49) = strpad('Q10NCX in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,50) = strpad('IbarSLCaP in component parameters (uA_per_uF)');
    LEGEND_CONSTANTS(:,51) = strpad('KmPCa in component parameters (mM)');
    LEGEND_CONSTANTS(:,52) = strpad('GCaB in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,53) = strpad('Q10SLCaP in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,54) = strpad('Q10SRCaP in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,55) = strpad('Vmax_SRCaP in component parameters (mM_per_msec)');
    LEGEND_CONSTANTS(:,56) = strpad('Kmf in component parameters (mM)');
    LEGEND_CONSTANTS(:,57) = strpad('Kmr in component parameters (mM)');
    LEGEND_CONSTANTS(:,58) = strpad('hillSRCaP in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,59) = strpad('ks in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,60) = strpad('koCa in component parameters (per_mM2_per_msec)');
    LEGEND_CONSTANTS(:,61) = strpad('kom in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,108) = strpad('kiCa in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,62) = strpad('kim in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,63) = strpad('ec50SR in component parameters (mM)');
    LEGEND_CONSTANTS(:,64) = strpad('Bmax_Naj in component parameters (mM)');
    LEGEND_CONSTANTS(:,65) = strpad('Bmax_Nasl in component parameters (mM)');
    LEGEND_CONSTANTS(:,66) = strpad('koff_na in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,67) = strpad('kon_na in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,68) = strpad('Bmax_TnClow in component parameters (mM)');
    LEGEND_CONSTANTS(:,69) = strpad('koff_tncl in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,70) = strpad('kon_tncl in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,71) = strpad('Bmax_TnChigh in component parameters (mM)');
    LEGEND_CONSTANTS(:,72) = strpad('koff_tnchca in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,73) = strpad('kon_tnchca in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,74) = strpad('koff_tnchmg in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,75) = strpad('kon_tnchmg in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,76) = strpad('Bmax_CaM in component parameters (mM)');
    LEGEND_CONSTANTS(:,77) = strpad('koff_cam in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,78) = strpad('kon_cam in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,79) = strpad('Bmax_myosin in component parameters (mM)');
    LEGEND_CONSTANTS(:,80) = strpad('koff_myoca in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,81) = strpad('kon_myoca in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,82) = strpad('koff_myomg in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,83) = strpad('kon_myomg in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,84) = strpad('Bmax_SR in component parameters (mM)');
    LEGEND_CONSTANTS(:,85) = strpad('koff_sr in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,86) = strpad('kon_sr in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,121) = strpad('Bmax_SLlowsl in component parameters (mM)');
    LEGEND_CONSTANTS(:,122) = strpad('Bmax_SLlowj in component parameters (mM)');
    LEGEND_CONSTANTS(:,87) = strpad('koff_sll in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,88) = strpad('kon_sll in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,123) = strpad('Bmax_SLhighsl in component parameters (mM)');
    LEGEND_CONSTANTS(:,124) = strpad('Bmax_SLhighj in component parameters (mM)');
    LEGEND_CONSTANTS(:,89) = strpad('koff_slh in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,90) = strpad('kon_slh in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,125) = strpad('Bmax_Csqn in component parameters (mM)');
    LEGEND_CONSTANTS(:,91) = strpad('koff_csqn in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,92) = 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(:,36) = strpad('I_Na_junc in component I_Na (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,37) = strpad('I_Na_sl in component I_Na (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,38) = strpad('I_Na in component I_Na (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,39) = strpad('I_nabk_junc in component I_NaBK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,40) = strpad('I_nabk_sl in component I_NaBK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,41) = strpad('I_nabk in component I_NaBK (uA_per_uF)');
    LEGEND_CONSTANTS(:,104) = strpad('sigma in component I_NaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,42) = strpad('fnak in component I_NaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,43) = strpad('I_nak_junc in component I_NaK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,44) = strpad('I_nak_sl in component I_NaK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,45) = strpad('I_nak in component I_NaK (uA_per_uF)');
    LEGEND_CONSTANTS(:,105) = 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(:,46) = strpad('rkr in component I_Kr (dimensionless)');
    LEGEND_ALGEBRAIC(:,47) = strpad('I_kr in component I_Kr (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,48) = strpad('kp_kp in component I_Kp (dimensionless)');
    LEGEND_ALGEBRAIC(:,49) = strpad('I_kp_junc in component I_Kp (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,50) = strpad('I_kp_sl in component I_Kp (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,51) = strpad('I_kp in component I_Kp (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,52) = strpad('eks in component I_Ks (mV)');
    LEGEND_CONSTANTS(:,93) = strpad('gks_junc in component I_Ks (mS_per_uF)');
    LEGEND_CONSTANTS(:,94) = 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(:,53) = strpad('I_ks_junc in component I_Ks (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,54) = strpad('I_ks_sl in component I_Ks (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,55) = strpad('I_ks in component I_Ks (uA_per_uF)');
    LEGEND_STATES(:,12) = strpad('Na_i in component Na_Concentrations (mM)');
    LEGEND_CONSTANTS(:,106) = strpad('GtoSlow in component I_to (mS_per_uF)');
    LEGEND_CONSTANTS(:,107) = 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(:,56) = 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(:,57) = strpad('I_tof in component I_to (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,58) = strpad('I_to in component I_to (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,59) = strpad('aki in component I_Ki (dimensionless)');
    LEGEND_ALGEBRAIC(:,60) = strpad('bki in component I_Ki (dimensionless)');
    LEGEND_ALGEBRAIC(:,61) = strpad('kiss in component I_Ki (dimensionless)');
    LEGEND_ALGEBRAIC(:,62) = strpad('I_ki in component I_Ki (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,63) = strpad('I_ClCa_junc in component I_ClCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,64) = strpad('I_ClCa_sl in component I_ClCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,65) = strpad('I_ClCa in component I_ClCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,66) = 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(:,95) = strpad('fcaCaMSL in component I_Ca (dimensionless)');
    LEGEND_CONSTANTS(:,96) = strpad('fcaCaj in component I_Ca (dimensionless)');
    LEGEND_ALGEBRAIC(:,67) = strpad('ibarca_j in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,68) = strpad('ibarca_sl in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,69) = strpad('ibark in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,70) = strpad('ibarna_j in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,71) = strpad('ibarna_sl in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,72) = strpad('I_Ca_junc in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,73) = strpad('I_Ca_sl in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,74) = strpad('I_Ca in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,75) = strpad('I_CaK in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,76) = strpad('I_CaNa_junc in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,77) = strpad('I_CaNa_sl in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,78) = strpad('I_CaNa in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,80) = strpad('I_Catot in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,79) = strpad('Ka_junc in component I_NCX (dimensionless)');
    LEGEND_ALGEBRAIC(:,81) = strpad('Ka_sl in component I_NCX (dimensionless)');
    LEGEND_ALGEBRAIC(:,82) = strpad('s1_junc in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,83) = strpad('s1_sl in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,84) = strpad('s2_junc in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,85) = strpad('s3_junc in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,86) = strpad('s2_sl in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,87) = strpad('s3_sl in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,88) = strpad('I_ncx_junc in component I_NCX (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,89) = strpad('I_ncx_sl in component I_NCX (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,91) = strpad('I_ncx in component I_NCX (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,92) = strpad('I_pca_junc in component I_PCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,94) = strpad('I_pca_sl in component I_PCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,95) = strpad('I_pca in component I_PCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,96) = strpad('I_cabk_junc in component I_CaBK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,97) = strpad('I_cabk_sl in component I_CaBK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,98) = strpad('I_cabk in component I_CaBK (uA_per_uF)');
    LEGEND_CONSTANTS(:,97) = strpad('MaxSR in component SR_Fluxes (dimensionless)');
    LEGEND_CONSTANTS(:,98) = 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(:,99) = strpad('J_SRCarel in component SR_Fluxes (mM_per_msec)');
    LEGEND_ALGEBRAIC(:,100) = strpad('J_serca in component SR_Fluxes (mM_per_msec)');
    LEGEND_ALGEBRAIC(:,101) = 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(:,103) = strpad('dNa_Bj_dt in component Na_Buffers (mM_per_msec)');
    LEGEND_ALGEBRAIC(:,104) = 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(:,102) = 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(:,105) = strpad('J_CaB_junction in component Junctional_and_SL_Ca_Buffers (mM_per_msec)');
    LEGEND_ALGEBRAIC(:,106) = 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(:,107) = strpad('I_Na_tot_junc in component Na_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,108) = strpad('I_Na_tot_sl in component Na_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,93) = strpad('I_Na_tot_sl2 in component Na_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,90) = strpad('I_Na_tot_junc2 in component Na_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,109) = strpad('I_K_tot in component K_Concentration (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,110) = strpad('I_Ca_tot_junc in component Ca_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,111) = strpad('I_Ca_tot_sl in component Ca_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,112) = strpad('I_Na_tot in component membrane_potential (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,113) = strpad('I_Cl_tot in component membrane_potential (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,114) = strpad('I_Ca_tot in component membrane_potential (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,115) = strpad('I_tot 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 = [];
    CONSTANTS(:,1) = -40;
    CONSTANTS(:,2) = 50;
    STATES(:,1) = -8.09763e1;
    CONSTANTS(:,3) = 0.02;
    STATES(:,2) = 9.06;
    STATES(:,3) = 9.06;
    STATES(:,4) = 120;
    STATES(:,5) = 1.737475e-4;
    STATES(:,6) = 1.031812e-4;
    STATES(:,7) = 1.405627e-3;
    STATES(:,8) = 9.867005e-1;
    STATES(:,9) = 9.91562e-1;
    STATES(:,10) = 8.641386e-3;
    STATES(:,11) = 5.412034e-3;
    STATES(:,12) = 9.06;
    STATES(:,13) = 4.051574e-3;
    STATES(:,14) = 9.945511e-1;
    STATES(:,15) = 4.051574e-3;
    STATES(:,16) = 9.945511e-1;
    STATES(:,17) = 7.175662e-6;
    STATES(:,18) = 1.000681;
    STATES(:,19) = 2.421991e-2;
    STATES(:,20) = 1.452605e-2;
    STATES(:,21) = 8.884332e-1;
    STATES(:,22) = 8.156628e-7;
    STATES(:,23) = 1.024274e-7;
    STATES(:,24) = 0.1e-1;
    STATES(:,25) = 8.597401e-5;
    STATES(:,26) = 3.539892;
    STATES(:,27) = 7.720854e-1;
    STATES(:,28) = 8.773191e-3;
    STATES(:,29) = 1.078283e-1;
    STATES(:,30) = 1.524002e-2;
    STATES(:,31) = 2.911916e-4;
    STATES(:,32) = 1.298754e-3;
    STATES(:,33) = 1.381982e-1;
    STATES(:,34) = 2.143165e-3;
    STATES(:,35) = 9.566355e-3;
    STATES(:,36) = 1.110363e-1;
    STATES(:,37) = 7.347888e-3;
    STATES(:,38) = 7.297378e-2;
    STATES(:,39) = 1.242988;
    CONSTANTS(:,4) = 1.00000;
    CONSTANTS(:,5) = 8314.00;
    CONSTANTS(:,6) = 1.38100e-10;
    CONSTANTS(:,7) = 100.000;
    CONSTANTS(:,8) = 0.160000;
    CONSTANTS(:,9) = 0.450000;
    CONSTANTS(:,10) = 0.500000;
    CONSTANTS(:,11) = 1.64000e-06;
    CONSTANTS(:,12) = 1.22000e-06;
    CONSTANTS(:,13) = 1.09000e-05;
    CONSTANTS(:,14) = 1.79000e-05;
    CONSTANTS(:,15) = 8.24130e-13;
    CONSTANTS(:,16) = 3.27430e-12;
    CONSTANTS(:,17) = 1.83130e-14;
    CONSTANTS(:,18) = 1.63860e-12;
    CONSTANTS(:,19) = 0.110000;
    CONSTANTS(:,20) = 0.900000;
    CONSTANTS(:,21) = 5.40000;
    CONSTANTS(:,22) = 140.000;
    CONSTANTS(:,23) = 1.80000;
    CONSTANTS(:,24) = 1.00000;
    CONSTANTS(:,25) = 23.0000;
    CONSTANTS(:,26) = 0.000597000;
    CONSTANTS(:,27) =  1.00000.*1.80000;
    CONSTANTS(:,28) = 11.0000;
    CONSTANTS(:,29) = 1.50000;
    CONSTANTS(:,30) = 1.63000;
    CONSTANTS(:,31) = 1.39000;
    CONSTANTS(:,32) = 0.0183300;
    CONSTANTS(:,33) =  2.00000.*0.00100000;
    CONSTANTS(:,34) =  0.500000.*0.109625;
    CONSTANTS(:,35) =  1.00000.*0.00900000;
    CONSTANTS(:,36) = 0.100000;
    CONSTANTS(:,37) =  0.500000.*1.50000e-08;
    CONSTANTS(:,38) =  0.500000.*0.000540000;
    CONSTANTS(:,39) =  0.500000.*2.70000e-07;
    CONSTANTS(:,40) = 1.80000;
    CONSTANTS(:,41) =  1.00000.*4.50000;
    CONSTANTS(:,42) = 0.00359000;
    CONSTANTS(:,43) = 1.30000;
    CONSTANTS(:,44) = 12.2900;
    CONSTANTS(:,45) = 87.5000;
    CONSTANTS(:,46) = 0.320000;
    CONSTANTS(:,47) = 0.270000;
    CONSTANTS(:,48) = 0.000150000;
    CONSTANTS(:,49) = 1.57000;
    CONSTANTS(:,50) = 0.0673000;
    CONSTANTS(:,51) = 0.000500000;
    CONSTANTS(:,52) = 0.000551300;
    CONSTANTS(:,53) = 2.35000;
    CONSTANTS(:,54) = 2.60000;
    CONSTANTS(:,55) = 0.00531140;
    CONSTANTS(:,56) = 0.000246000;
    CONSTANTS(:,57) = 1.70000;
    CONSTANTS(:,58) = 1.78700;
    CONSTANTS(:,59) = 25.0000;
    CONSTANTS(:,60) = 10.0000;
    CONSTANTS(:,61) = 0.0600000;
    CONSTANTS(:,62) = 0.00500000;
    CONSTANTS(:,63) = 0.450000;
    CONSTANTS(:,64) = 7.56100;
    CONSTANTS(:,65) = 1.65000;
    CONSTANTS(:,66) = 0.00100000;
    CONSTANTS(:,67) = 0.000100000;
    CONSTANTS(:,68) = 0.0700000;
    CONSTANTS(:,69) = 0.0196000;
    CONSTANTS(:,70) = 32.7000;
    CONSTANTS(:,71) = 0.140000;
    CONSTANTS(:,72) = 3.20000e-05;
    CONSTANTS(:,73) = 2.37000;
    CONSTANTS(:,74) = 0.00333000;
    CONSTANTS(:,75) = 0.00300000;
    CONSTANTS(:,76) = 0.0240000;
    CONSTANTS(:,77) = 0.238000;
    CONSTANTS(:,78) = 34.0000;
    CONSTANTS(:,79) = 0.140000;
    CONSTANTS(:,80) = 0.000460000;
    CONSTANTS(:,81) = 13.8000;
    CONSTANTS(:,82) = 5.70000e-05;
    CONSTANTS(:,83) = 0.0157000;
    CONSTANTS(:,84) =  19.0000.*0.000900000;
    CONSTANTS(:,85) = 0.0600000;
    CONSTANTS(:,86) = 100.000;
    CONSTANTS(:,87) = 1.30000;
    CONSTANTS(:,88) = 100.000;
    CONSTANTS(:,89) = 0.0300000;
    CONSTANTS(:,90) = 100.000;
    CONSTANTS(:,91) = 65.0000;
    CONSTANTS(:,92) = 100.000;
    CONSTANTS(:,93) = 0.00350000;
    CONSTANTS(:,94) = 0.00350000;
    CONSTANTS(:,95) = 0.00000;
    CONSTANTS(:,96) = 0.00000;
    CONSTANTS(:,97) = 15.0000;
    CONSTANTS(:,98) = 1.00000;
    CONSTANTS(:,126) = 0.00000;
    CONSTANTS(:,99) = 96485.0;
    CONSTANTS(:,100) = 10.2500;
    CONSTANTS(:,101) = 0.0150000;
    CONSTANTS(:,102) = 1.00000 - CONSTANTS(:,19);
    CONSTANTS(:,103) = 1.00000 - CONSTANTS(:,20);
    CONSTANTS(:,104) = (exp(CONSTANTS(:,22)./67.3000) - 1.00000)./7.00000;
    CONSTANTS(:,105) =  0.0350000.*power((CONSTANTS(:,21)./5.40000), 1.0 ./ 2);
    CONSTANTS(:,106) = piecewise({CONSTANTS(:,4)==1.00000,  1.00000.*0.130000.*0.120000 },  0.130000.*0.300000.*0.964000);
    CONSTANTS(:,107) = piecewise({CONSTANTS(:,4)==1.00000,  1.00000.*0.130000.*0.880000 },  0.130000.*0.300000.*0.0360000);
    CONSTANTS(:,108) = 0.500000;
    CONSTANTS(:,109) = 310.000;
    CONSTANTS(:,110) =   pi.*power(CONSTANTS(:,100), 2.00000).*CONSTANTS(:,7).*1.00000e-15;
    CONSTANTS(:,111) =  20150.0.* pi.*2.00000.*CONSTANTS(:,8).*CONSTANTS(:,101);
    CONSTANTS(:,112) =   pi.*2.00000.*CONSTANTS(:,100).*CONSTANTS(:,7);
    CONSTANTS(:,113) = CONSTANTS(:,99)./( CONSTANTS(:,5).*CONSTANTS(:,109));
    CONSTANTS(:,114) = (CONSTANTS(:,109) - 310.000)./10.0000;
    CONSTANTS(:,115) =  0.650000.*CONSTANTS(:,110);
    CONSTANTS(:,116) =  0.0350000.*CONSTANTS(:,110);
    CONSTANTS(:,117) =  0.0200000.*CONSTANTS(:,110);
    CONSTANTS(:,118) =  0.0539000.*0.0100000.*CONSTANTS(:,110);
    CONSTANTS(:,119) = 15.0000;
    CONSTANTS(:,120) = 150.000;
    CONSTANTS(:,121) = ( 0.0374000.*CONSTANTS(:,115))./CONSTANTS(:,117);
    CONSTANTS(:,122) =  (( 0.00460000.*CONSTANTS(:,115))./CONSTANTS(:,118)).*0.100000;
    CONSTANTS(:,123) = ( 0.0134000.*CONSTANTS(:,115))./CONSTANTS(:,117);
    CONSTANTS(:,124) =  (( 0.00165000.*CONSTANTS(:,115))./CONSTANTS(:,118)).*0.100000;
    CONSTANTS(:,125) = ( 0.140000.*CONSTANTS(:,115))./CONSTANTS(:,116);
    CONSTANTS(:,126) =  (1.00000./CONSTANTS(:,113)).*log(CONSTANTS(:,119)./CONSTANTS(:,120));
    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(:,4) = CONSTANTS(:,126);
    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(:,70).*STATES(:,25).*(CONSTANTS(:,68) - STATES(:,28)) -  CONSTANTS(:,69).*STATES(:,28);
    RATES(:,29) =  CONSTANTS(:,73).*STATES(:,25).*((CONSTANTS(:,71) - STATES(:,29)) - STATES(:,30)) -  CONSTANTS(:,72).*STATES(:,29);
    RATES(:,30) =  CONSTANTS(:,75).*CONSTANTS(:,24).*((CONSTANTS(:,71) - STATES(:,29)) - STATES(:,30)) -  CONSTANTS(:,74).*STATES(:,30);
    RATES(:,31) =  CONSTANTS(:,78).*STATES(:,25).*(CONSTANTS(:,76) - STATES(:,31)) -  CONSTANTS(:,77).*STATES(:,31);
    RATES(:,32) =  CONSTANTS(:,81).*STATES(:,25).*((CONSTANTS(:,79) - STATES(:,32)) - STATES(:,33)) -  CONSTANTS(:,80).*STATES(:,32);
    RATES(:,33) =  CONSTANTS(:,83).*CONSTANTS(:,24).*((CONSTANTS(:,79) - STATES(:,32)) - STATES(:,33)) -  CONSTANTS(:,82).*STATES(:,33);
    RATES(:,34) =  CONSTANTS(:,86).*STATES(:,25).*(CONSTANTS(:,84) - STATES(:,34)) -  CONSTANTS(:,85).*STATES(:,34);
    RATES(:,35) =  CONSTANTS(:,88).*STATES(:,5).*(CONSTANTS(:,122) - STATES(:,35)) -  CONSTANTS(:,87).*STATES(:,35);
    RATES(:,36) =  CONSTANTS(:,88).*STATES(:,6).*(CONSTANTS(:,121) - STATES(:,36)) -  CONSTANTS(:,87).*STATES(:,36);
    RATES(:,37) =  CONSTANTS(:,90).*STATES(:,5).*(CONSTANTS(:,124) - STATES(:,37)) -  CONSTANTS(:,89).*STATES(:,37);
    RATES(:,38) =  CONSTANTS(:,90).*STATES(:,6).*(CONSTANTS(:,123) - STATES(:,38)) -  CONSTANTS(:,89).*STATES(:,38);
    RATES(:,39) =  CONSTANTS(:,92).*STATES(:,24).*(CONSTANTS(:,125) - STATES(:,39)) -  CONSTANTS(:,91).*STATES(:,39);
    RATES(:,12) =  (CONSTANTS(:,18)./CONSTANTS(:,115)).*(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(:,97) - (CONSTANTS(:,97) - CONSTANTS(:,98))./(1.00000+power(CONSTANTS(:,63)./STATES(:,24), 2.50000));
    ALGEBRAIC(:,24) = CONSTANTS(:,60)./ALGEBRAIC(:,11);
    ALGEBRAIC(:,28) =  CONSTANTS(:,108).*ALGEBRAIC(:,11);
    RATES(:,22) = ( ALGEBRAIC(:,24).*power(STATES(:,5), 2.00000).*STATES(:,21) -  CONSTANTS(:,61).*STATES(:,22)) - ( ALGEBRAIC(:,28).*STATES(:,5).*STATES(:,22) -  CONSTANTS(:,62).*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./(1.00000+exp(power((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(:,62).*ALGEBRAIC(:,32) -  ALGEBRAIC(:,28).*STATES(:,5).*STATES(:,21)) - ( ALGEBRAIC(:,24).*power(STATES(:,5), 2.00000).*STATES(:,21) -  CONSTANTS(:,61).*STATES(:,22));
    RATES(:,23) = ( ALGEBRAIC(:,28).*STATES(:,5).*STATES(:,22) -  CONSTANTS(:,62).*STATES(:,23)) - ( CONSTANTS(:,61).*STATES(:,23) -  ALGEBRAIC(:,24).*power(STATES(:,5), 2.00000).*ALGEBRAIC(:,32));
    ALGEBRAIC(:,99) =  (( CONSTANTS(:,59).*STATES(:,22))./1.00000).*(STATES(:,24) - STATES(:,5));
    ALGEBRAIC(:,100) = ( power(CONSTANTS(:,54), CONSTANTS(:,114)).*CONSTANTS(:,55).*(power(STATES(:,25)./CONSTANTS(:,56), CONSTANTS(:,58)) - power(STATES(:,24)./CONSTANTS(:,57), CONSTANTS(:,58))))./(1.00000+power(STATES(:,25)./CONSTANTS(:,56), CONSTANTS(:,58))+power(STATES(:,24)./CONSTANTS(:,57), CONSTANTS(:,58)));
    ALGEBRAIC(:,101) =  5.34800e-06.*(STATES(:,24) - STATES(:,5));
    RATES(:,24) = (ALGEBRAIC(:,100) - (( ALGEBRAIC(:,101).*CONSTANTS(:,115))./CONSTANTS(:,116)+ALGEBRAIC(:,99))) - ( CONSTANTS(:,92).*STATES(:,24).*(CONSTANTS(:,125) - STATES(:,39)) -  CONSTANTS(:,91).*STATES(:,39));
    ALGEBRAIC(:,102) = ((((((((((( CONSTANTS(:,70).*STATES(:,25).*(CONSTANTS(:,68) - STATES(:,28)) -  CONSTANTS(:,69).*STATES(:,28))+ CONSTANTS(:,73).*STATES(:,25).*((CONSTANTS(:,71) - STATES(:,29)) - STATES(:,30))) -  CONSTANTS(:,72).*STATES(:,29))+ CONSTANTS(:,75).*CONSTANTS(:,24).*((CONSTANTS(:,71) - STATES(:,29)) - STATES(:,30))) -  CONSTANTS(:,74).*STATES(:,30))+ CONSTANTS(:,78).*STATES(:,25).*(CONSTANTS(:,76) - STATES(:,31))) -  CONSTANTS(:,77).*STATES(:,31))+ CONSTANTS(:,81).*STATES(:,25).*((CONSTANTS(:,79) - STATES(:,32)) - STATES(:,33))) -  CONSTANTS(:,80).*STATES(:,32))+ CONSTANTS(:,83).*CONSTANTS(:,24).*((CONSTANTS(:,79) - STATES(:,32)) - STATES(:,33))) -  CONSTANTS(:,82).*STATES(:,33))+( CONSTANTS(:,86).*STATES(:,25).*(CONSTANTS(:,84) - STATES(:,34)) -  CONSTANTS(:,85).*STATES(:,34));
    RATES(:,25) = ((  - ALGEBRAIC(:,100).*CONSTANTS(:,116))./CONSTANTS(:,115) - ALGEBRAIC(:,102))+ (CONSTANTS(:,16)./CONSTANTS(:,115)).*(STATES(:,6) - STATES(:,25));
    ALGEBRAIC(:,103) =  CONSTANTS(:,67).*STATES(:,2).*(CONSTANTS(:,64) - STATES(:,26)) -  CONSTANTS(:,66).*STATES(:,26);
    RATES(:,26) = ALGEBRAIC(:,103);
    ALGEBRAIC(:,104) =  CONSTANTS(:,67).*STATES(:,3).*(CONSTANTS(:,65) - STATES(:,27)) -  CONSTANTS(:,66).*STATES(:,27);
    RATES(:,27) = ALGEBRAIC(:,104);
    ALGEBRAIC(:,27) =  (1.00000./CONSTANTS(:,113)).*log(CONSTANTS(:,22)./STATES(:,2));
    ALGEBRAIC(:,36) =  CONSTANTS(:,19).*CONSTANTS(:,25).*power(STATES(:,7), 3.00000).*STATES(:,8).*STATES(:,9).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,39) =  CONSTANTS(:,19).*CONSTANTS(:,26).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,42) = 1.00000./(1.00000+ 0.124500.*exp(  - 0.100000.*STATES(:,1).*CONSTANTS(:,113))+ 0.0365000.*CONSTANTS(:,104).*exp(  - STATES(:,1).*CONSTANTS(:,113)));
    ALGEBRAIC(:,43) = (( CONSTANTS(:,19).*CONSTANTS(:,27).*ALGEBRAIC(:,42).*CONSTANTS(:,21))./(1.00000+power(CONSTANTS(:,28)./STATES(:,2), 4.00000)))./(CONSTANTS(:,21)+CONSTANTS(:,29));
    ALGEBRAIC(:,70) = ( CONSTANTS(:,37).*STATES(:,1).*CONSTANTS(:,99).*CONSTANTS(:,113).*( 0.750000.*STATES(:,2).*exp( STATES(:,1).*CONSTANTS(:,113)) -  0.750000.*CONSTANTS(:,22)))./(exp( STATES(:,1).*CONSTANTS(:,113)) - 1.00000);
    ALGEBRAIC(:,76) =  CONSTANTS(:,20).*ALGEBRAIC(:,70).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,19))+CONSTANTS(:,96)).*power(CONSTANTS(:,40), CONSTANTS(:,114)).*0.450000.*1.00000;
    ALGEBRAIC(:,79) = 1.00000./(1.00000+power(CONSTANTS(:,48)./STATES(:,5), 2.00000));
    ALGEBRAIC(:,82) =  exp( CONSTANTS(:,47).*STATES(:,1).*CONSTANTS(:,113)).*power(STATES(:,2), 3.00000).*CONSTANTS(:,23);
    ALGEBRAIC(:,84) =  exp( (CONSTANTS(:,47) - 1.00000).*STATES(:,1).*CONSTANTS(:,113)).*power(CONSTANTS(:,22), 3.00000).*STATES(:,5);
    ALGEBRAIC(:,85) =  CONSTANTS(:,42).*power(CONSTANTS(:,22), 3.00000).*(1.00000+power(STATES(:,2)./CONSTANTS(:,44), 3.00000))+ power(CONSTANTS(:,45), 3.00000).*STATES(:,5).*(1.00000+STATES(:,5)./CONSTANTS(:,42))+ CONSTANTS(:,43).*power(STATES(:,2), 3.00000)+ power(STATES(:,2), 3.00000).*CONSTANTS(:,23)+ power(CONSTANTS(:,22), 3.00000).*STATES(:,5);
    ALGEBRAIC(:,88) = (( CONSTANTS(:,19).*CONSTANTS(:,41).*power(CONSTANTS(:,49), CONSTANTS(:,114)).*ALGEBRAIC(:,79).*(ALGEBRAIC(:,82) - ALGEBRAIC(:,84)))./ALGEBRAIC(:,85))./(1.00000+ CONSTANTS(:,46).*exp( (CONSTANTS(:,47) - 1.00000).*STATES(:,1).*CONSTANTS(:,113)));
    ALGEBRAIC(:,107) = ALGEBRAIC(:,36)+ALGEBRAIC(:,39)+ 3.00000.*ALGEBRAIC(:,88)+ 3.00000.*ALGEBRAIC(:,43)+ALGEBRAIC(:,76);
    RATES(:,2) = ((  - ALGEBRAIC(:,107).*CONSTANTS(:,6))./( CONSTANTS(:,118).*CONSTANTS(:,99))+ (CONSTANTS(:,17)./CONSTANTS(:,118)).*(STATES(:,3) - STATES(:,2))) - ALGEBRAIC(:,103);
    ALGEBRAIC(:,31) =  (1.00000./CONSTANTS(:,113)).*log(CONSTANTS(:,22)./STATES(:,3));
    ALGEBRAIC(:,37) =  CONSTANTS(:,102).*CONSTANTS(:,25).*power(STATES(:,7), 3.00000).*STATES(:,8).*STATES(:,9).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,40) =  CONSTANTS(:,102).*CONSTANTS(:,26).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,44) = (( CONSTANTS(:,102).*CONSTANTS(:,27).*ALGEBRAIC(:,42).*CONSTANTS(:,21))./(1.00000+power(CONSTANTS(:,28)./STATES(:,3), 4.00000)))./(CONSTANTS(:,21)+CONSTANTS(:,29));
    ALGEBRAIC(:,71) = ( CONSTANTS(:,37).*STATES(:,1).*CONSTANTS(:,99).*CONSTANTS(:,113).*( 0.750000.*STATES(:,3).*exp( STATES(:,1).*CONSTANTS(:,113)) -  0.750000.*CONSTANTS(:,22)))./(exp( STATES(:,1).*CONSTANTS(:,113)) - 1.00000);
    ALGEBRAIC(:,77) =  CONSTANTS(:,103).*ALGEBRAIC(:,71).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,20))+CONSTANTS(:,95)).*power(CONSTANTS(:,40), CONSTANTS(:,114)).*0.450000.*1.00000;
    ALGEBRAIC(:,81) = 1.00000./(1.00000+power(CONSTANTS(:,48)./STATES(:,6), 2.00000));
    ALGEBRAIC(:,83) =  exp( CONSTANTS(:,47).*STATES(:,1).*CONSTANTS(:,113)).*power(STATES(:,3), 3.00000).*CONSTANTS(:,23);
    ALGEBRAIC(:,86) =  exp( (CONSTANTS(:,47) - 1.00000).*STATES(:,1).*CONSTANTS(:,113)).*power(CONSTANTS(:,22), 3.00000).*STATES(:,6);
    ALGEBRAIC(:,87) =  CONSTANTS(:,42).*power(CONSTANTS(:,22), 3.00000).*(1.00000+power(STATES(:,3)./CONSTANTS(:,44), 3.00000))+ power(CONSTANTS(:,45), 3.00000).*STATES(:,6).*(1.00000+STATES(:,6)./CONSTANTS(:,42))+ CONSTANTS(:,43).*power(STATES(:,3), 3.00000)+ power(STATES(:,3), 3.00000).*CONSTANTS(:,23)+ power(CONSTANTS(:,22), 3.00000).*STATES(:,6);
    ALGEBRAIC(:,89) = (( CONSTANTS(:,102).*CONSTANTS(:,41).*power(CONSTANTS(:,49), CONSTANTS(:,114)).*ALGEBRAIC(:,81).*(ALGEBRAIC(:,83) - ALGEBRAIC(:,86)))./ALGEBRAIC(:,87))./(1.00000+ CONSTANTS(:,46).*exp( (CONSTANTS(:,47) - 1.00000).*STATES(:,1).*CONSTANTS(:,113)));
    ALGEBRAIC(:,108) = ALGEBRAIC(:,37)+ALGEBRAIC(:,40)+ 3.00000.*ALGEBRAIC(:,89)+ 3.00000.*ALGEBRAIC(:,44)+ALGEBRAIC(:,77);
    RATES(:,3) = ((  - ALGEBRAIC(:,108).*CONSTANTS(:,6))./( CONSTANTS(:,117).*CONSTANTS(:,99))+ (CONSTANTS(:,17)./CONSTANTS(:,117)).*(STATES(:,2) - STATES(:,3))+ (CONSTANTS(:,18)./CONSTANTS(:,117)).*(STATES(:,12) - STATES(:,3))) - ALGEBRAIC(:,104);
    ALGEBRAIC(:,105) = ( CONSTANTS(:,88).*STATES(:,5).*(CONSTANTS(:,122) - STATES(:,35)) -  CONSTANTS(:,87).*STATES(:,35))+( CONSTANTS(:,90).*STATES(:,5).*(CONSTANTS(:,124) - STATES(:,37)) -  CONSTANTS(:,89).*STATES(:,37));
    ALGEBRAIC(:,67) = ( CONSTANTS(:,38).*4.00000.*STATES(:,1).*CONSTANTS(:,99).*CONSTANTS(:,113).*( 0.341000.*STATES(:,5).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,113)) -  0.341000.*CONSTANTS(:,23)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,113)) - 1.00000);
    ALGEBRAIC(:,72) =  CONSTANTS(:,20).*ALGEBRAIC(:,67).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,19))+CONSTANTS(:,96)).*power(CONSTANTS(:,40), CONSTANTS(:,114)).*0.450000.*1.00000;
    ALGEBRAIC(:,92) = ( CONSTANTS(:,19).*power(CONSTANTS(:,53), CONSTANTS(:,114)).*CONSTANTS(:,50).*power(STATES(:,5), 1.60000))./(power(CONSTANTS(:,51), 1.60000)+power(STATES(:,5), 1.60000));
    ALGEBRAIC(:,34) =  ((1.00000./CONSTANTS(:,113))./2.00000).*log(CONSTANTS(:,23)./STATES(:,5));
    ALGEBRAIC(:,96) =  CONSTANTS(:,19).*CONSTANTS(:,52).*(STATES(:,1) - ALGEBRAIC(:,34));
    ALGEBRAIC(:,110) = (ALGEBRAIC(:,72)+ALGEBRAIC(:,96)+ALGEBRAIC(:,92)) -  2.00000.*ALGEBRAIC(:,88);
    RATES(:,5) = (((  - ALGEBRAIC(:,110).*CONSTANTS(:,6))./( CONSTANTS(:,118).*2.00000.*CONSTANTS(:,99))+ (CONSTANTS(:,15)./CONSTANTS(:,118)).*(STATES(:,6) - STATES(:,5))) - ALGEBRAIC(:,105))+( ALGEBRAIC(:,99).*CONSTANTS(:,116))./CONSTANTS(:,118)+( ALGEBRAIC(:,101).*CONSTANTS(:,115))./CONSTANTS(:,118);
    ALGEBRAIC(:,106) = ( CONSTANTS(:,88).*STATES(:,6).*(CONSTANTS(:,121) - STATES(:,36)) -  CONSTANTS(:,87).*STATES(:,36))+( CONSTANTS(:,90).*STATES(:,6).*(CONSTANTS(:,123) - STATES(:,38)) -  CONSTANTS(:,89).*STATES(:,38));
    ALGEBRAIC(:,68) = ( CONSTANTS(:,38).*4.00000.*STATES(:,1).*CONSTANTS(:,99).*CONSTANTS(:,113).*( 0.341000.*STATES(:,6).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,113)) -  0.341000.*CONSTANTS(:,23)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,113)) - 1.00000);
    ALGEBRAIC(:,73) =  CONSTANTS(:,103).*ALGEBRAIC(:,68).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,20))+CONSTANTS(:,95)).*power(CONSTANTS(:,40), CONSTANTS(:,114)).*0.450000.*1.00000;
    ALGEBRAIC(:,94) = ( CONSTANTS(:,102).*power(CONSTANTS(:,53), CONSTANTS(:,114)).*CONSTANTS(:,50).*power(STATES(:,6), 1.60000))./(power(CONSTANTS(:,51), 1.60000)+power(STATES(:,6), 1.60000));
    ALGEBRAIC(:,35) =  ((1.00000./CONSTANTS(:,113))./2.00000).*log(CONSTANTS(:,23)./STATES(:,6));
    ALGEBRAIC(:,97) =  CONSTANTS(:,102).*CONSTANTS(:,52).*(STATES(:,1) - ALGEBRAIC(:,35));
    ALGEBRAIC(:,111) = (ALGEBRAIC(:,73)+ALGEBRAIC(:,97)+ALGEBRAIC(:,94)) -  2.00000.*ALGEBRAIC(:,89);
    RATES(:,6) = ((  - ALGEBRAIC(:,111).*CONSTANTS(:,6))./( CONSTANTS(:,117).*2.00000.*CONSTANTS(:,99))+ (CONSTANTS(:,15)./CONSTANTS(:,117)).*(STATES(:,5) - STATES(:,6))+ (CONSTANTS(:,16)./CONSTANTS(:,117)).*(STATES(:,25) - STATES(:,6))) - ALGEBRAIC(:,106);
    ALGEBRAIC(:,10) = piecewise({VOI>500.000&VOI<5500.00, CONSTANTS(:,2) }, CONSTANTS(:,1));
    ALGEBRAIC(:,23) = (ALGEBRAIC(:,10) - STATES(:,1))./CONSTANTS(:,3);
    ALGEBRAIC(:,45) = ALGEBRAIC(:,43)+ALGEBRAIC(:,44);
    ALGEBRAIC(:,33) =  (1.00000./CONSTANTS(:,113)).*log(CONSTANTS(:,21)./STATES(:,4));
    ALGEBRAIC(:,46) = 1.00000./(1.00000+exp((STATES(:,1)+74.0000)./24.0000));
    ALGEBRAIC(:,47) =  CONSTANTS(:,105).*STATES(:,10).*ALGEBRAIC(:,46).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,48) = 1.00000./(1.00000+exp(7.48800 - STATES(:,1)./5.98000));
    ALGEBRAIC(:,49) =  CONSTANTS(:,19).*CONSTANTS(:,33).*ALGEBRAIC(:,48).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,50) =  CONSTANTS(:,102).*CONSTANTS(:,33).*ALGEBRAIC(:,48).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,51) = ALGEBRAIC(:,49)+ALGEBRAIC(:,50);
    ALGEBRAIC(:,52) =  (1.00000./CONSTANTS(:,113)).*log((CONSTANTS(:,21)+ CONSTANTS(:,32).*CONSTANTS(:,22))./(STATES(:,4)+ CONSTANTS(:,32).*STATES(:,12)));
    ALGEBRAIC(:,53) =  CONSTANTS(:,19).*CONSTANTS(:,93).*power(STATES(:,11), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,52));
    ALGEBRAIC(:,54) =  CONSTANTS(:,102).*CONSTANTS(:,94).*power(STATES(:,11), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,52));
    ALGEBRAIC(:,55) = ALGEBRAIC(:,53)+ALGEBRAIC(:,54);
    ALGEBRAIC(:,56) =  CONSTANTS(:,106).*STATES(:,13).*STATES(:,14).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,57) =  CONSTANTS(:,107).*STATES(:,15).*STATES(:,16).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,58) = ALGEBRAIC(:,56)+ALGEBRAIC(:,57);
    ALGEBRAIC(:,59) = 1.02000./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,33)) - 59.2150)));
    ALGEBRAIC(:,60) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1)+5.47600) - ALGEBRAIC(:,33)))+exp( 0.0617500.*((STATES(:,1) - ALGEBRAIC(:,33)) - 594.310)))./(1.00000+exp(  - 0.514300.*((STATES(:,1) - ALGEBRAIC(:,33))+4.75300)));
    ALGEBRAIC(:,61) = ALGEBRAIC(:,59)./(ALGEBRAIC(:,59)+ALGEBRAIC(:,60));
    ALGEBRAIC(:,62) =  1.00000.*0.350000.*power((CONSTANTS(:,21)./5.40000), 1.0 ./ 2).*ALGEBRAIC(:,61).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,69) = ( CONSTANTS(:,39).*STATES(:,1).*CONSTANTS(:,99).*CONSTANTS(:,113).*( 0.750000.*STATES(:,4).*exp( STATES(:,1).*CONSTANTS(:,113)) -  0.750000.*CONSTANTS(:,21)))./(exp( STATES(:,1).*CONSTANTS(:,113)) - 1.00000);
    ALGEBRAIC(:,75) =  ALGEBRAIC(:,69).*STATES(:,17).*STATES(:,18).*( CONSTANTS(:,20).*(CONSTANTS(:,96)+(1.00000 - STATES(:,19)))+ CONSTANTS(:,103).*(CONSTANTS(:,95)+(1.00000 - STATES(:,20)))).*power(CONSTANTS(:,40), CONSTANTS(:,114)).*0.450000.*1.00000;
    ALGEBRAIC(:,109) = ((ALGEBRAIC(:,58)+ALGEBRAIC(:,47)+ALGEBRAIC(:,55)+ALGEBRAIC(:,62)) -  2.00000.*ALGEBRAIC(:,45))+ALGEBRAIC(:,75)+ALGEBRAIC(:,51);
    ALGEBRAIC(:,112) = ALGEBRAIC(:,107)+ALGEBRAIC(:,108);
    ALGEBRAIC(:,63) =  (( CONSTANTS(:,19).*CONSTANTS(:,34))./(1.00000+CONSTANTS(:,36)./STATES(:,5))).*(STATES(:,1) - CONSTANTS(:,126));
    ALGEBRAIC(:,64) =  (( CONSTANTS(:,102).*CONSTANTS(:,34))./(1.00000+CONSTANTS(:,36)./STATES(:,6))).*(STATES(:,1) - CONSTANTS(:,126));
    ALGEBRAIC(:,65) = ALGEBRAIC(:,63)+ALGEBRAIC(:,64);
    ALGEBRAIC(:,66) =  CONSTANTS(:,35).*(STATES(:,1) - CONSTANTS(:,126));
    ALGEBRAIC(:,113) = ALGEBRAIC(:,65)+ALGEBRAIC(:,66);
    ALGEBRAIC(:,114) = ALGEBRAIC(:,110)+ALGEBRAIC(:,111);
    ALGEBRAIC(:,115) = ALGEBRAIC(:,112)+ALGEBRAIC(:,113)+ALGEBRAIC(:,114)+ALGEBRAIC(:,109);
    RATES(:,1) =  - (ALGEBRAIC(:,115) - ALGEBRAIC(:,23));
   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(:,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(:,97) - (CONSTANTS(:,97) - CONSTANTS(:,98))./(1.00000+power(CONSTANTS(:,63)./STATES(:,24), 2.50000));
    ALGEBRAIC(:,24) = CONSTANTS(:,60)./ALGEBRAIC(:,11);
    ALGEBRAIC(:,28) =  CONSTANTS(:,108).*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./(1.00000+exp(power((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(:,99) =  (( CONSTANTS(:,59).*STATES(:,22))./1.00000).*(STATES(:,24) - STATES(:,5));
    ALGEBRAIC(:,100) = ( power(CONSTANTS(:,54), CONSTANTS(:,114)).*CONSTANTS(:,55).*(power(STATES(:,25)./CONSTANTS(:,56), CONSTANTS(:,58)) - power(STATES(:,24)./CONSTANTS(:,57), CONSTANTS(:,58))))./(1.00000+power(STATES(:,25)./CONSTANTS(:,56), CONSTANTS(:,58))+power(STATES(:,24)./CONSTANTS(:,57), CONSTANTS(:,58)));
    ALGEBRAIC(:,101) =  5.34800e-06.*(STATES(:,24) - STATES(:,5));
    ALGEBRAIC(:,102) = ((((((((((( CONSTANTS(:,70).*STATES(:,25).*(CONSTANTS(:,68) - STATES(:,28)) -  CONSTANTS(:,69).*STATES(:,28))+ CONSTANTS(:,73).*STATES(:,25).*((CONSTANTS(:,71) - STATES(:,29)) - STATES(:,30))) -  CONSTANTS(:,72).*STATES(:,29))+ CONSTANTS(:,75).*CONSTANTS(:,24).*((CONSTANTS(:,71) - STATES(:,29)) - STATES(:,30))) -  CONSTANTS(:,74).*STATES(:,30))+ CONSTANTS(:,78).*STATES(:,25).*(CONSTANTS(:,76) - STATES(:,31))) -  CONSTANTS(:,77).*STATES(:,31))+ CONSTANTS(:,81).*STATES(:,25).*((CONSTANTS(:,79) - STATES(:,32)) - STATES(:,33))) -  CONSTANTS(:,80).*STATES(:,32))+ CONSTANTS(:,83).*CONSTANTS(:,24).*((CONSTANTS(:,79) - STATES(:,32)) - STATES(:,33))) -  CONSTANTS(:,82).*STATES(:,33))+( CONSTANTS(:,86).*STATES(:,25).*(CONSTANTS(:,84) - STATES(:,34)) -  CONSTANTS(:,85).*STATES(:,34));
    ALGEBRAIC(:,103) =  CONSTANTS(:,67).*STATES(:,2).*(CONSTANTS(:,64) - STATES(:,26)) -  CONSTANTS(:,66).*STATES(:,26);
    ALGEBRAIC(:,104) =  CONSTANTS(:,67).*STATES(:,3).*(CONSTANTS(:,65) - STATES(:,27)) -  CONSTANTS(:,66).*STATES(:,27);
    ALGEBRAIC(:,27) =  (1.00000./CONSTANTS(:,113)).*log(CONSTANTS(:,22)./STATES(:,2));
    ALGEBRAIC(:,36) =  CONSTANTS(:,19).*CONSTANTS(:,25).*power(STATES(:,7), 3.00000).*STATES(:,8).*STATES(:,9).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,39) =  CONSTANTS(:,19).*CONSTANTS(:,26).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,42) = 1.00000./(1.00000+ 0.124500.*exp(  - 0.100000.*STATES(:,1).*CONSTANTS(:,113))+ 0.0365000.*CONSTANTS(:,104).*exp(  - STATES(:,1).*CONSTANTS(:,113)));
    ALGEBRAIC(:,43) = (( CONSTANTS(:,19).*CONSTANTS(:,27).*ALGEBRAIC(:,42).*CONSTANTS(:,21))./(1.00000+power(CONSTANTS(:,28)./STATES(:,2), 4.00000)))./(CONSTANTS(:,21)+CONSTANTS(:,29));
    ALGEBRAIC(:,70) = ( CONSTANTS(:,37).*STATES(:,1).*CONSTANTS(:,99).*CONSTANTS(:,113).*( 0.750000.*STATES(:,2).*exp( STATES(:,1).*CONSTANTS(:,113)) -  0.750000.*CONSTANTS(:,22)))./(exp( STATES(:,1).*CONSTANTS(:,113)) - 1.00000);
    ALGEBRAIC(:,76) =  CONSTANTS(:,20).*ALGEBRAIC(:,70).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,19))+CONSTANTS(:,96)).*power(CONSTANTS(:,40), CONSTANTS(:,114)).*0.450000.*1.00000;
    ALGEBRAIC(:,79) = 1.00000./(1.00000+power(CONSTANTS(:,48)./STATES(:,5), 2.00000));
    ALGEBRAIC(:,82) =  exp( CONSTANTS(:,47).*STATES(:,1).*CONSTANTS(:,113)).*power(STATES(:,2), 3.00000).*CONSTANTS(:,23);
    ALGEBRAIC(:,84) =  exp( (CONSTANTS(:,47) - 1.00000).*STATES(:,1).*CONSTANTS(:,113)).*power(CONSTANTS(:,22), 3.00000).*STATES(:,5);
    ALGEBRAIC(:,85) =  CONSTANTS(:,42).*power(CONSTANTS(:,22), 3.00000).*(1.00000+power(STATES(:,2)./CONSTANTS(:,44), 3.00000))+ power(CONSTANTS(:,45), 3.00000).*STATES(:,5).*(1.00000+STATES(:,5)./CONSTANTS(:,42))+ CONSTANTS(:,43).*power(STATES(:,2), 3.00000)+ power(STATES(:,2), 3.00000).*CONSTANTS(:,23)+ power(CONSTANTS(:,22), 3.00000).*STATES(:,5);
    ALGEBRAIC(:,88) = (( CONSTANTS(:,19).*CONSTANTS(:,41).*power(CONSTANTS(:,49), CONSTANTS(:,114)).*ALGEBRAIC(:,79).*(ALGEBRAIC(:,82) - ALGEBRAIC(:,84)))./ALGEBRAIC(:,85))./(1.00000+ CONSTANTS(:,46).*exp( (CONSTANTS(:,47) - 1.00000).*STATES(:,1).*CONSTANTS(:,113)));
    ALGEBRAIC(:,107) = ALGEBRAIC(:,36)+ALGEBRAIC(:,39)+ 3.00000.*ALGEBRAIC(:,88)+ 3.00000.*ALGEBRAIC(:,43)+ALGEBRAIC(:,76);
    ALGEBRAIC(:,31) =  (1.00000./CONSTANTS(:,113)).*log(CONSTANTS(:,22)./STATES(:,3));
    ALGEBRAIC(:,37) =  CONSTANTS(:,102).*CONSTANTS(:,25).*power(STATES(:,7), 3.00000).*STATES(:,8).*STATES(:,9).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,40) =  CONSTANTS(:,102).*CONSTANTS(:,26).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,44) = (( CONSTANTS(:,102).*CONSTANTS(:,27).*ALGEBRAIC(:,42).*CONSTANTS(:,21))./(1.00000+power(CONSTANTS(:,28)./STATES(:,3), 4.00000)))./(CONSTANTS(:,21)+CONSTANTS(:,29));
    ALGEBRAIC(:,71) = ( CONSTANTS(:,37).*STATES(:,1).*CONSTANTS(:,99).*CONSTANTS(:,113).*( 0.750000.*STATES(:,3).*exp( STATES(:,1).*CONSTANTS(:,113)) -  0.750000.*CONSTANTS(:,22)))./(exp( STATES(:,1).*CONSTANTS(:,113)) - 1.00000);
    ALGEBRAIC(:,77) =  CONSTANTS(:,103).*ALGEBRAIC(:,71).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,20))+CONSTANTS(:,95)).*power(CONSTANTS(:,40), CONSTANTS(:,114)).*0.450000.*1.00000;
    ALGEBRAIC(:,81) = 1.00000./(1.00000+power(CONSTANTS(:,48)./STATES(:,6), 2.00000));
    ALGEBRAIC(:,83) =  exp( CONSTANTS(:,47).*STATES(:,1).*CONSTANTS(:,113)).*power(STATES(:,3), 3.00000).*CONSTANTS(:,23);
    ALGEBRAIC(:,86) =  exp( (CONSTANTS(:,47) - 1.00000).*STATES(:,1).*CONSTANTS(:,113)).*power(CONSTANTS(:,22), 3.00000).*STATES(:,6);
    ALGEBRAIC(:,87) =  CONSTANTS(:,42).*power(CONSTANTS(:,22), 3.00000).*(1.00000+power(STATES(:,3)./CONSTANTS(:,44), 3.00000))+ power(CONSTANTS(:,45), 3.00000).*STATES(:,6).*(1.00000+STATES(:,6)./CONSTANTS(:,42))+ CONSTANTS(:,43).*power(STATES(:,3), 3.00000)+ power(STATES(:,3), 3.00000).*CONSTANTS(:,23)+ power(CONSTANTS(:,22), 3.00000).*STATES(:,6);
    ALGEBRAIC(:,89) = (( CONSTANTS(:,102).*CONSTANTS(:,41).*power(CONSTANTS(:,49), CONSTANTS(:,114)).*ALGEBRAIC(:,81).*(ALGEBRAIC(:,83) - ALGEBRAIC(:,86)))./ALGEBRAIC(:,87))./(1.00000+ CONSTANTS(:,46).*exp( (CONSTANTS(:,47) - 1.00000).*STATES(:,1).*CONSTANTS(:,113)));
    ALGEBRAIC(:,108) = ALGEBRAIC(:,37)+ALGEBRAIC(:,40)+ 3.00000.*ALGEBRAIC(:,89)+ 3.00000.*ALGEBRAIC(:,44)+ALGEBRAIC(:,77);
    ALGEBRAIC(:,105) = ( CONSTANTS(:,88).*STATES(:,5).*(CONSTANTS(:,122) - STATES(:,35)) -  CONSTANTS(:,87).*STATES(:,35))+( CONSTANTS(:,90).*STATES(:,5).*(CONSTANTS(:,124) - STATES(:,37)) -  CONSTANTS(:,89).*STATES(:,37));
    ALGEBRAIC(:,67) = ( CONSTANTS(:,38).*4.00000.*STATES(:,1).*CONSTANTS(:,99).*CONSTANTS(:,113).*( 0.341000.*STATES(:,5).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,113)) -  0.341000.*CONSTANTS(:,23)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,113)) - 1.00000);
    ALGEBRAIC(:,72) =  CONSTANTS(:,20).*ALGEBRAIC(:,67).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,19))+CONSTANTS(:,96)).*power(CONSTANTS(:,40), CONSTANTS(:,114)).*0.450000.*1.00000;
    ALGEBRAIC(:,92) = ( CONSTANTS(:,19).*power(CONSTANTS(:,53), CONSTANTS(:,114)).*CONSTANTS(:,50).*power(STATES(:,5), 1.60000))./(power(CONSTANTS(:,51), 1.60000)+power(STATES(:,5), 1.60000));
    ALGEBRAIC(:,34) =  ((1.00000./CONSTANTS(:,113))./2.00000).*log(CONSTANTS(:,23)./STATES(:,5));
    ALGEBRAIC(:,96) =  CONSTANTS(:,19).*CONSTANTS(:,52).*(STATES(:,1) - ALGEBRAIC(:,34));
    ALGEBRAIC(:,110) = (ALGEBRAIC(:,72)+ALGEBRAIC(:,96)+ALGEBRAIC(:,92)) -  2.00000.*ALGEBRAIC(:,88);
    ALGEBRAIC(:,106) = ( CONSTANTS(:,88).*STATES(:,6).*(CONSTANTS(:,121) - STATES(:,36)) -  CONSTANTS(:,87).*STATES(:,36))+( CONSTANTS(:,90).*STATES(:,6).*(CONSTANTS(:,123) - STATES(:,38)) -  CONSTANTS(:,89).*STATES(:,38));
    ALGEBRAIC(:,68) = ( CONSTANTS(:,38).*4.00000.*STATES(:,1).*CONSTANTS(:,99).*CONSTANTS(:,113).*( 0.341000.*STATES(:,6).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,113)) -  0.341000.*CONSTANTS(:,23)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,113)) - 1.00000);
    ALGEBRAIC(:,73) =  CONSTANTS(:,103).*ALGEBRAIC(:,68).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,20))+CONSTANTS(:,95)).*power(CONSTANTS(:,40), CONSTANTS(:,114)).*0.450000.*1.00000;
    ALGEBRAIC(:,94) = ( CONSTANTS(:,102).*power(CONSTANTS(:,53), CONSTANTS(:,114)).*CONSTANTS(:,50).*power(STATES(:,6), 1.60000))./(power(CONSTANTS(:,51), 1.60000)+power(STATES(:,6), 1.60000));
    ALGEBRAIC(:,35) =  ((1.00000./CONSTANTS(:,113))./2.00000).*log(CONSTANTS(:,23)./STATES(:,6));
    ALGEBRAIC(:,97) =  CONSTANTS(:,102).*CONSTANTS(:,52).*(STATES(:,1) - ALGEBRAIC(:,35));
    ALGEBRAIC(:,111) = (ALGEBRAIC(:,73)+ALGEBRAIC(:,97)+ALGEBRAIC(:,94)) -  2.00000.*ALGEBRAIC(:,89);
    ALGEBRAIC(:,10) = piecewise({VOI>500.000&VOI<5500.00, CONSTANTS(:,2) }, CONSTANTS(:,1));
    ALGEBRAIC(:,23) = (ALGEBRAIC(:,10) - STATES(:,1))./CONSTANTS(:,3);
    ALGEBRAIC(:,45) = ALGEBRAIC(:,43)+ALGEBRAIC(:,44);
    ALGEBRAIC(:,33) =  (1.00000./CONSTANTS(:,113)).*log(CONSTANTS(:,21)./STATES(:,4));
    ALGEBRAIC(:,46) = 1.00000./(1.00000+exp((STATES(:,1)+74.0000)./24.0000));
    ALGEBRAIC(:,47) =  CONSTANTS(:,105).*STATES(:,10).*ALGEBRAIC(:,46).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,48) = 1.00000./(1.00000+exp(7.48800 - STATES(:,1)./5.98000));
    ALGEBRAIC(:,49) =  CONSTANTS(:,19).*CONSTANTS(:,33).*ALGEBRAIC(:,48).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,50) =  CONSTANTS(:,102).*CONSTANTS(:,33).*ALGEBRAIC(:,48).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,51) = ALGEBRAIC(:,49)+ALGEBRAIC(:,50);
    ALGEBRAIC(:,52) =  (1.00000./CONSTANTS(:,113)).*log((CONSTANTS(:,21)+ CONSTANTS(:,32).*CONSTANTS(:,22))./(STATES(:,4)+ CONSTANTS(:,32).*STATES(:,12)));
    ALGEBRAIC(:,53) =  CONSTANTS(:,19).*CONSTANTS(:,93).*power(STATES(:,11), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,52));
    ALGEBRAIC(:,54) =  CONSTANTS(:,102).*CONSTANTS(:,94).*power(STATES(:,11), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,52));
    ALGEBRAIC(:,55) = ALGEBRAIC(:,53)+ALGEBRAIC(:,54);
    ALGEBRAIC(:,56) =  CONSTANTS(:,106).*STATES(:,13).*STATES(:,14).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,57) =  CONSTANTS(:,107).*STATES(:,15).*STATES(:,16).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,58) = ALGEBRAIC(:,56)+ALGEBRAIC(:,57);
    ALGEBRAIC(:,59) = 1.02000./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,33)) - 59.2150)));
    ALGEBRAIC(:,60) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1)+5.47600) - ALGEBRAIC(:,33)))+exp( 0.0617500.*((STATES(:,1) - ALGEBRAIC(:,33)) - 594.310)))./(1.00000+exp(  - 0.514300.*((STATES(:,1) - ALGEBRAIC(:,33))+4.75300)));
    ALGEBRAIC(:,61) = ALGEBRAIC(:,59)./(ALGEBRAIC(:,59)+ALGEBRAIC(:,60));
    ALGEBRAIC(:,62) =  1.00000.*0.350000.*power((CONSTANTS(:,21)./5.40000), 1.0 ./ 2).*ALGEBRAIC(:,61).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,69) = ( CONSTANTS(:,39).*STATES(:,1).*CONSTANTS(:,99).*CONSTANTS(:,113).*( 0.750000.*STATES(:,4).*exp( STATES(:,1).*CONSTANTS(:,113)) -  0.750000.*CONSTANTS(:,21)))./(exp( STATES(:,1).*CONSTANTS(:,113)) - 1.00000);
    ALGEBRAIC(:,75) =  ALGEBRAIC(:,69).*STATES(:,17).*STATES(:,18).*( CONSTANTS(:,20).*(CONSTANTS(:,96)+(1.00000 - STATES(:,19)))+ CONSTANTS(:,103).*(CONSTANTS(:,95)+(1.00000 - STATES(:,20)))).*power(CONSTANTS(:,40), CONSTANTS(:,114)).*0.450000.*1.00000;
    ALGEBRAIC(:,109) = ((ALGEBRAIC(:,58)+ALGEBRAIC(:,47)+ALGEBRAIC(:,55)+ALGEBRAIC(:,62)) -  2.00000.*ALGEBRAIC(:,45))+ALGEBRAIC(:,75)+ALGEBRAIC(:,51);
    ALGEBRAIC(:,112) = ALGEBRAIC(:,107)+ALGEBRAIC(:,108);
    ALGEBRAIC(:,63) =  (( CONSTANTS(:,19).*CONSTANTS(:,34))./(1.00000+CONSTANTS(:,36)./STATES(:,5))).*(STATES(:,1) - CONSTANTS(:,126));
    ALGEBRAIC(:,64) =  (( CONSTANTS(:,102).*CONSTANTS(:,34))./(1.00000+CONSTANTS(:,36)./STATES(:,6))).*(STATES(:,1) - CONSTANTS(:,126));
    ALGEBRAIC(:,65) = ALGEBRAIC(:,63)+ALGEBRAIC(:,64);
    ALGEBRAIC(:,66) =  CONSTANTS(:,35).*(STATES(:,1) - CONSTANTS(:,126));
    ALGEBRAIC(:,113) = ALGEBRAIC(:,65)+ALGEBRAIC(:,66);
    ALGEBRAIC(:,114) = ALGEBRAIC(:,110)+ALGEBRAIC(:,111);
    ALGEBRAIC(:,115) = ALGEBRAIC(:,112)+ALGEBRAIC(:,113)+ALGEBRAIC(:,114)+ALGEBRAIC(:,109);
    ALGEBRAIC(:,38) = ALGEBRAIC(:,36)+ALGEBRAIC(:,37);
    ALGEBRAIC(:,41) = ALGEBRAIC(:,39)+ALGEBRAIC(:,40);
    ALGEBRAIC(:,74) = ALGEBRAIC(:,72)+ALGEBRAIC(:,73);
    ALGEBRAIC(:,78) = ALGEBRAIC(:,76)+ALGEBRAIC(:,77);
    ALGEBRAIC(:,80) = ALGEBRAIC(:,74)+ALGEBRAIC(:,75)+ALGEBRAIC(:,78);
    ALGEBRAIC(:,90) =  3.00000.*ALGEBRAIC(:,88)+ 3.00000.*ALGEBRAIC(:,43)+ALGEBRAIC(:,76);
    ALGEBRAIC(:,91) = ALGEBRAIC(:,88)+ALGEBRAIC(:,89);
    ALGEBRAIC(:,93) =  3.00000.*ALGEBRAIC(:,89)+ 3.00000.*ALGEBRAIC(:,44)+ALGEBRAIC(:,77);
    ALGEBRAIC(:,95) = ALGEBRAIC(:,92)+ALGEBRAIC(:,94);
    ALGEBRAIC(:,98) = ALGEBRAIC(:,96)+ALGEBRAIC(:,97);
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

Source
Derived from workspace Grandi, Pasqualini and Bers, 2010 at changeset ef586db92da0.
This exposure was expired. A more up-to-date exposure is available, or view related resources.
Collaboration
To begin collaborating on this work, please use your git client and issue this command:
License

This work is licensed under a Creative Commons Attribution 3.0 Unported License.