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

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

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

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

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

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

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

function [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends()
    LEGEND_STATES = ''; LEGEND_ALGEBRAIC = ''; LEGEND_VOI = ''; LEGEND_CONSTANTS = '';
    LEGEND_VOI = strpad('time in component environment (millisecond)');
    LEGEND_CONSTANTS(:,1) = strpad('celltype in component environment (dimensionless)');
    LEGEND_CONSTANTS(:,2) = strpad('nao in component extracellular (millimolar)');
    LEGEND_CONSTANTS(:,3) = strpad('cao in component extracellular (millimolar)');
    LEGEND_CONSTANTS(:,4) = strpad('ko in component extracellular (millimolar)');
    LEGEND_CONSTANTS(:,5) = strpad('clo in component extracellular (millimolar)');
    LEGEND_CONSTANTS(:,6) = strpad('R in component physical_constants (joule_per_kilomole_kelvin)');
    LEGEND_CONSTANTS(:,7) = strpad('T in component physical_constants (kelvin)');
    LEGEND_CONSTANTS(:,8) = strpad('F in component physical_constants (coulomb_per_mole)');
    LEGEND_CONSTANTS(:,9) = strpad('zna in component physical_constants (dimensionless)');
    LEGEND_CONSTANTS(:,10) = strpad('zca in component physical_constants (dimensionless)');
    LEGEND_CONSTANTS(:,11) = strpad('zk in component physical_constants (dimensionless)');
    LEGEND_CONSTANTS(:,12) = strpad('zcl in component physical_constants (dimensionless)');
    LEGEND_CONSTANTS(:,13) = strpad('L in component cell_geometry (centimeter)');
    LEGEND_CONSTANTS(:,14) = strpad('rad in component cell_geometry (centimeter)');
    LEGEND_CONSTANTS(:,113) = strpad('vcell in component cell_geometry (microliter)');
    LEGEND_CONSTANTS(:,131) = strpad('Ageo in component cell_geometry (centimeter_squared)');
    LEGEND_CONSTANTS(:,137) = strpad('Acap in component cell_geometry (centimeter_squared)');
    LEGEND_CONSTANTS(:,143) = strpad('vmyo in component cell_geometry (microliter)');
    LEGEND_CONSTANTS(:,144) = strpad('vnsr in component cell_geometry (microliter)');
    LEGEND_CONSTANTS(:,145) = strpad('vjsr in component cell_geometry (microliter)');
    LEGEND_CONSTANTS(:,146) = strpad('vss in component cell_geometry (microliter)');
    LEGEND_STATES(:,1) = strpad('v in component membrane (millivolt)');
    LEGEND_ALGEBRAIC(:,26) = strpad('vffrt in component membrane (coulomb_per_mole)');
    LEGEND_ALGEBRAIC(:,29) = strpad('vfrt in component membrane (dimensionless)');
    LEGEND_ALGEBRAIC(:,69) = strpad('INa in component INa (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,71) = strpad('INaL in component INaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,77) = strpad('Ito in component Ito (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,113) = strpad('ICaL in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,114) = strpad('ICaNa in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,115) = strpad('ICaK in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,116) = strpad('IKr in component IKr (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,118) = strpad('IKs in component IKs (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,122) = strpad('IK1 in component IK1 (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,154) = strpad('INaCa_i in component INaCa (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,184) = strpad('INaCa_ss in component INaCa (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,203) = strpad('INaK in component INaK (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,206) = strpad('INab in component INab (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,205) = strpad('IKb in component IKb (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,210) = strpad('IpCa in component IpCa (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,208) = strpad('ICab in component ICab (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,215) = strpad('IClCa in component ICl (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,217) = strpad('IClb in component ICl (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,67) = strpad('I_katp in component I_katp (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,12) = strpad('Istim in component membrane (microA_per_microF)');
    LEGEND_CONSTANTS(:,15) = strpad('i_Stim_Start in component membrane (millisecond)');
    LEGEND_CONSTANTS(:,16) = strpad('i_Stim_End in component membrane (millisecond)');
    LEGEND_CONSTANTS(:,17) = strpad('i_Stim_Amplitude in component membrane (microA_per_microF)');
    LEGEND_CONSTANTS(:,18) = strpad('i_Stim_Period in component membrane (millisecond)');
    LEGEND_CONSTANTS(:,19) = strpad('i_Stim_PulseDuration in component membrane (millisecond)');
    LEGEND_CONSTANTS(:,20) = strpad('KmCaMK in component CaMK (millimolar)');
    LEGEND_CONSTANTS(:,21) = strpad('aCaMK in component CaMK (per_millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,22) = strpad('bCaMK in component CaMK (per_millisecond)');
    LEGEND_CONSTANTS(:,23) = strpad('CaMKo in component CaMK (dimensionless)');
    LEGEND_CONSTANTS(:,24) = strpad('KmCaM in component CaMK (millimolar)');
    LEGEND_ALGEBRAIC(:,44) = strpad('CaMKb in component CaMK (millimolar)');
    LEGEND_ALGEBRAIC(:,50) = strpad('CaMKa in component CaMK (millimolar)');
    LEGEND_STATES(:,2) = strpad('CaMKt in component CaMK (millimolar)');
    LEGEND_STATES(:,3) = strpad('cass in component intracellular_ions (millimolar)');
    LEGEND_CONSTANTS(:,25) = strpad('cmdnmax_b in component intracellular_ions (millimolar)');
    LEGEND_CONSTANTS(:,114) = strpad('cmdnmax in component intracellular_ions (millimolar)');
    LEGEND_CONSTANTS(:,26) = strpad('kmcmdn in component intracellular_ions (millimolar)');
    LEGEND_CONSTANTS(:,27) = strpad('trpnmax in component intracellular_ions (millimolar)');
    LEGEND_CONSTANTS(:,28) = strpad('kmtrpn in component intracellular_ions (millimolar)');
    LEGEND_CONSTANTS(:,29) = strpad('BSRmax in component intracellular_ions (millimolar)');
    LEGEND_CONSTANTS(:,30) = strpad('KmBSR in component intracellular_ions (millimolar)');
    LEGEND_CONSTANTS(:,31) = strpad('BSLmax in component intracellular_ions (millimolar)');
    LEGEND_CONSTANTS(:,32) = strpad('KmBSL in component intracellular_ions (millimolar)');
    LEGEND_CONSTANTS(:,33) = strpad('csqnmax in component intracellular_ions (millimolar)');
    LEGEND_CONSTANTS(:,34) = strpad('kmcsqn in component intracellular_ions (millimolar)');
    LEGEND_STATES(:,4) = strpad('nai in component intracellular_ions (millimolar)');
    LEGEND_STATES(:,5) = strpad('nass in component intracellular_ions (millimolar)');
    LEGEND_STATES(:,6) = strpad('ki in component intracellular_ions (millimolar)');
    LEGEND_STATES(:,7) = strpad('kss in component intracellular_ions (millimolar)');
    LEGEND_STATES(:,8) = strpad('cansr in component intracellular_ions (millimolar)');
    LEGEND_STATES(:,9) = strpad('cajsr in component intracellular_ions (millimolar)');
    LEGEND_STATES(:,10) = strpad('cai in component intracellular_ions (millimolar)');
    LEGEND_CONSTANTS(:,35) = strpad('cli in component intracellular_ions (millimolar)');
    LEGEND_ALGEBRAIC(:,92) = strpad('ICaL_ss in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,93) = strpad('ICaNa_ss in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,96) = strpad('ICaK_ss in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,110) = strpad('ICaL_i in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,111) = strpad('ICaNa_i in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,112) = strpad('ICaK_i in component ICaL (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,209) = strpad('JdiffNa in component diff (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,212) = strpad('Jdiff in component diff (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,222) = strpad('Jup in component SERCA (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,207) = strpad('JdiffK in component diff (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,216) = strpad('Jrel in component ryr (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,223) = strpad('Jtr in component trans_flux (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,54) = strpad('Bcai in component intracellular_ions (dimensionless)');
    LEGEND_ALGEBRAIC(:,60) = strpad('Bcajsr in component intracellular_ions (dimensionless)');
    LEGEND_ALGEBRAIC(:,57) = strpad('Bcass in component intracellular_ions (dimensionless)');
    LEGEND_CONSTANTS(:,36) = strpad('PKNa in component reversal_potentials (dimensionless)');
    LEGEND_ALGEBRAIC(:,64) = strpad('ENa in component reversal_potentials (millivolt)');
    LEGEND_ALGEBRAIC(:,65) = strpad('EK in component reversal_potentials (millivolt)');
    LEGEND_ALGEBRAIC(:,66) = strpad('EKs in component reversal_potentials (millivolt)');
    LEGEND_CONSTANTS(:,115) = strpad('ECl in component reversal_potentials (millivolt)');
    LEGEND_CONSTANTS(:,37) = strpad('gkatp in component I_katp (milliS_per_microF)');
    LEGEND_CONSTANTS(:,38) = strpad('fkatp in component I_katp (dimensionless)');
    LEGEND_CONSTANTS(:,39) = strpad('K_o_n in component I_katp (millimolar)');
    LEGEND_CONSTANTS(:,40) = strpad('A_atp in component I_katp (millimolar)');
    LEGEND_CONSTANTS(:,41) = strpad('K_atp in component I_katp (millimolar)');
    LEGEND_CONSTANTS(:,116) = strpad('akik in component I_katp (dimensionless)');
    LEGEND_CONSTANTS(:,117) = strpad('bkik in component I_katp (dimensionless)');
    LEGEND_ALGEBRAIC(:,1) = strpad('mss in component INa (dimensionless)');
    LEGEND_ALGEBRAIC(:,14) = strpad('tm in component INa (millisecond)');
    LEGEND_STATES(:,11) = strpad('m in component INa (dimensionless)');
    LEGEND_ALGEBRAIC(:,2) = strpad('hss in component INa (dimensionless)');
    LEGEND_ALGEBRAIC(:,15) = strpad('ah in component INa (dimensionless)');
    LEGEND_ALGEBRAIC(:,30) = strpad('bh in component INa (dimensionless)');
    LEGEND_ALGEBRAIC(:,38) = strpad('th in component INa (millisecond)');
    LEGEND_STATES(:,12) = strpad('h in component INa (dimensionless)');
    LEGEND_ALGEBRAIC(:,39) = strpad('jss in component INa (dimensionless)');
    LEGEND_ALGEBRAIC(:,16) = strpad('aj in component INa (dimensionless)');
    LEGEND_ALGEBRAIC(:,31) = strpad('bj in component INa (dimensionless)');
    LEGEND_ALGEBRAIC(:,45) = strpad('tj in component INa (millisecond)');
    LEGEND_STATES(:,13) = strpad('j in component INa (dimensionless)');
    LEGEND_ALGEBRAIC(:,46) = strpad('hssp in component INa (dimensionless)');
    LEGEND_STATES(:,14) = strpad('hp in component INa (dimensionless)');
    LEGEND_ALGEBRAIC(:,51) = strpad('tjp in component INa (millisecond)');
    LEGEND_STATES(:,15) = strpad('jp in component INa (dimensionless)');
    LEGEND_ALGEBRAIC(:,68) = strpad('fINap in component INa (dimensionless)');
    LEGEND_CONSTANTS(:,42) = strpad('GNa in component INa (milliS_per_microF)');
    LEGEND_ALGEBRAIC(:,3) = strpad('mLss in component INaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,17) = strpad('tmL in component INaL (millisecond)');
    LEGEND_STATES(:,16) = strpad('mL in component INaL (dimensionless)');
    LEGEND_CONSTANTS(:,43) = strpad('thL in component INaL (millisecond)');
    LEGEND_ALGEBRAIC(:,4) = strpad('hLss in component INaL (dimensionless)');
    LEGEND_STATES(:,17) = strpad('hL in component INaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,5) = strpad('hLssp in component INaL (dimensionless)');
    LEGEND_CONSTANTS(:,118) = strpad('thLp in component INaL (millisecond)');
    LEGEND_STATES(:,18) = strpad('hLp in component INaL (dimensionless)');
    LEGEND_CONSTANTS(:,44) = strpad('GNaL_b in component INaL (milliS_per_microF)');
    LEGEND_CONSTANTS(:,119) = strpad('GNaL in component INaL (milliS_per_microF)');
    LEGEND_ALGEBRAIC(:,70) = strpad('fINaLp in component INaL (dimensionless)');
    LEGEND_CONSTANTS(:,45) = strpad('Gto_b in component Ito (milliS_per_microF)');
    LEGEND_ALGEBRAIC(:,6) = strpad('ass in component Ito (dimensionless)');
    LEGEND_ALGEBRAIC(:,18) = strpad('ta in component Ito (millisecond)');
    LEGEND_STATES(:,19) = strpad('a in component Ito (dimensionless)');
    LEGEND_CONSTANTS(:,46) = strpad('EKshift in component Ito (millivolt)');
    LEGEND_ALGEBRAIC(:,7) = strpad('iss in component Ito (dimensionless)');
    LEGEND_ALGEBRAIC(:,19) = strpad('delta_epi in component Ito (dimensionless)');
    LEGEND_ALGEBRAIC(:,32) = strpad('tiF_b in component Ito (millisecond)');
    LEGEND_ALGEBRAIC(:,40) = strpad('tiS_b in component Ito (millisecond)');
    LEGEND_ALGEBRAIC(:,47) = strpad('tiF in component Ito (millisecond)');
    LEGEND_ALGEBRAIC(:,52) = strpad('tiS in component Ito (millisecond)');
    LEGEND_ALGEBRAIC(:,72) = strpad('AiF in component Ito (dimensionless)');
    LEGEND_ALGEBRAIC(:,73) = strpad('AiS in component Ito (dimensionless)');
    LEGEND_STATES(:,20) = strpad('iF in component Ito (dimensionless)');
    LEGEND_STATES(:,21) = strpad('iS in component Ito (dimensionless)');
    LEGEND_ALGEBRAIC(:,74) = strpad('i in component Ito (dimensionless)');
    LEGEND_ALGEBRAIC(:,33) = strpad('assp in component Ito (dimensionless)');
    LEGEND_STATES(:,22) = strpad('ap in component Ito (dimensionless)');
    LEGEND_ALGEBRAIC(:,55) = strpad('dti_develop in component Ito (dimensionless)');
    LEGEND_ALGEBRAIC(:,58) = strpad('dti_recover in component Ito (dimensionless)');
    LEGEND_ALGEBRAIC(:,61) = strpad('tiFp in component Ito (millisecond)');
    LEGEND_ALGEBRAIC(:,62) = strpad('tiSp in component Ito (millisecond)');
    LEGEND_STATES(:,23) = strpad('iFp in component Ito (dimensionless)');
    LEGEND_STATES(:,24) = strpad('iSp in component Ito (dimensionless)');
    LEGEND_ALGEBRAIC(:,75) = strpad('ip in component Ito (dimensionless)');
    LEGEND_CONSTANTS(:,120) = strpad('Gto in component Ito (milliS_per_microF)');
    LEGEND_ALGEBRAIC(:,76) = strpad('fItop in component Ito (dimensionless)');
    LEGEND_CONSTANTS(:,47) = strpad('Kmn in component ICaL (millimolar)');
    LEGEND_CONSTANTS(:,48) = strpad('k2n in component ICaL (per_millisecond)');
    LEGEND_CONSTANTS(:,49) = strpad('PCa_b in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,8) = strpad('dss in component ICaL (dimensionless)');
    LEGEND_STATES(:,25) = strpad('d in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,9) = strpad('fss in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,50) = strpad('Aff in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,121) = strpad('Afs in component ICaL (dimensionless)');
    LEGEND_STATES(:,26) = strpad('ff in component ICaL (dimensionless)');
    LEGEND_STATES(:,27) = strpad('fs in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,78) = strpad('f in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,20) = strpad('fcass in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,10) = strpad('jcass in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,79) = strpad('Afcaf in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,80) = strpad('Afcas in component ICaL (dimensionless)');
    LEGEND_STATES(:,28) = strpad('fcaf in component ICaL (dimensionless)');
    LEGEND_STATES(:,29) = strpad('fcas in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,81) = strpad('fca in component ICaL (dimensionless)');
    LEGEND_STATES(:,30) = strpad('jca in component ICaL (dimensionless)');
    LEGEND_STATES(:,31) = strpad('ffp in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,82) = strpad('fp in component ICaL (dimensionless)');
    LEGEND_STATES(:,32) = strpad('fcafp in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,83) = strpad('fcap in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,11) = strpad('km2n in component ICaL (per_millisecond)');
    LEGEND_ALGEBRAIC(:,21) = strpad('anca_ss in component ICaL (dimensionless)');
    LEGEND_STATES(:,33) = strpad('nca_ss in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,22) = strpad('anca_i in component ICaL (dimensionless)');
    LEGEND_STATES(:,34) = strpad('nca_i in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,88) = strpad('PhiCaL_ss in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,89) = strpad('PhiCaNa_ss in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,90) = strpad('PhiCaK_ss in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,107) = strpad('PhiCaL_i in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,108) = strpad('PhiCaNa_i in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,109) = strpad('PhiCaK_i in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,122) = strpad('PCa in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,132) = strpad('PCap in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,133) = strpad('PCaNa in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,134) = strpad('PCaK in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,138) = strpad('PCaNap in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,139) = strpad('PCaKp in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,91) = strpad('fICaLp in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,23) = strpad('td in component ICaL (millisecond)');
    LEGEND_ALGEBRAIC(:,24) = strpad('tff in component ICaL (millisecond)');
    LEGEND_ALGEBRAIC(:,25) = strpad('tfs in component ICaL (millisecond)');
    LEGEND_ALGEBRAIC(:,34) = strpad('tfcaf in component ICaL (millisecond)');
    LEGEND_ALGEBRAIC(:,35) = strpad('tfcas in component ICaL (millisecond)');
    LEGEND_CONSTANTS(:,51) = strpad('tjca in component ICaL (millisecond)');
    LEGEND_ALGEBRAIC(:,36) = strpad('tffp in component ICaL (millisecond)');
    LEGEND_ALGEBRAIC(:,41) = strpad('tfcafp in component ICaL (millisecond)');
    LEGEND_CONSTANTS(:,52) = strpad('vShift in component ICaL (millivolt)');
    LEGEND_CONSTANTS(:,53) = strpad('offset in component ICaL (millisecond)');
    LEGEND_CONSTANTS(:,123) = strpad('Io in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,84) = strpad('Iss in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,99) = strpad('Ii in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,54) = strpad('dielConstant in component ICaL (per_kelvin)');
    LEGEND_CONSTANTS(:,135) = strpad('constA in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,140) = strpad('gamma_cao in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,85) = strpad('gamma_cass in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,102) = strpad('gamma_cai in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,141) = strpad('gamma_nao in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,86) = strpad('gamma_nass in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,105) = strpad('gamma_nai in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,142) = strpad('gamma_ko in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,87) = strpad('gamma_kss in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,106) = strpad('gamma_ki in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,55) = strpad('ICaL_fractionSS in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,56) = strpad('GKr_b in component IKr (milliS_per_microF)');
    LEGEND_STATES(:,35) = strpad('C1 in component IKr (dimensionless)');
    LEGEND_STATES(:,36) = strpad('C2 in component IKr (dimensionless)');
    LEGEND_STATES(:,37) = strpad('C3 in component IKr (dimensionless)');
    LEGEND_STATES(:,38) = strpad('I in component IKr (dimensionless)');
    LEGEND_STATES(:,39) = strpad('O in component IKr (dimensionless)');
    LEGEND_ALGEBRAIC(:,42) = strpad('alpha in component IKr (per_millisecond)');
    LEGEND_ALGEBRAIC(:,48) = strpad('beta in component IKr (per_millisecond)');
    LEGEND_CONSTANTS(:,57) = strpad('alpha_1 in component IKr (per_millisecond)');
    LEGEND_CONSTANTS(:,58) = strpad('beta_1 in component IKr (per_millisecond)');
    LEGEND_ALGEBRAIC(:,43) = strpad('alpha_2 in component IKr (per_millisecond)');
    LEGEND_ALGEBRAIC(:,49) = strpad('beta_2 in component IKr (per_millisecond)');
    LEGEND_ALGEBRAIC(:,53) = strpad('alpha_i in component IKr (per_millisecond)');
    LEGEND_ALGEBRAIC(:,56) = strpad('beta_i in component IKr (per_millisecond)');
    LEGEND_ALGEBRAIC(:,59) = strpad('alpha_C2ToI in component IKr (per_millisecond)');
    LEGEND_ALGEBRAIC(:,63) = strpad('beta_ItoC2 in component IKr (per_millisecond)');
    LEGEND_CONSTANTS(:,124) = strpad('GKr in component IKr (milliS_per_microF)');
    LEGEND_CONSTANTS(:,59) = strpad('GKs_b in component IKs (milliS_per_microF)');
    LEGEND_CONSTANTS(:,125) = strpad('GKs in component IKs (milliS_per_microF)');
    LEGEND_ALGEBRAIC(:,13) = strpad('xs1ss in component IKs (dimensionless)');
    LEGEND_ALGEBRAIC(:,27) = strpad('xs2ss in component IKs (dimensionless)');
    LEGEND_ALGEBRAIC(:,28) = strpad('txs1 in component IKs (millisecond)');
    LEGEND_STATES(:,40) = strpad('xs1 in component IKs (dimensionless)');
    LEGEND_STATES(:,41) = strpad('xs2 in component IKs (dimensionless)');
    LEGEND_ALGEBRAIC(:,117) = strpad('KsCa in component IKs (dimensionless)');
    LEGEND_ALGEBRAIC(:,37) = strpad('txs2 in component IKs (millisecond)');
    LEGEND_CONSTANTS(:,126) = strpad('GK1 in component IK1 (milliS_per_microF)');
    LEGEND_CONSTANTS(:,60) = strpad('GK1_b in component IK1 (milliS_per_microF)');
    LEGEND_ALGEBRAIC(:,119) = strpad('aK1 in component IK1 (dimensionless)');
    LEGEND_ALGEBRAIC(:,120) = strpad('bK1 in component IK1 (dimensionless)');
    LEGEND_ALGEBRAIC(:,121) = strpad('K1ss in component IK1 (dimensionless)');
    LEGEND_CONSTANTS(:,61) = strpad('INaCa_fractionSS in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,62) = strpad('kna1 in component INaCa (per_millisecond)');
    LEGEND_CONSTANTS(:,63) = strpad('kna2 in component INaCa (per_millisecond)');
    LEGEND_CONSTANTS(:,64) = strpad('kna3 in component INaCa (per_millisecond)');
    LEGEND_CONSTANTS(:,65) = strpad('kasymm in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,66) = strpad('wna in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,67) = strpad('wca in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,68) = strpad('wnaca in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,69) = strpad('kcaon in component INaCa (per_millisecond)');
    LEGEND_CONSTANTS(:,70) = strpad('kcaoff in component INaCa (per_millisecond)');
    LEGEND_CONSTANTS(:,71) = strpad('qna in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,72) = strpad('qca in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,124) = strpad('hna in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,123) = strpad('hca in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,73) = strpad('KmCaAct in component INaCa (millimolar)');
    LEGEND_CONSTANTS(:,74) = strpad('Gncx_b in component INaCa (milliS_per_microF)');
    LEGEND_CONSTANTS(:,153) = strpad('Gncx in component INaCa (milliS_per_microF)');
    LEGEND_ALGEBRAIC(:,125) = strpad('h1_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,126) = strpad('h2_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,127) = strpad('h3_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,128) = strpad('h4_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,129) = strpad('h5_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,130) = strpad('h6_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,131) = strpad('h7_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,132) = strpad('h8_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,133) = strpad('h9_i in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,147) = strpad('h10_i in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,148) = strpad('h11_i in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,149) = strpad('h12_i in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,150) = strpad('k1_i in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,151) = strpad('k2_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,134) = strpad('k3p_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,135) = strpad('k3pp_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,136) = strpad('k3_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,139) = strpad('k4_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,137) = strpad('k4p_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,138) = strpad('k4pp_i in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,152) = strpad('k5_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,140) = strpad('k6_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,141) = strpad('k7_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,142) = strpad('k8_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,143) = strpad('x1_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,144) = strpad('x2_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,145) = strpad('x3_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,146) = strpad('x4_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,147) = strpad('E1_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,148) = strpad('E2_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,149) = strpad('E3_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,150) = strpad('E4_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,151) = strpad('allo_i in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,152) = strpad('JncxNa_i in component INaCa (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,153) = strpad('JncxCa_i in component INaCa (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,155) = strpad('h1_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,156) = strpad('h2_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,157) = strpad('h3_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,158) = strpad('h4_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,159) = strpad('h5_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,160) = strpad('h6_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,161) = strpad('h7_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,162) = strpad('h8_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,163) = strpad('h9_ss in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,154) = strpad('h10_ss in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,155) = strpad('h11_ss in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,156) = strpad('h12_ss in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,157) = strpad('k1_ss in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,158) = strpad('k2_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,164) = strpad('k3p_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,165) = strpad('k3pp_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,166) = strpad('k3_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,169) = strpad('k4_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,167) = strpad('k4p_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,168) = strpad('k4pp_ss in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,159) = strpad('k5_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,170) = strpad('k6_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,171) = strpad('k7_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,172) = strpad('k8_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,173) = strpad('x1_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,174) = strpad('x2_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,175) = strpad('x3_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,176) = strpad('x4_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,177) = strpad('E1_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,178) = strpad('E2_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,179) = strpad('E3_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,180) = strpad('E4_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,181) = strpad('allo_ss in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,182) = strpad('JncxNa_ss in component INaCa (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,183) = strpad('JncxCa_ss in component INaCa (millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,75) = strpad('k1p in component INaK (per_millisecond)');
    LEGEND_CONSTANTS(:,76) = strpad('k1m in component INaK (per_millisecond)');
    LEGEND_CONSTANTS(:,77) = strpad('k2p in component INaK (per_millisecond)');
    LEGEND_CONSTANTS(:,78) = strpad('k2m in component INaK (per_millisecond)');
    LEGEND_CONSTANTS(:,79) = strpad('k3p in component INaK (per_millisecond)');
    LEGEND_CONSTANTS(:,80) = strpad('k3m in component INaK (per_millisecond)');
    LEGEND_CONSTANTS(:,81) = strpad('k4p in component INaK (per_millisecond)');
    LEGEND_CONSTANTS(:,82) = strpad('k4m in component INaK (per_millisecond)');
    LEGEND_CONSTANTS(:,83) = strpad('Knai0 in component INaK (millimolar)');
    LEGEND_CONSTANTS(:,84) = strpad('Knao0 in component INaK (millimolar)');
    LEGEND_CONSTANTS(:,85) = strpad('delta in component INaK (millivolt)');
    LEGEND_CONSTANTS(:,86) = strpad('Kki in component INaK (per_millisecond)');
    LEGEND_CONSTANTS(:,87) = strpad('Kko in component INaK (per_millisecond)');
    LEGEND_CONSTANTS(:,88) = strpad('MgADP in component INaK (millimolar)');
    LEGEND_CONSTANTS(:,89) = strpad('MgATP in component INaK (millimolar)');
    LEGEND_CONSTANTS(:,90) = strpad('Kmgatp in component INaK (millimolar)');
    LEGEND_CONSTANTS(:,91) = strpad('H in component INaK (millimolar)');
    LEGEND_CONSTANTS(:,92) = strpad('eP in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,93) = strpad('Khp in component INaK (millimolar)');
    LEGEND_CONSTANTS(:,94) = strpad('Knap in component INaK (millimolar)');
    LEGEND_CONSTANTS(:,95) = strpad('Kxkur in component INaK (millimolar)');
    LEGEND_CONSTANTS(:,96) = strpad('Pnak_b in component INaK (milliS_per_microF)');
    LEGEND_CONSTANTS(:,163) = strpad('Pnak in component INaK (milliS_per_microF)');
    LEGEND_ALGEBRAIC(:,185) = strpad('Knai in component INaK (millimolar)');
    LEGEND_ALGEBRAIC(:,186) = strpad('Knao in component INaK (millimolar)');
    LEGEND_ALGEBRAIC(:,187) = strpad('P in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,188) = strpad('a1 in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,160) = strpad('b1 in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,161) = strpad('a2 in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,189) = strpad('b2 in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,190) = strpad('a3 in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,191) = strpad('b3 in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,162) = strpad('a4 in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,192) = strpad('b4 in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,193) = strpad('x1 in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,194) = strpad('x2 in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,195) = strpad('x3 in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,196) = strpad('x4 in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,197) = strpad('E1 in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,198) = strpad('E2 in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,199) = strpad('E3 in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,200) = strpad('E4 in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,201) = strpad('JnakNa in component INaK (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,202) = strpad('JnakK in component INaK (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,204) = strpad('xkb in component IKb (dimensionless)');
    LEGEND_CONSTANTS(:,97) = strpad('GKb_b in component IKb (milliS_per_microF)');
    LEGEND_CONSTANTS(:,127) = strpad('GKb in component IKb (milliS_per_microF)');
    LEGEND_CONSTANTS(:,98) = strpad('PNab in component INab (milliS_per_microF)');
    LEGEND_CONSTANTS(:,99) = strpad('PCab in component ICab (milliS_per_microF)');
    LEGEND_CONSTANTS(:,100) = strpad('GpCa in component IpCa (milliS_per_microF)');
    LEGEND_CONSTANTS(:,101) = strpad('KmCap in component IpCa (millimolar)');
    LEGEND_CONSTANTS(:,102) = strpad('GClCa in component ICl (milliS_per_microF)');
    LEGEND_CONSTANTS(:,103) = strpad('GClb in component ICl (milliS_per_microF)');
    LEGEND_CONSTANTS(:,104) = strpad('KdClCa in component ICl (millimolar)');
    LEGEND_CONSTANTS(:,105) = strpad('Fjunc in component ICl (dimensionless)');
    LEGEND_ALGEBRAIC(:,211) = strpad('IClCa_junc in component ICl (microA_per_microF)');
    LEGEND_ALGEBRAIC(:,213) = strpad('IClCa_sl in component ICl (microA_per_microF)');
    LEGEND_CONSTANTS(:,106) = strpad('tauNa in component diff (millisecond)');
    LEGEND_CONSTANTS(:,107) = strpad('tauK in component diff (millisecond)');
    LEGEND_CONSTANTS(:,108) = strpad('tauCa in component diff (millisecond)');
    LEGEND_CONSTANTS(:,109) = strpad('bt in component ryr (millisecond)');
    LEGEND_CONSTANTS(:,128) = strpad('a_rel in component ryr (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,94) = strpad('Jrel_inf_b in component ryr (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,97) = strpad('Jrel_inf in component ryr (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,100) = strpad('tau_rel_b in component ryr (millisecond)');
    LEGEND_ALGEBRAIC(:,103) = strpad('tau_rel in component ryr (millisecond)');
    LEGEND_STATES(:,42) = strpad('Jrel_np in component ryr (millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,129) = strpad('btp in component ryr (millisecond)');
    LEGEND_CONSTANTS(:,136) = strpad('a_relp in component ryr (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,95) = strpad('Jrel_infp_b in component ryr (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,98) = strpad('Jrel_infp in component ryr (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,101) = strpad('tau_relp_b in component ryr (millisecond)');
    LEGEND_ALGEBRAIC(:,104) = strpad('tau_relp in component ryr (millisecond)');
    LEGEND_STATES(:,43) = strpad('Jrel_p in component ryr (millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,110) = strpad('cajsr_half in component ryr (millimolar)');
    LEGEND_ALGEBRAIC(:,214) = strpad('fJrelp in component ryr (dimensionless)');
    LEGEND_CONSTANTS(:,111) = strpad('Jrel_b in component ryr (dimensionless)');
    LEGEND_CONSTANTS(:,130) = strpad('upScale in component SERCA (dimensionless)');
    LEGEND_ALGEBRAIC(:,218) = strpad('Jupnp in component SERCA (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,219) = strpad('Jupp in component SERCA (millimolar_per_millisecond)');
    LEGEND_ALGEBRAIC(:,220) = strpad('fJupp in component SERCA (dimensionless)');
    LEGEND_ALGEBRAIC(:,221) = strpad('Jleak in component SERCA (millimolar_per_millisecond)');
    LEGEND_CONSTANTS(:,112) = strpad('Jup_b in component SERCA (dimensionless)');
    LEGEND_RATES(:,1) = strpad('d/dt v in component membrane (millivolt)');
    LEGEND_RATES(:,2) = strpad('d/dt CaMKt in component CaMK (millimolar)');
    LEGEND_RATES(:,4) = strpad('d/dt nai in component intracellular_ions (millimolar)');
    LEGEND_RATES(:,5) = strpad('d/dt nass in component intracellular_ions (millimolar)');
    LEGEND_RATES(:,6) = strpad('d/dt ki in component intracellular_ions (millimolar)');
    LEGEND_RATES(:,7) = strpad('d/dt kss in component intracellular_ions (millimolar)');
    LEGEND_RATES(:,10) = strpad('d/dt cai in component intracellular_ions (millimolar)');
    LEGEND_RATES(:,3) = strpad('d/dt cass in component intracellular_ions (millimolar)');
    LEGEND_RATES(:,8) = strpad('d/dt cansr in component intracellular_ions (millimolar)');
    LEGEND_RATES(:,9) = strpad('d/dt cajsr in component intracellular_ions (millimolar)');
    LEGEND_RATES(:,11) = strpad('d/dt m in component INa (dimensionless)');
    LEGEND_RATES(:,12) = strpad('d/dt h in component INa (dimensionless)');
    LEGEND_RATES(:,13) = strpad('d/dt j in component INa (dimensionless)');
    LEGEND_RATES(:,14) = strpad('d/dt hp in component INa (dimensionless)');
    LEGEND_RATES(:,15) = strpad('d/dt jp in component INa (dimensionless)');
    LEGEND_RATES(:,16) = strpad('d/dt mL in component INaL (dimensionless)');
    LEGEND_RATES(:,17) = strpad('d/dt hL in component INaL (dimensionless)');
    LEGEND_RATES(:,18) = strpad('d/dt hLp in component INaL (dimensionless)');
    LEGEND_RATES(:,19) = strpad('d/dt a in component Ito (dimensionless)');
    LEGEND_RATES(:,20) = strpad('d/dt iF in component Ito (dimensionless)');
    LEGEND_RATES(:,21) = strpad('d/dt iS in component Ito (dimensionless)');
    LEGEND_RATES(:,22) = strpad('d/dt ap in component Ito (dimensionless)');
    LEGEND_RATES(:,23) = strpad('d/dt iFp in component Ito (dimensionless)');
    LEGEND_RATES(:,24) = strpad('d/dt iSp in component Ito (dimensionless)');
    LEGEND_RATES(:,25) = strpad('d/dt d in component ICaL (dimensionless)');
    LEGEND_RATES(:,26) = strpad('d/dt ff in component ICaL (dimensionless)');
    LEGEND_RATES(:,27) = strpad('d/dt fs in component ICaL (dimensionless)');
    LEGEND_RATES(:,28) = strpad('d/dt fcaf in component ICaL (dimensionless)');
    LEGEND_RATES(:,29) = strpad('d/dt fcas in component ICaL (dimensionless)');
    LEGEND_RATES(:,30) = strpad('d/dt jca in component ICaL (dimensionless)');
    LEGEND_RATES(:,31) = strpad('d/dt ffp in component ICaL (dimensionless)');
    LEGEND_RATES(:,32) = strpad('d/dt fcafp in component ICaL (dimensionless)');
    LEGEND_RATES(:,33) = strpad('d/dt nca_ss in component ICaL (dimensionless)');
    LEGEND_RATES(:,34) = strpad('d/dt nca_i in component ICaL (dimensionless)');
    LEGEND_RATES(:,37) = strpad('d/dt C3 in component IKr (dimensionless)');
    LEGEND_RATES(:,36) = strpad('d/dt C2 in component IKr (dimensionless)');
    LEGEND_RATES(:,35) = strpad('d/dt C1 in component IKr (dimensionless)');
    LEGEND_RATES(:,39) = strpad('d/dt O in component IKr (dimensionless)');
    LEGEND_RATES(:,38) = strpad('d/dt I in component IKr (dimensionless)');
    LEGEND_RATES(:,40) = strpad('d/dt xs1 in component IKs (dimensionless)');
    LEGEND_RATES(:,41) = strpad('d/dt xs2 in component IKs (dimensionless)');
    LEGEND_RATES(:,42) = strpad('d/dt Jrel_np in component ryr (millimolar_per_millisecond)');
    LEGEND_RATES(:,43) = strpad('d/dt Jrel_p in component ryr (millimolar_per_millisecond)');
    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) = 2;
    CONSTANTS(:,2) = 140.0;
    CONSTANTS(:,3) = 1.8;
    CONSTANTS(:,4) = 5.0;
    CONSTANTS(:,5) = 150.0;
    CONSTANTS(:,6) = 8314;
    CONSTANTS(:,7) = 310;
    CONSTANTS(:,8) = 96485;
    CONSTANTS(:,9) = 1;
    CONSTANTS(:,10) = 2;
    CONSTANTS(:,11) = 1;
    CONSTANTS(:,12) = -1;
    CONSTANTS(:,13) = 0.01;
    CONSTANTS(:,14) = 0.0011;
    STATES(:,1) = -89.1704;
    CONSTANTS(:,15) = 0;
    CONSTANTS(:,16) = 100000000000000000;
    CONSTANTS(:,17) = -53;
    CONSTANTS(:,18) = 1000;
    CONSTANTS(:,19) = 1.0;
    CONSTANTS(:,20) = 0.15;
    CONSTANTS(:,21) = 0.05;
    CONSTANTS(:,22) = 0.00068;
    CONSTANTS(:,23) = 0.05;
    CONSTANTS(:,24) = 0.0015;
    STATES(:,2) = 0.0192;
    STATES(:,3) = 6.5781e-05;
    CONSTANTS(:,25) = 0.05;
    CONSTANTS(:,26) = 0.00238;
    CONSTANTS(:,27) = 0.07;
    CONSTANTS(:,28) = 0.0005;
    CONSTANTS(:,29) = 0.047;
    CONSTANTS(:,30) = 0.00087;
    CONSTANTS(:,31) = 1.124;
    CONSTANTS(:,32) = 0.0087;
    CONSTANTS(:,33) = 10;
    CONSTANTS(:,34) = 0.8;
    STATES(:,4) = 15.0038;
    STATES(:,5) = 15.0043;
    STATES(:,6) = 143.0403;
    STATES(:,7) = 143.0402;
    STATES(:,8) = 1.9557;
    STATES(:,9) = 1.9593;
    STATES(:,10) = 8.166e-05;
    CONSTANTS(:,35) = 24.0;
    CONSTANTS(:,36) = 0.01833;
    CONSTANTS(:,37) = 4.3195;
    CONSTANTS(:,38) = 0.0;
    CONSTANTS(:,39) = 5;
    CONSTANTS(:,40) = 2;
    CONSTANTS(:,41) = 0.25;
    STATES(:,11) = 0.00073818;
    STATES(:,12) = 0.8365;
    STATES(:,13) = 0.8363;
    STATES(:,14) = 0.6838;
    STATES(:,15) = 0.8358;
    CONSTANTS(:,42) = 11.7802;
    STATES(:,16) = 0.00015079;
    CONSTANTS(:,43) = 200;
    STATES(:,17) = 0.5327;
    STATES(:,18) = 0.2834;
    CONSTANTS(:,44) = 0.0279;
    CONSTANTS(:,45) = 0.16;
    STATES(:,19) = 0.00092527;
    CONSTANTS(:,46) = 0;
    STATES(:,20) = 0.9996;
    STATES(:,21) = 0.5671;
    STATES(:,22) = 0.00047143;
    STATES(:,23) = 0.9996;
    STATES(:,24) = 0.6261;
    CONSTANTS(:,47) = 0.002;
    CONSTANTS(:,48) = 500;
    CONSTANTS(:,49) = 8.3757e-05;
    STATES(:,25) = 0;
    CONSTANTS(:,50) = 0.6;
    STATES(:,26) = 1.0;
    STATES(:,27) = 0.92;
    STATES(:,28) = 1.0;
    STATES(:,29) = 0.9998;
    STATES(:,30) = 1.0;
    STATES(:,31) = 1.0;
    STATES(:,32) = 1.0;
    STATES(:,33) = 0.00051399;
    STATES(:,34) = 0.0012;
    CONSTANTS(:,51) = 75;
    CONSTANTS(:,52) = 0;
    CONSTANTS(:,53) = 0;
    CONSTANTS(:,54) = 74;
    CONSTANTS(:,55) = 0.8;
    CONSTANTS(:,56) = 0.0321;
    STATES(:,35) = 0.00069560;
    STATES(:,36) = 0.00082672;
    STATES(:,37) = 0.9979;
    STATES(:,38) = 1.8784e-05;
    STATES(:,39) = 0.00054206;
    CONSTANTS(:,57) = 0.154375;
    CONSTANTS(:,58) = 0.1911;
    CONSTANTS(:,59) = 0.0011;
    STATES(:,40) = 0.2653;
    STATES(:,41) = 0.00016921;
    CONSTANTS(:,60) = 0.6992;
    CONSTANTS(:,61) = 0.35;
    CONSTANTS(:,62) = 15;
    CONSTANTS(:,63) = 5;
    CONSTANTS(:,64) = 88.12;
    CONSTANTS(:,65) = 12.5;
    CONSTANTS(:,66) = 6e4;
    CONSTANTS(:,67) = 6e4;
    CONSTANTS(:,68) = 5e3;
    CONSTANTS(:,69) = 1.5e6;
    CONSTANTS(:,70) = 5e3;
    CONSTANTS(:,71) = 0.5224;
    CONSTANTS(:,72) = 0.167;
    CONSTANTS(:,73) = 150e-6;
    CONSTANTS(:,74) = 0.0034;
    CONSTANTS(:,75) = 949.5;
    CONSTANTS(:,76) = 182.4;
    CONSTANTS(:,77) = 687.2;
    CONSTANTS(:,78) = 39.4;
    CONSTANTS(:,79) = 1899;
    CONSTANTS(:,80) = 79300;
    CONSTANTS(:,81) = 639;
    CONSTANTS(:,82) = 40;
    CONSTANTS(:,83) = 9.073;
    CONSTANTS(:,84) = 27.78;
    CONSTANTS(:,85) = -0.155;
    CONSTANTS(:,86) = 0.5;
    CONSTANTS(:,87) = 0.3582;
    CONSTANTS(:,88) = 0.05;
    CONSTANTS(:,89) = 9.8;
    CONSTANTS(:,90) = 1.698e-7;
    CONSTANTS(:,91) = 1e-7;
    CONSTANTS(:,92) = 4.2;
    CONSTANTS(:,93) = 1.698e-7;
    CONSTANTS(:,94) = 224;
    CONSTANTS(:,95) = 292;
    CONSTANTS(:,96) = 15.4509;
    CONSTANTS(:,97) = 0.0189;
    CONSTANTS(:,98) = 1.9239e-09;
    CONSTANTS(:,99) = 5.9194e-08;
    CONSTANTS(:,100) = 5e-04;
    CONSTANTS(:,101) = 0.0005;
    CONSTANTS(:,102) = 0.2843;
    CONSTANTS(:,103) = 1.98e-3;
    CONSTANTS(:,104) = 0.1;
    CONSTANTS(:,105) = 1;
    CONSTANTS(:,106) = 2.0;
    CONSTANTS(:,107) = 2.0;
    CONSTANTS(:,108) = 0.2;
    CONSTANTS(:,109) = 4.75;
    STATES(:,42) = 0;
    STATES(:,43) = 0;
    CONSTANTS(:,110) = 1.7;
    CONSTANTS(:,111) = 1.5378;
    CONSTANTS(:,112) = 1.0;
    CONSTANTS(:,113) =  1000.00.*3.14000.*CONSTANTS(:,14).*CONSTANTS(:,14).*CONSTANTS(:,13);
    CONSTANTS(:,114) = piecewise({CONSTANTS(:,1)==1.00000,  CONSTANTS(:,25).*1.30000 }, CONSTANTS(:,25));
    CONSTANTS(:,115) =  (( CONSTANTS(:,6).*CONSTANTS(:,7))./( CONSTANTS(:,12).*CONSTANTS(:,8))).*log(CONSTANTS(:,5)./CONSTANTS(:,35));
    CONSTANTS(:,116) = power(CONSTANTS(:,4)./CONSTANTS(:,39), 0.240000);
    CONSTANTS(:,117) = 1.00000./(1.00000+power(CONSTANTS(:,40)./CONSTANTS(:,41), 2.00000));
    CONSTANTS(:,118) =  3.00000.*CONSTANTS(:,43);
    CONSTANTS(:,119) = piecewise({CONSTANTS(:,1)==1.00000,  CONSTANTS(:,44).*0.600000 }, CONSTANTS(:,44));
    CONSTANTS(:,120) = piecewise({CONSTANTS(:,1)==1.00000,  CONSTANTS(:,45).*2.00000 , CONSTANTS(:,1)==2.00000,  CONSTANTS(:,45).*2.00000 }, CONSTANTS(:,45));
    CONSTANTS(:,121) = 1.00000 - CONSTANTS(:,50);
    CONSTANTS(:,122) = piecewise({CONSTANTS(:,1)==1.00000,  CONSTANTS(:,49).*1.20000 , CONSTANTS(:,1)==2.00000,  CONSTANTS(:,49).*2.00000 }, CONSTANTS(:,49));
    CONSTANTS(:,123) = ( 0.500000.*(CONSTANTS(:,2)+CONSTANTS(:,4)+CONSTANTS(:,5)+ 4.00000.*CONSTANTS(:,3)))./1000.00;
    CONSTANTS(:,124) = piecewise({CONSTANTS(:,1)==1.00000,  CONSTANTS(:,56).*1.30000 , CONSTANTS(:,1)==2.00000,  CONSTANTS(:,56).*0.800000 }, CONSTANTS(:,56));
    CONSTANTS(:,125) = piecewise({CONSTANTS(:,1)==1.00000,  CONSTANTS(:,59).*1.40000 }, CONSTANTS(:,59));
    CONSTANTS(:,126) = piecewise({CONSTANTS(:,1)==1.00000,  CONSTANTS(:,60).*1.20000 , CONSTANTS(:,1)==2.00000,  CONSTANTS(:,60).*1.30000 }, CONSTANTS(:,60));
    CONSTANTS(:,127) = piecewise({CONSTANTS(:,1)==1.00000,  CONSTANTS(:,97).*0.600000 }, CONSTANTS(:,97));
    CONSTANTS(:,128) = ( 0.500000.*CONSTANTS(:,109))./1.00000;
    CONSTANTS(:,129) =  1.25000.*CONSTANTS(:,109);
    CONSTANTS(:,130) = piecewise({CONSTANTS(:,1)==1.00000, 1.30000 }, 1.00000);
    CONSTANTS(:,131) =  2.00000.*3.14000.*CONSTANTS(:,14).*CONSTANTS(:,14)+ 2.00000.*3.14000.*CONSTANTS(:,14).*CONSTANTS(:,13);
    CONSTANTS(:,132) =  1.10000.*CONSTANTS(:,122);
    CONSTANTS(:,133) =  0.00125000.*CONSTANTS(:,122);
    CONSTANTS(:,134) =  0.000357400.*CONSTANTS(:,122);
    CONSTANTS(:,135) =  1.82000e+06.*power( CONSTANTS(:,54).*CONSTANTS(:,7),  - 1.50000);
    CONSTANTS(:,136) = ( 0.500000.*CONSTANTS(:,129))./1.00000;
    CONSTANTS(:,137) =  2.00000.*CONSTANTS(:,131);
    CONSTANTS(:,138) =  0.00125000.*CONSTANTS(:,132);
    CONSTANTS(:,139) =  0.000357400.*CONSTANTS(:,132);
    CONSTANTS(:,140) = exp(  - CONSTANTS(:,135).*4.00000.*(power(CONSTANTS(:,123), 1.0 ./ 2)./(1.00000+power(CONSTANTS(:,123), 1.0 ./ 2)) -  0.300000.*CONSTANTS(:,123)));
    CONSTANTS(:,141) = exp(  - CONSTANTS(:,135).*1.00000.*(power(CONSTANTS(:,123), 1.0 ./ 2)./(1.00000+power(CONSTANTS(:,123), 1.0 ./ 2)) -  0.300000.*CONSTANTS(:,123)));
    CONSTANTS(:,142) = exp(  - CONSTANTS(:,135).*1.00000.*(power(CONSTANTS(:,123), 1.0 ./ 2)./(1.00000+power(CONSTANTS(:,123), 1.0 ./ 2)) -  0.300000.*CONSTANTS(:,123)));
    CONSTANTS(:,143) =  0.680000.*CONSTANTS(:,113);
    CONSTANTS(:,144) =  0.0552000.*CONSTANTS(:,113);
    CONSTANTS(:,145) =  0.00480000.*CONSTANTS(:,113);
    CONSTANTS(:,146) =  0.0200000.*CONSTANTS(:,113);
    CONSTANTS(:,147) = CONSTANTS(:,65)+1.00000+ (CONSTANTS(:,2)./CONSTANTS(:,62)).*(1.00000+CONSTANTS(:,2)./CONSTANTS(:,63));
    CONSTANTS(:,148) = ( CONSTANTS(:,2).*CONSTANTS(:,2))./( CONSTANTS(:,147).*CONSTANTS(:,62).*CONSTANTS(:,63));
    CONSTANTS(:,149) = 1.00000./CONSTANTS(:,147);
    CONSTANTS(:,150) =  CONSTANTS(:,149).*CONSTANTS(:,3).*CONSTANTS(:,69);
    CONSTANTS(:,151) = CONSTANTS(:,70);
    CONSTANTS(:,152) = CONSTANTS(:,70);
    CONSTANTS(:,153) = piecewise({CONSTANTS(:,1)==1.00000,  CONSTANTS(:,74).*1.10000 , CONSTANTS(:,1)==2.00000,  CONSTANTS(:,74).*1.40000 }, CONSTANTS(:,74));
    CONSTANTS(:,154) = CONSTANTS(:,65)+1.00000+ (CONSTANTS(:,2)./CONSTANTS(:,62)).*(1.00000+CONSTANTS(:,2)./CONSTANTS(:,63));
    CONSTANTS(:,155) = ( CONSTANTS(:,2).*CONSTANTS(:,2))./( CONSTANTS(:,154).*CONSTANTS(:,62).*CONSTANTS(:,63));
    CONSTANTS(:,156) = 1.00000./CONSTANTS(:,154);
    CONSTANTS(:,157) =  CONSTANTS(:,156).*CONSTANTS(:,3).*CONSTANTS(:,69);
    CONSTANTS(:,158) = CONSTANTS(:,70);
    CONSTANTS(:,159) = CONSTANTS(:,70);
    CONSTANTS(:,160) =  CONSTANTS(:,76).*CONSTANTS(:,88);
    CONSTANTS(:,161) = CONSTANTS(:,77);
    CONSTANTS(:,162) = (( CONSTANTS(:,81).*CONSTANTS(:,89))./CONSTANTS(:,90))./(1.00000+CONSTANTS(:,89)./CONSTANTS(:,90));
    CONSTANTS(:,163) = piecewise({CONSTANTS(:,1)==1.00000,  CONSTANTS(:,96).*0.900000 , CONSTANTS(:,1)==2.00000,  CONSTANTS(:,96).*0.700000 }, CONSTANTS(:,96));
    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
    ALGEBRAIC(:,4) = 1.00000./(1.00000+exp((STATES(:,1)+87.6100)./7.48800));
    RATES(:,17) = (ALGEBRAIC(:,4) - STATES(:,17))./CONSTANTS(:,43);
    ALGEBRAIC(:,5) = 1.00000./(1.00000+exp((STATES(:,1)+93.8100)./7.48800));
    RATES(:,18) = (ALGEBRAIC(:,5) - STATES(:,18))./CONSTANTS(:,118);
    ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,1)+18.0800)./2.79160));
    RATES(:,30) = (ALGEBRAIC(:,10) - STATES(:,30))./CONSTANTS(:,51);
    ALGEBRAIC(:,1) = 1.00000./power(1.00000+exp( - (STATES(:,1)+56.8600)./9.03000), 2.00000);
    ALGEBRAIC(:,14) =  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(:,11) = (ALGEBRAIC(:,1) - STATES(:,11))./ALGEBRAIC(:,14);
    ALGEBRAIC(:,3) = 1.00000./(1.00000+exp( - (STATES(:,1)+42.8500)./5.26400));
    ALGEBRAIC(:,17) =  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(:,16) = (ALGEBRAIC(:,3) - STATES(:,16))./ALGEBRAIC(:,17);
    ALGEBRAIC(:,6) = 1.00000./(1.00000+exp( - ((STATES(:,1)+CONSTANTS(:,46)) - 14.3400)./14.8200));
    ALGEBRAIC(:,18) = 1.05150./(1.00000./( 1.20890.*(1.00000+exp( - ((STATES(:,1)+CONSTANTS(:,46)) - 18.4099)./29.3814)))+3.50000./(1.00000+exp((STATES(:,1)+CONSTANTS(:,46)+100.000)./29.3814)));
    RATES(:,19) = (ALGEBRAIC(:,6) - STATES(:,19))./ALGEBRAIC(:,18);
    ALGEBRAIC(:,8) = piecewise({STATES(:,1)>=31.4978, 1.00000 },  1.07630.*exp(  - 1.00700.*exp(  - 0.0829000.*STATES(:,1))));
    ALGEBRAIC(:,23) = CONSTANTS(:,53)+0.600000+1.00000./(exp(  - 0.0500000.*(STATES(:,1)+CONSTANTS(:,52)+6.00000))+exp( 0.0900000.*(STATES(:,1)+CONSTANTS(:,52)+14.0000)));
    RATES(:,25) = (ALGEBRAIC(:,8) - STATES(:,25))./ALGEBRAIC(:,23);
    ALGEBRAIC(:,9) = 1.00000./(1.00000+exp((STATES(:,1)+19.5800)./3.69600));
    ALGEBRAIC(:,24) = 7.00000+1.00000./( 0.00450000.*exp( - (STATES(:,1)+20.0000)./10.0000)+ 0.00450000.*exp((STATES(:,1)+20.0000)./10.0000));
    RATES(:,26) = (ALGEBRAIC(:,9) - STATES(:,26))./ALGEBRAIC(:,24);
    ALGEBRAIC(:,25) = 1000.00+1.00000./( 3.50000e-05.*exp( - (STATES(:,1)+5.00000)./4.00000)+ 3.50000e-05.*exp((STATES(:,1)+5.00000)./6.00000));
    RATES(:,27) = (ALGEBRAIC(:,9) - STATES(:,27))./ALGEBRAIC(:,25);
    ALGEBRAIC(:,11) =  STATES(:,30).*1.00000;
    ALGEBRAIC(:,21) = 1.00000./(CONSTANTS(:,48)./ALGEBRAIC(:,11)+power(1.00000+CONSTANTS(:,47)./STATES(:,3), 4.00000));
    RATES(:,33) =  ALGEBRAIC(:,21).*CONSTANTS(:,48) -  STATES(:,33).*ALGEBRAIC(:,11);
    ALGEBRAIC(:,22) = 1.00000./(CONSTANTS(:,48)./ALGEBRAIC(:,11)+power(1.00000+CONSTANTS(:,47)./STATES(:,10), 4.00000));
    RATES(:,34) =  ALGEBRAIC(:,22).*CONSTANTS(:,48) -  STATES(:,34).*ALGEBRAIC(:,11);
    ALGEBRAIC(:,13) = 1.00000./(1.00000+exp( - (STATES(:,1)+11.6000)./8.93200));
    ALGEBRAIC(:,28) = 817.300+1.00000./( 0.000232600.*exp((STATES(:,1)+48.2800)./17.8000)+ 0.00129200.*exp( - (STATES(:,1)+210.000)./230.000));
    RATES(:,40) = (ALGEBRAIC(:,13) - STATES(:,40))./ALGEBRAIC(:,28);
    ALGEBRAIC(:,33) = 1.00000./(1.00000+exp( - ((STATES(:,1)+CONSTANTS(:,46)) - 24.3400)./14.8200));
    RATES(:,22) = (ALGEBRAIC(:,33) - STATES(:,22))./ALGEBRAIC(:,18);
    ALGEBRAIC(:,20) = ALGEBRAIC(:,9);
    ALGEBRAIC(:,34) = 7.00000+1.00000./( 0.0400000.*exp( - (STATES(:,1) - 4.00000)./7.00000)+ 0.0400000.*exp((STATES(:,1) - 4.00000)./7.00000));
    RATES(:,28) = (ALGEBRAIC(:,20) - STATES(:,28))./ALGEBRAIC(:,34);
    ALGEBRAIC(:,35) = 100.000+1.00000./( 0.000120000.*exp( - STATES(:,1)./3.00000)+ 0.000120000.*exp(STATES(:,1)./7.00000));
    RATES(:,29) = (ALGEBRAIC(:,20) - STATES(:,29))./ALGEBRAIC(:,35);
    ALGEBRAIC(:,36) =  2.50000.*ALGEBRAIC(:,24);
    RATES(:,31) = (ALGEBRAIC(:,9) - STATES(:,31))./ALGEBRAIC(:,36);
    ALGEBRAIC(:,27) = ALGEBRAIC(:,13);
    ALGEBRAIC(:,37) = 1.00000./( 0.0100000.*exp((STATES(:,1) - 50.0000)./20.0000)+ 0.0193000.*exp( - (STATES(:,1)+66.5400)./31.0000));
    RATES(:,41) = (ALGEBRAIC(:,27) - STATES(:,41))./ALGEBRAIC(:,37);
    ALGEBRAIC(:,44) = ( CONSTANTS(:,23).*(1.00000 - STATES(:,2)))./(1.00000+CONSTANTS(:,24)./STATES(:,3));
    RATES(:,2) =  CONSTANTS(:,21).*ALGEBRAIC(:,44).*(ALGEBRAIC(:,44)+STATES(:,2)) -  CONSTANTS(:,22).*STATES(:,2);
    ALGEBRAIC(:,2) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000);
    ALGEBRAIC(:,15) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 },  0.0570000.*exp( - (STATES(:,1)+80.0000)./6.80000));
    ALGEBRAIC(:,30) = 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(:,38) = 1.00000./(ALGEBRAIC(:,15)+ALGEBRAIC(:,30));
    RATES(:,12) = (ALGEBRAIC(:,2) - STATES(:,12))./ALGEBRAIC(:,38);
    ALGEBRAIC(:,41) =  2.50000.*ALGEBRAIC(:,34);
    RATES(:,32) = (ALGEBRAIC(:,20) - STATES(:,32))./ALGEBRAIC(:,41);
    ALGEBRAIC(:,39) = ALGEBRAIC(:,2);
    ALGEBRAIC(:,16) = 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(:,31) = 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(:,45) = 1.00000./(ALGEBRAIC(:,16)+ALGEBRAIC(:,31));
    RATES(:,13) = (ALGEBRAIC(:,39) - STATES(:,13))./ALGEBRAIC(:,45);
    ALGEBRAIC(:,46) = 1.00000./power(1.00000+exp((STATES(:,1)+77.5500)./7.43000), 2.00000);
    RATES(:,14) = (ALGEBRAIC(:,46) - STATES(:,14))./ALGEBRAIC(:,38);
    ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,1)+CONSTANTS(:,46)+43.9400)./5.71100));
    ALGEBRAIC(:,19) = piecewise({CONSTANTS(:,1)==1.00000, 1.00000 - 0.950000./(1.00000+exp((STATES(:,1)+CONSTANTS(:,46)+70.0000)./5.00000)) }, 1.00000);
    ALGEBRAIC(:,32) = 4.56200+1.00000./( 0.393300.*exp( - (STATES(:,1)+CONSTANTS(:,46)+100.000)./100.000)+ 0.0800400.*exp((STATES(:,1)+CONSTANTS(:,46)+50.0000)./16.5900));
    ALGEBRAIC(:,47) =  ALGEBRAIC(:,32).*ALGEBRAIC(:,19);
    RATES(:,20) = (ALGEBRAIC(:,7) - STATES(:,20))./ALGEBRAIC(:,47);
    ALGEBRAIC(:,29) = ( STATES(:,1).*CONSTANTS(:,8))./( CONSTANTS(:,6).*CONSTANTS(:,7));
    ALGEBRAIC(:,42) =  0.116100.*exp( 0.299000.*ALGEBRAIC(:,29));
    ALGEBRAIC(:,48) =  0.244200.*exp(  - 1.60400.*ALGEBRAIC(:,29));
    RATES(:,37) =  ALGEBRAIC(:,48).*STATES(:,36) -  ALGEBRAIC(:,42).*STATES(:,37);
    RATES(:,36) = ( ALGEBRAIC(:,42).*STATES(:,37)+ CONSTANTS(:,58).*STATES(:,35)) -  (ALGEBRAIC(:,48)+CONSTANTS(:,57)).*STATES(:,36);
    ALGEBRAIC(:,51) =  1.46000.*ALGEBRAIC(:,45);
    RATES(:,15) = (ALGEBRAIC(:,39) - STATES(:,15))./ALGEBRAIC(:,51);
    ALGEBRAIC(:,40) = 23.6200+1.00000./( 0.00141600.*exp( - (STATES(:,1)+CONSTANTS(:,46)+96.5200)./59.0500)+ 1.78000e-08.*exp((STATES(:,1)+CONSTANTS(:,46)+114.100)./8.07900));
    ALGEBRAIC(:,52) =  ALGEBRAIC(:,40).*ALGEBRAIC(:,19);
    RATES(:,21) = (ALGEBRAIC(:,7) - STATES(:,21))./ALGEBRAIC(:,52);
    ALGEBRAIC(:,43) =  0.0578000.*exp( 0.971000.*ALGEBRAIC(:,29));
    ALGEBRAIC(:,49) =  0.000349000.*exp(  - 1.06200.*ALGEBRAIC(:,29));
    ALGEBRAIC(:,53) =  0.253300.*exp( 0.595300.*ALGEBRAIC(:,29));
    ALGEBRAIC(:,56) =  0.0652500.*exp(  - 0.820900.*ALGEBRAIC(:,29));
    RATES(:,39) = ( ALGEBRAIC(:,43).*STATES(:,35)+ ALGEBRAIC(:,56).*STATES(:,38)) -  (ALGEBRAIC(:,49)+ALGEBRAIC(:,53)).*STATES(:,39);
    ALGEBRAIC(:,55) = 1.35400+0.000100000./(exp(((STATES(:,1)+CONSTANTS(:,46)) - 167.400)./15.8900)+exp( - ((STATES(:,1)+CONSTANTS(:,46)) - 12.2300)./0.215400));
    ALGEBRAIC(:,58) = 1.00000 - 0.500000./(1.00000+exp((STATES(:,1)+CONSTANTS(:,46)+70.0000)./20.0000));
    ALGEBRAIC(:,61) =  ALGEBRAIC(:,55).*ALGEBRAIC(:,58).*ALGEBRAIC(:,47);
    RATES(:,23) = (ALGEBRAIC(:,7) - STATES(:,23))./ALGEBRAIC(:,61);
    ALGEBRAIC(:,62) =  ALGEBRAIC(:,55).*ALGEBRAIC(:,58).*ALGEBRAIC(:,52);
    RATES(:,24) = (ALGEBRAIC(:,7) - STATES(:,24))./ALGEBRAIC(:,62);
    ALGEBRAIC(:,59) =  5.20000e-05.*exp( 1.52500.*ALGEBRAIC(:,29));
    ALGEBRAIC(:,63) = ( ALGEBRAIC(:,49).*ALGEBRAIC(:,56).*ALGEBRAIC(:,59))./( ALGEBRAIC(:,43).*ALGEBRAIC(:,53));
    RATES(:,35) = ( CONSTANTS(:,57).*STATES(:,36)+ ALGEBRAIC(:,49).*STATES(:,39)+ ALGEBRAIC(:,63).*STATES(:,38)) -  (CONSTANTS(:,58)+ALGEBRAIC(:,43)+ALGEBRAIC(:,59)).*STATES(:,35);
    RATES(:,38) = ( ALGEBRAIC(:,59).*STATES(:,35)+ ALGEBRAIC(:,53).*STATES(:,39)) -  (ALGEBRAIC(:,63)+ALGEBRAIC(:,56)).*STATES(:,38);
    ALGEBRAIC(:,78) =  CONSTANTS(:,50).*STATES(:,26)+ CONSTANTS(:,121).*STATES(:,27);
    ALGEBRAIC(:,79) = 0.300000+0.600000./(1.00000+exp((STATES(:,1) - 10.0000)./10.0000));
    ALGEBRAIC(:,80) = 1.00000 - ALGEBRAIC(:,79);
    ALGEBRAIC(:,81) =  ALGEBRAIC(:,79).*STATES(:,28)+ ALGEBRAIC(:,80).*STATES(:,29);
    ALGEBRAIC(:,82) =  CONSTANTS(:,50).*STATES(:,31)+ CONSTANTS(:,121).*STATES(:,27);
    ALGEBRAIC(:,83) =  ALGEBRAIC(:,79).*STATES(:,32)+ ALGEBRAIC(:,80).*STATES(:,29);
    ALGEBRAIC(:,26) = ( STATES(:,1).*CONSTANTS(:,8).*CONSTANTS(:,8))./( CONSTANTS(:,6).*CONSTANTS(:,7));
    ALGEBRAIC(:,84) = ( 0.500000.*(STATES(:,5)+STATES(:,7)+CONSTANTS(:,35)+ 4.00000.*STATES(:,3)))./1000.00;
    ALGEBRAIC(:,85) = exp(  - CONSTANTS(:,135).*4.00000.*(power(ALGEBRAIC(:,84), 1.0 ./ 2)./(1.00000+power(ALGEBRAIC(:,84), 1.0 ./ 2)) -  0.300000.*ALGEBRAIC(:,84)));
    ALGEBRAIC(:,88) = ( 4.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,85).*STATES(:,3).*exp( 2.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,140).*CONSTANTS(:,3)))./(exp( 2.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,50) = ALGEBRAIC(:,44)+STATES(:,2);
    ALGEBRAIC(:,91) = 1.00000./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,50));
    ALGEBRAIC(:,92) =  CONSTANTS(:,55).*( (1.00000 - ALGEBRAIC(:,91)).*CONSTANTS(:,122).*ALGEBRAIC(:,88).*STATES(:,25).*( ALGEBRAIC(:,78).*(1.00000 - STATES(:,33))+ STATES(:,30).*ALGEBRAIC(:,81).*STATES(:,33))+ ALGEBRAIC(:,91).*CONSTANTS(:,132).*ALGEBRAIC(:,88).*STATES(:,25).*( ALGEBRAIC(:,82).*(1.00000 - STATES(:,33))+ STATES(:,30).*ALGEBRAIC(:,83).*STATES(:,33)));
    ALGEBRAIC(:,94) = ((  - CONSTANTS(:,128).*ALGEBRAIC(:,92))./1.00000)./(1.00000+power(CONSTANTS(:,110)./STATES(:,9), 8.00000));
    ALGEBRAIC(:,97) = piecewise({CONSTANTS(:,1)==2.00000,  ALGEBRAIC(:,94).*1.70000 }, ALGEBRAIC(:,94));
    ALGEBRAIC(:,100) = CONSTANTS(:,109)./(1.00000+0.0123000./STATES(:,9));
    ALGEBRAIC(:,103) = piecewise({ALGEBRAIC(:,100)<0.00100000, 0.00100000 }, ALGEBRAIC(:,100));
    RATES(:,42) = (ALGEBRAIC(:,97) - STATES(:,42))./ALGEBRAIC(:,103);
    ALGEBRAIC(:,95) = ((  - CONSTANTS(:,136).*ALGEBRAIC(:,92))./1.00000)./(1.00000+power(CONSTANTS(:,110)./STATES(:,9), 8.00000));
    ALGEBRAIC(:,98) = piecewise({CONSTANTS(:,1)==2.00000,  ALGEBRAIC(:,95).*1.70000 }, ALGEBRAIC(:,95));
    ALGEBRAIC(:,101) = CONSTANTS(:,129)./(1.00000+0.0123000./STATES(:,9));
    ALGEBRAIC(:,104) = piecewise({ALGEBRAIC(:,101)<0.00100000, 0.00100000 }, ALGEBRAIC(:,101));
    RATES(:,43) = (ALGEBRAIC(:,98) - STATES(:,43))./ALGEBRAIC(:,104);
    ALGEBRAIC(:,65) =  (( CONSTANTS(:,6).*CONSTANTS(:,7))./( CONSTANTS(:,11).*CONSTANTS(:,8))).*log(CONSTANTS(:,4)./STATES(:,6));
    ALGEBRAIC(:,72) = 1.00000./(1.00000+exp(((STATES(:,1)+CONSTANTS(:,46)) - 213.600)./151.200));
    ALGEBRAIC(:,73) = 1.00000 - ALGEBRAIC(:,72);
    ALGEBRAIC(:,74) =  ALGEBRAIC(:,72).*STATES(:,20)+ ALGEBRAIC(:,73).*STATES(:,21);
    ALGEBRAIC(:,75) =  ALGEBRAIC(:,72).*STATES(:,23)+ ALGEBRAIC(:,73).*STATES(:,24);
    ALGEBRAIC(:,76) = 1.00000./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,50));
    ALGEBRAIC(:,77) =  CONSTANTS(:,120).*(STATES(:,1) - ALGEBRAIC(:,65)).*( (1.00000 - ALGEBRAIC(:,76)).*STATES(:,19).*ALGEBRAIC(:,74)+ ALGEBRAIC(:,76).*STATES(:,22).*ALGEBRAIC(:,75));
    ALGEBRAIC(:,116) =  CONSTANTS(:,124).*power((CONSTANTS(:,4)./5.00000), 1.0 ./ 2).*STATES(:,39).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,66) =  (( CONSTANTS(:,6).*CONSTANTS(:,7))./( CONSTANTS(:,11).*CONSTANTS(:,8))).*log((CONSTANTS(:,4)+ CONSTANTS(:,36).*CONSTANTS(:,2))./(STATES(:,6)+ CONSTANTS(:,36).*STATES(:,4)));
    ALGEBRAIC(:,117) = 1.00000+0.600000./(1.00000+power(3.80000e-05./STATES(:,10), 1.40000));
    ALGEBRAIC(:,118) =  CONSTANTS(:,125).*ALGEBRAIC(:,117).*STATES(:,40).*STATES(:,41).*(STATES(:,1) - ALGEBRAIC(:,66));
    ALGEBRAIC(:,119) = 4.09400./(1.00000+exp( 0.121700.*((STATES(:,1) - ALGEBRAIC(:,65)) - 49.9340)));
    ALGEBRAIC(:,120) = ( 15.7200.*exp( 0.0674000.*((STATES(:,1) - ALGEBRAIC(:,65)) - 3.25700))+exp( 0.0618000.*((STATES(:,1) - ALGEBRAIC(:,65)) - 594.310)))./(1.00000+exp(  - 0.162900.*((STATES(:,1) - ALGEBRAIC(:,65))+14.2070)));
    ALGEBRAIC(:,121) = ALGEBRAIC(:,119)./(ALGEBRAIC(:,119)+ALGEBRAIC(:,120));
    ALGEBRAIC(:,122) =  CONSTANTS(:,126).*power((CONSTANTS(:,4)./5.00000), 1.0 ./ 2).*ALGEBRAIC(:,121).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,186) =  CONSTANTS(:,84).*exp(( (1.00000 - CONSTANTS(:,85)).*ALGEBRAIC(:,29))./3.00000);
    ALGEBRAIC(:,190) = ( CONSTANTS(:,79).*power(CONSTANTS(:,4)./CONSTANTS(:,87), 2.00000))./((power(1.00000+CONSTANTS(:,2)./ALGEBRAIC(:,186), 3.00000)+power(1.00000+CONSTANTS(:,4)./CONSTANTS(:,87), 2.00000)) - 1.00000);
    ALGEBRAIC(:,187) = CONSTANTS(:,92)./(1.00000+CONSTANTS(:,91)./CONSTANTS(:,93)+STATES(:,4)./CONSTANTS(:,94)+STATES(:,6)./CONSTANTS(:,95));
    ALGEBRAIC(:,191) = ( CONSTANTS(:,80).*ALGEBRAIC(:,187).*CONSTANTS(:,91))./(1.00000+CONSTANTS(:,89)./CONSTANTS(:,90));
    ALGEBRAIC(:,185) =  CONSTANTS(:,83).*exp(( CONSTANTS(:,85).*ALGEBRAIC(:,29))./3.00000);
    ALGEBRAIC(:,188) = ( CONSTANTS(:,75).*power(STATES(:,4)./ALGEBRAIC(:,185), 3.00000))./((power(1.00000+STATES(:,4)./ALGEBRAIC(:,185), 3.00000)+power(1.00000+STATES(:,6)./CONSTANTS(:,86), 2.00000)) - 1.00000);
    ALGEBRAIC(:,189) = ( CONSTANTS(:,78).*power(CONSTANTS(:,2)./ALGEBRAIC(:,186), 3.00000))./((power(1.00000+CONSTANTS(:,2)./ALGEBRAIC(:,186), 3.00000)+power(1.00000+CONSTANTS(:,4)./CONSTANTS(:,87), 2.00000)) - 1.00000);
    ALGEBRAIC(:,192) = ( CONSTANTS(:,82).*power(STATES(:,6)./CONSTANTS(:,86), 2.00000))./((power(1.00000+STATES(:,4)./ALGEBRAIC(:,185), 3.00000)+power(1.00000+STATES(:,6)./CONSTANTS(:,86), 2.00000)) - 1.00000);
    ALGEBRAIC(:,193) =  CONSTANTS(:,162).*ALGEBRAIC(:,188).*CONSTANTS(:,161)+ ALGEBRAIC(:,189).*ALGEBRAIC(:,192).*ALGEBRAIC(:,191)+ CONSTANTS(:,161).*ALGEBRAIC(:,192).*ALGEBRAIC(:,191)+ ALGEBRAIC(:,191).*ALGEBRAIC(:,188).*CONSTANTS(:,161);
    ALGEBRAIC(:,194) =  ALGEBRAIC(:,189).*CONSTANTS(:,160).*ALGEBRAIC(:,192)+ ALGEBRAIC(:,188).*CONSTANTS(:,161).*ALGEBRAIC(:,190)+ ALGEBRAIC(:,190).*CONSTANTS(:,160).*ALGEBRAIC(:,192)+ CONSTANTS(:,161).*ALGEBRAIC(:,190).*ALGEBRAIC(:,192);
    ALGEBRAIC(:,195) =  CONSTANTS(:,161).*ALGEBRAIC(:,190).*CONSTANTS(:,162)+ ALGEBRAIC(:,191).*ALGEBRAIC(:,189).*CONSTANTS(:,160)+ ALGEBRAIC(:,189).*CONSTANTS(:,160).*CONSTANTS(:,162)+ ALGEBRAIC(:,190).*CONSTANTS(:,162).*CONSTANTS(:,160);
    ALGEBRAIC(:,196) =  ALGEBRAIC(:,192).*ALGEBRAIC(:,191).*ALGEBRAIC(:,189)+ ALGEBRAIC(:,190).*CONSTANTS(:,162).*ALGEBRAIC(:,188)+ ALGEBRAIC(:,189).*CONSTANTS(:,162).*ALGEBRAIC(:,188)+ ALGEBRAIC(:,191).*ALGEBRAIC(:,189).*ALGEBRAIC(:,188);
    ALGEBRAIC(:,197) = ALGEBRAIC(:,193)./(ALGEBRAIC(:,193)+ALGEBRAIC(:,194)+ALGEBRAIC(:,195)+ALGEBRAIC(:,196));
    ALGEBRAIC(:,198) = ALGEBRAIC(:,194)./(ALGEBRAIC(:,193)+ALGEBRAIC(:,194)+ALGEBRAIC(:,195)+ALGEBRAIC(:,196));
    ALGEBRAIC(:,201) =  3.00000.*( ALGEBRAIC(:,197).*ALGEBRAIC(:,190) -  ALGEBRAIC(:,198).*ALGEBRAIC(:,191));
    ALGEBRAIC(:,199) = ALGEBRAIC(:,195)./(ALGEBRAIC(:,193)+ALGEBRAIC(:,194)+ALGEBRAIC(:,195)+ALGEBRAIC(:,196));
    ALGEBRAIC(:,200) = ALGEBRAIC(:,196)./(ALGEBRAIC(:,193)+ALGEBRAIC(:,194)+ALGEBRAIC(:,195)+ALGEBRAIC(:,196));
    ALGEBRAIC(:,202) =  2.00000.*( ALGEBRAIC(:,200).*CONSTANTS(:,160) -  ALGEBRAIC(:,199).*ALGEBRAIC(:,188));
    ALGEBRAIC(:,203) =  CONSTANTS(:,163).*( CONSTANTS(:,9).*ALGEBRAIC(:,201)+ CONSTANTS(:,11).*ALGEBRAIC(:,202));
    ALGEBRAIC(:,204) = 1.00000./(1.00000+exp( - (STATES(:,1) - 10.8968)./23.9871));
    ALGEBRAIC(:,205) =  CONSTANTS(:,127).*ALGEBRAIC(:,204).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,67) =  CONSTANTS(:,38).*CONSTANTS(:,37).*CONSTANTS(:,116).*CONSTANTS(:,117).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,12) = piecewise({VOI>=CONSTANTS(:,15)&VOI<=CONSTANTS(:,16)&(VOI - CONSTANTS(:,15)) -  floor((VOI - CONSTANTS(:,15))./CONSTANTS(:,18)).*CONSTANTS(:,18)<=CONSTANTS(:,19), CONSTANTS(:,17) }, 0.00000);
    ALGEBRAIC(:,99) = ( 0.500000.*(STATES(:,4)+STATES(:,6)+CONSTANTS(:,35)+ 4.00000.*STATES(:,10)))./1000.00;
    ALGEBRAIC(:,106) = exp(  - CONSTANTS(:,135).*1.00000.*(power(ALGEBRAIC(:,99), 1.0 ./ 2)./(1.00000+power(ALGEBRAIC(:,99), 1.0 ./ 2)) -  0.300000.*ALGEBRAIC(:,99)));
    ALGEBRAIC(:,109) = ( 1.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,106).*STATES(:,6).*exp( 1.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,142).*CONSTANTS(:,4)))./(exp( 1.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,112) =  (1.00000 - CONSTANTS(:,55)).*( (1.00000 - ALGEBRAIC(:,91)).*CONSTANTS(:,134).*ALGEBRAIC(:,109).*STATES(:,25).*( ALGEBRAIC(:,78).*(1.00000 - STATES(:,34))+ STATES(:,30).*ALGEBRAIC(:,81).*STATES(:,34))+ ALGEBRAIC(:,91).*CONSTANTS(:,139).*ALGEBRAIC(:,109).*STATES(:,25).*( ALGEBRAIC(:,82).*(1.00000 - STATES(:,34))+ STATES(:,30).*ALGEBRAIC(:,83).*STATES(:,34)));
    ALGEBRAIC(:,207) = (STATES(:,7) - STATES(:,6))./CONSTANTS(:,107);
    RATES(:,6) = (  - (((ALGEBRAIC(:,77)+ALGEBRAIC(:,116)+ALGEBRAIC(:,118)+ALGEBRAIC(:,122)+ALGEBRAIC(:,205)+ALGEBRAIC(:,67)+ALGEBRAIC(:,12)) -  2.00000.*ALGEBRAIC(:,203))+ALGEBRAIC(:,112)).*CONSTANTS(:,137))./( CONSTANTS(:,8).*CONSTANTS(:,143))+( ALGEBRAIC(:,207).*CONSTANTS(:,146))./CONSTANTS(:,143);
    ALGEBRAIC(:,87) = exp(  - CONSTANTS(:,135).*1.00000.*(power(ALGEBRAIC(:,84), 1.0 ./ 2)./(1.00000+power(ALGEBRAIC(:,84), 1.0 ./ 2)) -  0.300000.*ALGEBRAIC(:,84)));
    ALGEBRAIC(:,90) = ( 1.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,87).*STATES(:,7).*exp( 1.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,142).*CONSTANTS(:,4)))./(exp( 1.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,96) =  CONSTANTS(:,55).*( (1.00000 - ALGEBRAIC(:,91)).*CONSTANTS(:,134).*ALGEBRAIC(:,90).*STATES(:,25).*( ALGEBRAIC(:,78).*(1.00000 - STATES(:,33))+ STATES(:,30).*ALGEBRAIC(:,81).*STATES(:,33))+ ALGEBRAIC(:,91).*CONSTANTS(:,139).*ALGEBRAIC(:,90).*STATES(:,25).*( ALGEBRAIC(:,82).*(1.00000 - STATES(:,33))+ STATES(:,30).*ALGEBRAIC(:,83).*STATES(:,33)));
    RATES(:,7) = (  - ALGEBRAIC(:,96).*CONSTANTS(:,137))./( CONSTANTS(:,8).*CONSTANTS(:,146)) - ALGEBRAIC(:,207);
    ALGEBRAIC(:,64) =  (( CONSTANTS(:,6).*CONSTANTS(:,7))./( CONSTANTS(:,9).*CONSTANTS(:,8))).*log(CONSTANTS(:,2)./STATES(:,4));
    ALGEBRAIC(:,68) = 1.00000./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,50));
    ALGEBRAIC(:,69) =  CONSTANTS(:,42).*(STATES(:,1) - ALGEBRAIC(:,64)).*power(STATES(:,11), 3.00000).*( (1.00000 - ALGEBRAIC(:,68)).*STATES(:,12).*STATES(:,13)+ ALGEBRAIC(:,68).*STATES(:,14).*STATES(:,15));
    ALGEBRAIC(:,70) = 1.00000./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,50));
    ALGEBRAIC(:,71) =  CONSTANTS(:,119).*(STATES(:,1) - ALGEBRAIC(:,64)).*STATES(:,16).*( (1.00000 - ALGEBRAIC(:,70)).*STATES(:,17)+ ALGEBRAIC(:,70).*STATES(:,18));
    ALGEBRAIC(:,151) = 1.00000./(1.00000+power(CONSTANTS(:,73)./STATES(:,10), 2.00000));
    ALGEBRAIC(:,124) = exp( CONSTANTS(:,71).*ALGEBRAIC(:,29));
    ALGEBRAIC(:,131) = 1.00000+ (CONSTANTS(:,2)./CONSTANTS(:,64)).*(1.00000+1.00000./ALGEBRAIC(:,124));
    ALGEBRAIC(:,132) = CONSTANTS(:,2)./( CONSTANTS(:,64).*ALGEBRAIC(:,124).*ALGEBRAIC(:,131));
    ALGEBRAIC(:,135) =  ALGEBRAIC(:,132).*CONSTANTS(:,68);
    ALGEBRAIC(:,125) = 1.00000+ (STATES(:,4)./CONSTANTS(:,64)).*(1.00000+ALGEBRAIC(:,124));
    ALGEBRAIC(:,126) = ( STATES(:,4).*ALGEBRAIC(:,124))./( CONSTANTS(:,64).*ALGEBRAIC(:,125));
    ALGEBRAIC(:,138) =  ALGEBRAIC(:,126).*CONSTANTS(:,68);
    ALGEBRAIC(:,128) = 1.00000+ (STATES(:,4)./CONSTANTS(:,62)).*(1.00000+STATES(:,4)./CONSTANTS(:,63));
    ALGEBRAIC(:,129) = ( STATES(:,4).*STATES(:,4))./( ALGEBRAIC(:,128).*CONSTANTS(:,62).*CONSTANTS(:,63));
    ALGEBRAIC(:,141) =  ALGEBRAIC(:,129).*ALGEBRAIC(:,126).*CONSTANTS(:,66);
    ALGEBRAIC(:,142) =  ALGEBRAIC(:,132).*CONSTANTS(:,148).*CONSTANTS(:,66);
    ALGEBRAIC(:,133) = 1.00000./ALGEBRAIC(:,131);
    ALGEBRAIC(:,134) =  ALGEBRAIC(:,133).*CONSTANTS(:,67);
    ALGEBRAIC(:,136) = ALGEBRAIC(:,134)+ALGEBRAIC(:,135);
    ALGEBRAIC(:,123) = exp( CONSTANTS(:,72).*ALGEBRAIC(:,29));
    ALGEBRAIC(:,127) = 1.00000./ALGEBRAIC(:,125);
    ALGEBRAIC(:,137) = ( ALGEBRAIC(:,127).*CONSTANTS(:,67))./ALGEBRAIC(:,123);
    ALGEBRAIC(:,139) = ALGEBRAIC(:,137)+ALGEBRAIC(:,138);
    ALGEBRAIC(:,130) = 1.00000./ALGEBRAIC(:,128);
    ALGEBRAIC(:,140) =  ALGEBRAIC(:,130).*STATES(:,10).*CONSTANTS(:,69);
    ALGEBRAIC(:,143) =  CONSTANTS(:,151).*ALGEBRAIC(:,139).*(ALGEBRAIC(:,141)+ALGEBRAIC(:,140))+ CONSTANTS(:,152).*ALGEBRAIC(:,141).*(CONSTANTS(:,151)+ALGEBRAIC(:,136));
    ALGEBRAIC(:,144) =  CONSTANTS(:,150).*ALGEBRAIC(:,141).*(ALGEBRAIC(:,139)+CONSTANTS(:,152))+ ALGEBRAIC(:,139).*ALGEBRAIC(:,140).*(CONSTANTS(:,150)+ALGEBRAIC(:,142));
    ALGEBRAIC(:,145) =  CONSTANTS(:,150).*ALGEBRAIC(:,136).*(ALGEBRAIC(:,141)+ALGEBRAIC(:,140))+ ALGEBRAIC(:,142).*ALGEBRAIC(:,140).*(CONSTANTS(:,151)+ALGEBRAIC(:,136));
    ALGEBRAIC(:,146) =  CONSTANTS(:,151).*ALGEBRAIC(:,142).*(ALGEBRAIC(:,139)+CONSTANTS(:,152))+ ALGEBRAIC(:,136).*CONSTANTS(:,152).*(CONSTANTS(:,150)+ALGEBRAIC(:,142));
    ALGEBRAIC(:,147) = ALGEBRAIC(:,143)./(ALGEBRAIC(:,143)+ALGEBRAIC(:,144)+ALGEBRAIC(:,145)+ALGEBRAIC(:,146));
    ALGEBRAIC(:,148) = ALGEBRAIC(:,144)./(ALGEBRAIC(:,143)+ALGEBRAIC(:,144)+ALGEBRAIC(:,145)+ALGEBRAIC(:,146));
    ALGEBRAIC(:,149) = ALGEBRAIC(:,145)./(ALGEBRAIC(:,143)+ALGEBRAIC(:,144)+ALGEBRAIC(:,145)+ALGEBRAIC(:,146));
    ALGEBRAIC(:,150) = ALGEBRAIC(:,146)./(ALGEBRAIC(:,143)+ALGEBRAIC(:,144)+ALGEBRAIC(:,145)+ALGEBRAIC(:,146));
    ALGEBRAIC(:,152) = ( 3.00000.*( ALGEBRAIC(:,150).*ALGEBRAIC(:,141) -  ALGEBRAIC(:,147).*ALGEBRAIC(:,142))+ ALGEBRAIC(:,149).*ALGEBRAIC(:,138)) -  ALGEBRAIC(:,148).*ALGEBRAIC(:,135);
    ALGEBRAIC(:,153) =  ALGEBRAIC(:,148).*CONSTANTS(:,151) -  ALGEBRAIC(:,147).*CONSTANTS(:,150);
    ALGEBRAIC(:,154) =  (1.00000 - CONSTANTS(:,61)).*CONSTANTS(:,153).*ALGEBRAIC(:,151).*( CONSTANTS(:,9).*ALGEBRAIC(:,152)+ CONSTANTS(:,10).*ALGEBRAIC(:,153));
    ALGEBRAIC(:,206) = ( CONSTANTS(:,98).*ALGEBRAIC(:,26).*( STATES(:,4).*exp(ALGEBRAIC(:,29)) - CONSTANTS(:,2)))./(exp(ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,105) = exp(  - CONSTANTS(:,135).*1.00000.*(power(ALGEBRAIC(:,99), 1.0 ./ 2)./(1.00000+power(ALGEBRAIC(:,99), 1.0 ./ 2)) -  0.300000.*ALGEBRAIC(:,99)));
    ALGEBRAIC(:,108) = ( 1.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,105).*STATES(:,4).*exp( 1.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,141).*CONSTANTS(:,2)))./(exp( 1.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,111) =  (1.00000 - CONSTANTS(:,55)).*( (1.00000 - ALGEBRAIC(:,91)).*CONSTANTS(:,133).*ALGEBRAIC(:,108).*STATES(:,25).*( ALGEBRAIC(:,78).*(1.00000 - STATES(:,34))+ STATES(:,30).*ALGEBRAIC(:,81).*STATES(:,34))+ ALGEBRAIC(:,91).*CONSTANTS(:,138).*ALGEBRAIC(:,108).*STATES(:,25).*( ALGEBRAIC(:,82).*(1.00000 - STATES(:,34))+ STATES(:,30).*ALGEBRAIC(:,83).*STATES(:,34)));
    ALGEBRAIC(:,209) = (STATES(:,5) - STATES(:,4))./CONSTANTS(:,106);
    RATES(:,4) = (  - (ALGEBRAIC(:,69)+ALGEBRAIC(:,71)+ 3.00000.*ALGEBRAIC(:,154)+ALGEBRAIC(:,111)+ 3.00000.*ALGEBRAIC(:,203)+ALGEBRAIC(:,206)).*CONSTANTS(:,137))./( CONSTANTS(:,8).*CONSTANTS(:,143))+( ALGEBRAIC(:,209).*CONSTANTS(:,146))./CONSTANTS(:,143);
    ALGEBRAIC(:,181) = 1.00000./(1.00000+power(CONSTANTS(:,73)./STATES(:,3), 2.00000));
    ALGEBRAIC(:,161) = 1.00000+ (CONSTANTS(:,2)./CONSTANTS(:,64)).*(1.00000+1.00000./ALGEBRAIC(:,124));
    ALGEBRAIC(:,162) = CONSTANTS(:,2)./( CONSTANTS(:,64).*ALGEBRAIC(:,124).*ALGEBRAIC(:,161));
    ALGEBRAIC(:,165) =  ALGEBRAIC(:,162).*CONSTANTS(:,68);
    ALGEBRAIC(:,155) = 1.00000+ (STATES(:,5)./CONSTANTS(:,64)).*(1.00000+ALGEBRAIC(:,124));
    ALGEBRAIC(:,156) = ( STATES(:,5).*ALGEBRAIC(:,124))./( CONSTANTS(:,64).*ALGEBRAIC(:,155));
    ALGEBRAIC(:,168) =  ALGEBRAIC(:,156).*CONSTANTS(:,68);
    ALGEBRAIC(:,158) = 1.00000+ (STATES(:,5)./CONSTANTS(:,62)).*(1.00000+STATES(:,5)./CONSTANTS(:,63));
    ALGEBRAIC(:,159) = ( STATES(:,5).*STATES(:,5))./( ALGEBRAIC(:,158).*CONSTANTS(:,62).*CONSTANTS(:,63));
    ALGEBRAIC(:,171) =  ALGEBRAIC(:,159).*ALGEBRAIC(:,156).*CONSTANTS(:,66);
    ALGEBRAIC(:,172) =  ALGEBRAIC(:,162).*CONSTANTS(:,155).*CONSTANTS(:,66);
    ALGEBRAIC(:,163) = 1.00000./ALGEBRAIC(:,161);
    ALGEBRAIC(:,164) =  ALGEBRAIC(:,163).*CONSTANTS(:,67);
    ALGEBRAIC(:,166) = ALGEBRAIC(:,164)+ALGEBRAIC(:,165);
    ALGEBRAIC(:,157) = 1.00000./ALGEBRAIC(:,155);
    ALGEBRAIC(:,167) = ( ALGEBRAIC(:,157).*CONSTANTS(:,67))./ALGEBRAIC(:,123);
    ALGEBRAIC(:,169) = ALGEBRAIC(:,167)+ALGEBRAIC(:,168);
    ALGEBRAIC(:,160) = 1.00000./ALGEBRAIC(:,158);
    ALGEBRAIC(:,170) =  ALGEBRAIC(:,160).*STATES(:,3).*CONSTANTS(:,69);
    ALGEBRAIC(:,173) =  CONSTANTS(:,158).*ALGEBRAIC(:,169).*(ALGEBRAIC(:,171)+ALGEBRAIC(:,170))+ CONSTANTS(:,159).*ALGEBRAIC(:,171).*(CONSTANTS(:,158)+ALGEBRAIC(:,166));
    ALGEBRAIC(:,174) =  CONSTANTS(:,157).*ALGEBRAIC(:,171).*(ALGEBRAIC(:,169)+CONSTANTS(:,159))+ ALGEBRAIC(:,169).*ALGEBRAIC(:,170).*(CONSTANTS(:,157)+ALGEBRAIC(:,172));
    ALGEBRAIC(:,175) =  CONSTANTS(:,157).*ALGEBRAIC(:,166).*(ALGEBRAIC(:,171)+ALGEBRAIC(:,170))+ ALGEBRAIC(:,172).*ALGEBRAIC(:,170).*(CONSTANTS(:,158)+ALGEBRAIC(:,166));
    ALGEBRAIC(:,176) =  CONSTANTS(:,158).*ALGEBRAIC(:,172).*(ALGEBRAIC(:,169)+CONSTANTS(:,159))+ ALGEBRAIC(:,166).*CONSTANTS(:,159).*(CONSTANTS(:,157)+ALGEBRAIC(:,172));
    ALGEBRAIC(:,177) = ALGEBRAIC(:,173)./(ALGEBRAIC(:,173)+ALGEBRAIC(:,174)+ALGEBRAIC(:,175)+ALGEBRAIC(:,176));
    ALGEBRAIC(:,178) = ALGEBRAIC(:,174)./(ALGEBRAIC(:,173)+ALGEBRAIC(:,174)+ALGEBRAIC(:,175)+ALGEBRAIC(:,176));
    ALGEBRAIC(:,179) = ALGEBRAIC(:,175)./(ALGEBRAIC(:,173)+ALGEBRAIC(:,174)+ALGEBRAIC(:,175)+ALGEBRAIC(:,176));
    ALGEBRAIC(:,180) = ALGEBRAIC(:,176)./(ALGEBRAIC(:,173)+ALGEBRAIC(:,174)+ALGEBRAIC(:,175)+ALGEBRAIC(:,176));
    ALGEBRAIC(:,182) = ( 3.00000.*( ALGEBRAIC(:,180).*ALGEBRAIC(:,171) -  ALGEBRAIC(:,177).*ALGEBRAIC(:,172))+ ALGEBRAIC(:,179).*ALGEBRAIC(:,168)) -  ALGEBRAIC(:,178).*ALGEBRAIC(:,165);
    ALGEBRAIC(:,183) =  ALGEBRAIC(:,178).*CONSTANTS(:,158) -  ALGEBRAIC(:,177).*CONSTANTS(:,157);
    ALGEBRAIC(:,184) =  CONSTANTS(:,61).*CONSTANTS(:,153).*ALGEBRAIC(:,181).*( CONSTANTS(:,9).*ALGEBRAIC(:,182)+ CONSTANTS(:,10).*ALGEBRAIC(:,183));
    ALGEBRAIC(:,86) = exp(  - CONSTANTS(:,135).*1.00000.*(power(ALGEBRAIC(:,84), 1.0 ./ 2)./(1.00000+power(ALGEBRAIC(:,84), 1.0 ./ 2)) -  0.300000.*ALGEBRAIC(:,84)));
    ALGEBRAIC(:,89) = ( 1.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,86).*STATES(:,5).*exp( 1.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,141).*CONSTANTS(:,2)))./(exp( 1.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,93) =  CONSTANTS(:,55).*( (1.00000 - ALGEBRAIC(:,91)).*CONSTANTS(:,133).*ALGEBRAIC(:,89).*STATES(:,25).*( ALGEBRAIC(:,78).*(1.00000 - STATES(:,33))+ STATES(:,30).*ALGEBRAIC(:,81).*STATES(:,33))+ ALGEBRAIC(:,91).*CONSTANTS(:,138).*ALGEBRAIC(:,89).*STATES(:,25).*( ALGEBRAIC(:,82).*(1.00000 - STATES(:,33))+ STATES(:,30).*ALGEBRAIC(:,83).*STATES(:,33)));
    RATES(:,5) = (  - (ALGEBRAIC(:,93)+ 3.00000.*ALGEBRAIC(:,184)).*CONSTANTS(:,137))./( CONSTANTS(:,8).*CONSTANTS(:,146)) - ALGEBRAIC(:,209);
    ALGEBRAIC(:,212) = (STATES(:,3) - STATES(:,10))./CONSTANTS(:,108);
    ALGEBRAIC(:,214) = 1.00000./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,50));
    ALGEBRAIC(:,216) =  CONSTANTS(:,111).*( (1.00000 - ALGEBRAIC(:,214)).*STATES(:,42)+ ALGEBRAIC(:,214).*STATES(:,43));
    ALGEBRAIC(:,57) = 1.00000./(1.00000+( CONSTANTS(:,29).*CONSTANTS(:,30))./power(CONSTANTS(:,30)+STATES(:,3), 2.00000)+( CONSTANTS(:,31).*CONSTANTS(:,32))./power(CONSTANTS(:,32)+STATES(:,3), 2.00000));
    RATES(:,3) =  ALGEBRAIC(:,57).*(((  - (ALGEBRAIC(:,92) -  2.00000.*ALGEBRAIC(:,184)).*CONSTANTS(:,137))./( 2.00000.*CONSTANTS(:,8).*CONSTANTS(:,146))+( ALGEBRAIC(:,216).*CONSTANTS(:,145))./CONSTANTS(:,146)) - ALGEBRAIC(:,212));
    ALGEBRAIC(:,102) = exp(  - CONSTANTS(:,135).*4.00000.*(power(ALGEBRAIC(:,99), 1.0 ./ 2)./(1.00000+power(ALGEBRAIC(:,99), 1.0 ./ 2)) -  0.300000.*ALGEBRAIC(:,99)));
    ALGEBRAIC(:,107) = ( 4.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,102).*STATES(:,10).*exp( 2.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,140).*CONSTANTS(:,3)))./(exp( 2.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,110) =  (1.00000 - CONSTANTS(:,55)).*( (1.00000 - ALGEBRAIC(:,91)).*CONSTANTS(:,122).*ALGEBRAIC(:,107).*STATES(:,25).*( ALGEBRAIC(:,78).*(1.00000 - STATES(:,34))+ STATES(:,30).*ALGEBRAIC(:,81).*STATES(:,34))+ ALGEBRAIC(:,91).*CONSTANTS(:,132).*ALGEBRAIC(:,107).*STATES(:,25).*( ALGEBRAIC(:,82).*(1.00000 - STATES(:,34))+ STATES(:,30).*ALGEBRAIC(:,83).*STATES(:,34)));
    ALGEBRAIC(:,113) = ALGEBRAIC(:,92)+ALGEBRAIC(:,110);
    ALGEBRAIC(:,114) = ALGEBRAIC(:,93)+ALGEBRAIC(:,111);
    ALGEBRAIC(:,115) = ALGEBRAIC(:,96)+ALGEBRAIC(:,112);
    ALGEBRAIC(:,210) = ( CONSTANTS(:,100).*STATES(:,10))./(CONSTANTS(:,101)+STATES(:,10));
    ALGEBRAIC(:,208) = ( CONSTANTS(:,99).*4.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,102).*STATES(:,10).*exp( 2.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,140).*CONSTANTS(:,3)))./(exp( 2.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,211) =  (( CONSTANTS(:,105).*CONSTANTS(:,102))./(1.00000+CONSTANTS(:,104)./STATES(:,3))).*(STATES(:,1) - CONSTANTS(:,115));
    ALGEBRAIC(:,213) =  (( (1.00000 - CONSTANTS(:,105)).*CONSTANTS(:,102))./(1.00000+CONSTANTS(:,104)./STATES(:,10))).*(STATES(:,1) - CONSTANTS(:,115));
    ALGEBRAIC(:,215) = ALGEBRAIC(:,211)+ALGEBRAIC(:,213);
    ALGEBRAIC(:,217) =  CONSTANTS(:,103).*(STATES(:,1) - CONSTANTS(:,115));
    RATES(:,1) =  - (ALGEBRAIC(:,69)+ALGEBRAIC(:,71)+ALGEBRAIC(:,77)+ALGEBRAIC(:,113)+ALGEBRAIC(:,114)+ALGEBRAIC(:,115)+ALGEBRAIC(:,116)+ALGEBRAIC(:,118)+ALGEBRAIC(:,122)+ALGEBRAIC(:,154)+ALGEBRAIC(:,184)+ALGEBRAIC(:,203)+ALGEBRAIC(:,206)+ALGEBRAIC(:,205)+ALGEBRAIC(:,210)+ALGEBRAIC(:,208)+ALGEBRAIC(:,215)+ALGEBRAIC(:,217)+ALGEBRAIC(:,67)+ALGEBRAIC(:,12));
    ALGEBRAIC(:,218) = ( CONSTANTS(:,130).*0.00542500.*STATES(:,10))./(STATES(:,10)+0.000920000);
    ALGEBRAIC(:,219) = ( CONSTANTS(:,130).*2.75000.*0.00542500.*STATES(:,10))./((STATES(:,10)+0.000920000) - 0.000170000);
    ALGEBRAIC(:,220) = 1.00000./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,50));
    ALGEBRAIC(:,221) = ( 0.00488250.*STATES(:,8))./15.0000;
    ALGEBRAIC(:,222) =  CONSTANTS(:,112).*(( (1.00000 - ALGEBRAIC(:,220)).*ALGEBRAIC(:,218)+ ALGEBRAIC(:,220).*ALGEBRAIC(:,219)) - ALGEBRAIC(:,221));
    ALGEBRAIC(:,54) = 1.00000./(1.00000+( CONSTANTS(:,114).*CONSTANTS(:,26))./power(CONSTANTS(:,26)+STATES(:,10), 2.00000)+( CONSTANTS(:,27).*CONSTANTS(:,28))./power(CONSTANTS(:,28)+STATES(:,10), 2.00000));
    RATES(:,10) =  ALGEBRAIC(:,54).*(((  - ((ALGEBRAIC(:,110)+ALGEBRAIC(:,210)+ALGEBRAIC(:,208)) -  2.00000.*ALGEBRAIC(:,154)).*CONSTANTS(:,137))./( 2.00000.*CONSTANTS(:,8).*CONSTANTS(:,143)) - ( ALGEBRAIC(:,222).*CONSTANTS(:,144))./CONSTANTS(:,143))+( ALGEBRAIC(:,212).*CONSTANTS(:,146))./CONSTANTS(:,143));
    ALGEBRAIC(:,223) = (STATES(:,8) - STATES(:,9))./60.0000;
    RATES(:,8) = ALGEBRAIC(:,222) - ( ALGEBRAIC(:,223).*CONSTANTS(:,145))./CONSTANTS(:,144);
    ALGEBRAIC(:,60) = 1.00000./(1.00000+( CONSTANTS(:,33).*CONSTANTS(:,34))./power(CONSTANTS(:,34)+STATES(:,9), 2.00000));
    RATES(:,9) =  ALGEBRAIC(:,60).*(ALGEBRAIC(:,223) - ALGEBRAIC(:,216));
   RATES = RATES';
end

% Calculate algebraic variables
function ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI)
    statesSize = size(STATES);
    statesColumnCount = statesSize(2);
    if ( statesColumnCount == 1)
        STATES = STATES';
        utilOnes = 1;
    else
        statesRowCount = statesSize(1);
        utilOnes = ones(statesRowCount, 1);
    end
    ALGEBRAIC(:,4) = 1.00000./(1.00000+exp((STATES(:,1)+87.6100)./7.48800));
    ALGEBRAIC(:,5) = 1.00000./(1.00000+exp((STATES(:,1)+93.8100)./7.48800));
    ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,1)+18.0800)./2.79160));
    ALGEBRAIC(:,1) = 1.00000./power(1.00000+exp( - (STATES(:,1)+56.8600)./9.03000), 2.00000);
    ALGEBRAIC(:,14) =  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(:,3) = 1.00000./(1.00000+exp( - (STATES(:,1)+42.8500)./5.26400));
    ALGEBRAIC(:,17) =  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(:,6) = 1.00000./(1.00000+exp( - ((STATES(:,1)+CONSTANTS(:,46)) - 14.3400)./14.8200));
    ALGEBRAIC(:,18) = 1.05150./(1.00000./( 1.20890.*(1.00000+exp( - ((STATES(:,1)+CONSTANTS(:,46)) - 18.4099)./29.3814)))+3.50000./(1.00000+exp((STATES(:,1)+CONSTANTS(:,46)+100.000)./29.3814)));
    ALGEBRAIC(:,8) = piecewise({STATES(:,1)>=31.4978, 1.00000 },  1.07630.*exp(  - 1.00700.*exp(  - 0.0829000.*STATES(:,1))));
    ALGEBRAIC(:,23) = CONSTANTS(:,53)+0.600000+1.00000./(exp(  - 0.0500000.*(STATES(:,1)+CONSTANTS(:,52)+6.00000))+exp( 0.0900000.*(STATES(:,1)+CONSTANTS(:,52)+14.0000)));
    ALGEBRAIC(:,9) = 1.00000./(1.00000+exp((STATES(:,1)+19.5800)./3.69600));
    ALGEBRAIC(:,24) = 7.00000+1.00000./( 0.00450000.*exp( - (STATES(:,1)+20.0000)./10.0000)+ 0.00450000.*exp((STATES(:,1)+20.0000)./10.0000));
    ALGEBRAIC(:,25) = 1000.00+1.00000./( 3.50000e-05.*exp( - (STATES(:,1)+5.00000)./4.00000)+ 3.50000e-05.*exp((STATES(:,1)+5.00000)./6.00000));
    ALGEBRAIC(:,11) =  STATES(:,30).*1.00000;
    ALGEBRAIC(:,21) = 1.00000./(CONSTANTS(:,48)./ALGEBRAIC(:,11)+power(1.00000+CONSTANTS(:,47)./STATES(:,3), 4.00000));
    ALGEBRAIC(:,22) = 1.00000./(CONSTANTS(:,48)./ALGEBRAIC(:,11)+power(1.00000+CONSTANTS(:,47)./STATES(:,10), 4.00000));
    ALGEBRAIC(:,13) = 1.00000./(1.00000+exp( - (STATES(:,1)+11.6000)./8.93200));
    ALGEBRAIC(:,28) = 817.300+1.00000./( 0.000232600.*exp((STATES(:,1)+48.2800)./17.8000)+ 0.00129200.*exp( - (STATES(:,1)+210.000)./230.000));
    ALGEBRAIC(:,33) = 1.00000./(1.00000+exp( - ((STATES(:,1)+CONSTANTS(:,46)) - 24.3400)./14.8200));
    ALGEBRAIC(:,20) = ALGEBRAIC(:,9);
    ALGEBRAIC(:,34) = 7.00000+1.00000./( 0.0400000.*exp( - (STATES(:,1) - 4.00000)./7.00000)+ 0.0400000.*exp((STATES(:,1) - 4.00000)./7.00000));
    ALGEBRAIC(:,35) = 100.000+1.00000./( 0.000120000.*exp( - STATES(:,1)./3.00000)+ 0.000120000.*exp(STATES(:,1)./7.00000));
    ALGEBRAIC(:,36) =  2.50000.*ALGEBRAIC(:,24);
    ALGEBRAIC(:,27) = ALGEBRAIC(:,13);
    ALGEBRAIC(:,37) = 1.00000./( 0.0100000.*exp((STATES(:,1) - 50.0000)./20.0000)+ 0.0193000.*exp( - (STATES(:,1)+66.5400)./31.0000));
    ALGEBRAIC(:,44) = ( CONSTANTS(:,23).*(1.00000 - STATES(:,2)))./(1.00000+CONSTANTS(:,24)./STATES(:,3));
    ALGEBRAIC(:,2) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000);
    ALGEBRAIC(:,15) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 },  0.0570000.*exp( - (STATES(:,1)+80.0000)./6.80000));
    ALGEBRAIC(:,30) = 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(:,38) = 1.00000./(ALGEBRAIC(:,15)+ALGEBRAIC(:,30));
    ALGEBRAIC(:,41) =  2.50000.*ALGEBRAIC(:,34);
    ALGEBRAIC(:,39) = ALGEBRAIC(:,2);
    ALGEBRAIC(:,16) = 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(:,31) = 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(:,45) = 1.00000./(ALGEBRAIC(:,16)+ALGEBRAIC(:,31));
    ALGEBRAIC(:,46) = 1.00000./power(1.00000+exp((STATES(:,1)+77.5500)./7.43000), 2.00000);
    ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,1)+CONSTANTS(:,46)+43.9400)./5.71100));
    ALGEBRAIC(:,19) = piecewise({CONSTANTS(:,1)==1.00000, 1.00000 - 0.950000./(1.00000+exp((STATES(:,1)+CONSTANTS(:,46)+70.0000)./5.00000)) }, 1.00000);
    ALGEBRAIC(:,32) = 4.56200+1.00000./( 0.393300.*exp( - (STATES(:,1)+CONSTANTS(:,46)+100.000)./100.000)+ 0.0800400.*exp((STATES(:,1)+CONSTANTS(:,46)+50.0000)./16.5900));
    ALGEBRAIC(:,47) =  ALGEBRAIC(:,32).*ALGEBRAIC(:,19);
    ALGEBRAIC(:,29) = ( STATES(:,1).*CONSTANTS(:,8))./( CONSTANTS(:,6).*CONSTANTS(:,7));
    ALGEBRAIC(:,42) =  0.116100.*exp( 0.299000.*ALGEBRAIC(:,29));
    ALGEBRAIC(:,48) =  0.244200.*exp(  - 1.60400.*ALGEBRAIC(:,29));
    ALGEBRAIC(:,51) =  1.46000.*ALGEBRAIC(:,45);
    ALGEBRAIC(:,40) = 23.6200+1.00000./( 0.00141600.*exp( - (STATES(:,1)+CONSTANTS(:,46)+96.5200)./59.0500)+ 1.78000e-08.*exp((STATES(:,1)+CONSTANTS(:,46)+114.100)./8.07900));
    ALGEBRAIC(:,52) =  ALGEBRAIC(:,40).*ALGEBRAIC(:,19);
    ALGEBRAIC(:,43) =  0.0578000.*exp( 0.971000.*ALGEBRAIC(:,29));
    ALGEBRAIC(:,49) =  0.000349000.*exp(  - 1.06200.*ALGEBRAIC(:,29));
    ALGEBRAIC(:,53) =  0.253300.*exp( 0.595300.*ALGEBRAIC(:,29));
    ALGEBRAIC(:,56) =  0.0652500.*exp(  - 0.820900.*ALGEBRAIC(:,29));
    ALGEBRAIC(:,55) = 1.35400+0.000100000./(exp(((STATES(:,1)+CONSTANTS(:,46)) - 167.400)./15.8900)+exp( - ((STATES(:,1)+CONSTANTS(:,46)) - 12.2300)./0.215400));
    ALGEBRAIC(:,58) = 1.00000 - 0.500000./(1.00000+exp((STATES(:,1)+CONSTANTS(:,46)+70.0000)./20.0000));
    ALGEBRAIC(:,61) =  ALGEBRAIC(:,55).*ALGEBRAIC(:,58).*ALGEBRAIC(:,47);
    ALGEBRAIC(:,62) =  ALGEBRAIC(:,55).*ALGEBRAIC(:,58).*ALGEBRAIC(:,52);
    ALGEBRAIC(:,59) =  5.20000e-05.*exp( 1.52500.*ALGEBRAIC(:,29));
    ALGEBRAIC(:,63) = ( ALGEBRAIC(:,49).*ALGEBRAIC(:,56).*ALGEBRAIC(:,59))./( ALGEBRAIC(:,43).*ALGEBRAIC(:,53));
    ALGEBRAIC(:,78) =  CONSTANTS(:,50).*STATES(:,26)+ CONSTANTS(:,121).*STATES(:,27);
    ALGEBRAIC(:,79) = 0.300000+0.600000./(1.00000+exp((STATES(:,1) - 10.0000)./10.0000));
    ALGEBRAIC(:,80) = 1.00000 - ALGEBRAIC(:,79);
    ALGEBRAIC(:,81) =  ALGEBRAIC(:,79).*STATES(:,28)+ ALGEBRAIC(:,80).*STATES(:,29);
    ALGEBRAIC(:,82) =  CONSTANTS(:,50).*STATES(:,31)+ CONSTANTS(:,121).*STATES(:,27);
    ALGEBRAIC(:,83) =  ALGEBRAIC(:,79).*STATES(:,32)+ ALGEBRAIC(:,80).*STATES(:,29);
    ALGEBRAIC(:,26) = ( STATES(:,1).*CONSTANTS(:,8).*CONSTANTS(:,8))./( CONSTANTS(:,6).*CONSTANTS(:,7));
    ALGEBRAIC(:,84) = ( 0.500000.*(STATES(:,5)+STATES(:,7)+CONSTANTS(:,35)+ 4.00000.*STATES(:,3)))./1000.00;
    ALGEBRAIC(:,85) = exp(  - CONSTANTS(:,135).*4.00000.*(power(ALGEBRAIC(:,84), 1.0 ./ 2)./(1.00000+power(ALGEBRAIC(:,84), 1.0 ./ 2)) -  0.300000.*ALGEBRAIC(:,84)));
    ALGEBRAIC(:,88) = ( 4.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,85).*STATES(:,3).*exp( 2.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,140).*CONSTANTS(:,3)))./(exp( 2.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,50) = ALGEBRAIC(:,44)+STATES(:,2);
    ALGEBRAIC(:,91) = 1.00000./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,50));
    ALGEBRAIC(:,92) =  CONSTANTS(:,55).*( (1.00000 - ALGEBRAIC(:,91)).*CONSTANTS(:,122).*ALGEBRAIC(:,88).*STATES(:,25).*( ALGEBRAIC(:,78).*(1.00000 - STATES(:,33))+ STATES(:,30).*ALGEBRAIC(:,81).*STATES(:,33))+ ALGEBRAIC(:,91).*CONSTANTS(:,132).*ALGEBRAIC(:,88).*STATES(:,25).*( ALGEBRAIC(:,82).*(1.00000 - STATES(:,33))+ STATES(:,30).*ALGEBRAIC(:,83).*STATES(:,33)));
    ALGEBRAIC(:,94) = ((  - CONSTANTS(:,128).*ALGEBRAIC(:,92))./1.00000)./(1.00000+power(CONSTANTS(:,110)./STATES(:,9), 8.00000));
    ALGEBRAIC(:,97) = piecewise({CONSTANTS(:,1)==2.00000,  ALGEBRAIC(:,94).*1.70000 }, ALGEBRAIC(:,94));
    ALGEBRAIC(:,100) = CONSTANTS(:,109)./(1.00000+0.0123000./STATES(:,9));
    ALGEBRAIC(:,103) = piecewise({ALGEBRAIC(:,100)<0.00100000, 0.00100000 }, ALGEBRAIC(:,100));
    ALGEBRAIC(:,95) = ((  - CONSTANTS(:,136).*ALGEBRAIC(:,92))./1.00000)./(1.00000+power(CONSTANTS(:,110)./STATES(:,9), 8.00000));
    ALGEBRAIC(:,98) = piecewise({CONSTANTS(:,1)==2.00000,  ALGEBRAIC(:,95).*1.70000 }, ALGEBRAIC(:,95));
    ALGEBRAIC(:,101) = CONSTANTS(:,129)./(1.00000+0.0123000./STATES(:,9));
    ALGEBRAIC(:,104) = piecewise({ALGEBRAIC(:,101)<0.00100000, 0.00100000 }, ALGEBRAIC(:,101));
    ALGEBRAIC(:,65) =  (( CONSTANTS(:,6).*CONSTANTS(:,7))./( CONSTANTS(:,11).*CONSTANTS(:,8))).*log(CONSTANTS(:,4)./STATES(:,6));
    ALGEBRAIC(:,72) = 1.00000./(1.00000+exp(((STATES(:,1)+CONSTANTS(:,46)) - 213.600)./151.200));
    ALGEBRAIC(:,73) = 1.00000 - ALGEBRAIC(:,72);
    ALGEBRAIC(:,74) =  ALGEBRAIC(:,72).*STATES(:,20)+ ALGEBRAIC(:,73).*STATES(:,21);
    ALGEBRAIC(:,75) =  ALGEBRAIC(:,72).*STATES(:,23)+ ALGEBRAIC(:,73).*STATES(:,24);
    ALGEBRAIC(:,76) = 1.00000./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,50));
    ALGEBRAIC(:,77) =  CONSTANTS(:,120).*(STATES(:,1) - ALGEBRAIC(:,65)).*( (1.00000 - ALGEBRAIC(:,76)).*STATES(:,19).*ALGEBRAIC(:,74)+ ALGEBRAIC(:,76).*STATES(:,22).*ALGEBRAIC(:,75));
    ALGEBRAIC(:,116) =  CONSTANTS(:,124).*power((CONSTANTS(:,4)./5.00000), 1.0 ./ 2).*STATES(:,39).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,66) =  (( CONSTANTS(:,6).*CONSTANTS(:,7))./( CONSTANTS(:,11).*CONSTANTS(:,8))).*log((CONSTANTS(:,4)+ CONSTANTS(:,36).*CONSTANTS(:,2))./(STATES(:,6)+ CONSTANTS(:,36).*STATES(:,4)));
    ALGEBRAIC(:,117) = 1.00000+0.600000./(1.00000+power(3.80000e-05./STATES(:,10), 1.40000));
    ALGEBRAIC(:,118) =  CONSTANTS(:,125).*ALGEBRAIC(:,117).*STATES(:,40).*STATES(:,41).*(STATES(:,1) - ALGEBRAIC(:,66));
    ALGEBRAIC(:,119) = 4.09400./(1.00000+exp( 0.121700.*((STATES(:,1) - ALGEBRAIC(:,65)) - 49.9340)));
    ALGEBRAIC(:,120) = ( 15.7200.*exp( 0.0674000.*((STATES(:,1) - ALGEBRAIC(:,65)) - 3.25700))+exp( 0.0618000.*((STATES(:,1) - ALGEBRAIC(:,65)) - 594.310)))./(1.00000+exp(  - 0.162900.*((STATES(:,1) - ALGEBRAIC(:,65))+14.2070)));
    ALGEBRAIC(:,121) = ALGEBRAIC(:,119)./(ALGEBRAIC(:,119)+ALGEBRAIC(:,120));
    ALGEBRAIC(:,122) =  CONSTANTS(:,126).*power((CONSTANTS(:,4)./5.00000), 1.0 ./ 2).*ALGEBRAIC(:,121).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,186) =  CONSTANTS(:,84).*exp(( (1.00000 - CONSTANTS(:,85)).*ALGEBRAIC(:,29))./3.00000);
    ALGEBRAIC(:,190) = ( CONSTANTS(:,79).*power(CONSTANTS(:,4)./CONSTANTS(:,87), 2.00000))./((power(1.00000+CONSTANTS(:,2)./ALGEBRAIC(:,186), 3.00000)+power(1.00000+CONSTANTS(:,4)./CONSTANTS(:,87), 2.00000)) - 1.00000);
    ALGEBRAIC(:,187) = CONSTANTS(:,92)./(1.00000+CONSTANTS(:,91)./CONSTANTS(:,93)+STATES(:,4)./CONSTANTS(:,94)+STATES(:,6)./CONSTANTS(:,95));
    ALGEBRAIC(:,191) = ( CONSTANTS(:,80).*ALGEBRAIC(:,187).*CONSTANTS(:,91))./(1.00000+CONSTANTS(:,89)./CONSTANTS(:,90));
    ALGEBRAIC(:,185) =  CONSTANTS(:,83).*exp(( CONSTANTS(:,85).*ALGEBRAIC(:,29))./3.00000);
    ALGEBRAIC(:,188) = ( CONSTANTS(:,75).*power(STATES(:,4)./ALGEBRAIC(:,185), 3.00000))./((power(1.00000+STATES(:,4)./ALGEBRAIC(:,185), 3.00000)+power(1.00000+STATES(:,6)./CONSTANTS(:,86), 2.00000)) - 1.00000);
    ALGEBRAIC(:,189) = ( CONSTANTS(:,78).*power(CONSTANTS(:,2)./ALGEBRAIC(:,186), 3.00000))./((power(1.00000+CONSTANTS(:,2)./ALGEBRAIC(:,186), 3.00000)+power(1.00000+CONSTANTS(:,4)./CONSTANTS(:,87), 2.00000)) - 1.00000);
    ALGEBRAIC(:,192) = ( CONSTANTS(:,82).*power(STATES(:,6)./CONSTANTS(:,86), 2.00000))./((power(1.00000+STATES(:,4)./ALGEBRAIC(:,185), 3.00000)+power(1.00000+STATES(:,6)./CONSTANTS(:,86), 2.00000)) - 1.00000);
    ALGEBRAIC(:,193) =  CONSTANTS(:,162).*ALGEBRAIC(:,188).*CONSTANTS(:,161)+ ALGEBRAIC(:,189).*ALGEBRAIC(:,192).*ALGEBRAIC(:,191)+ CONSTANTS(:,161).*ALGEBRAIC(:,192).*ALGEBRAIC(:,191)+ ALGEBRAIC(:,191).*ALGEBRAIC(:,188).*CONSTANTS(:,161);
    ALGEBRAIC(:,194) =  ALGEBRAIC(:,189).*CONSTANTS(:,160).*ALGEBRAIC(:,192)+ ALGEBRAIC(:,188).*CONSTANTS(:,161).*ALGEBRAIC(:,190)+ ALGEBRAIC(:,190).*CONSTANTS(:,160).*ALGEBRAIC(:,192)+ CONSTANTS(:,161).*ALGEBRAIC(:,190).*ALGEBRAIC(:,192);
    ALGEBRAIC(:,195) =  CONSTANTS(:,161).*ALGEBRAIC(:,190).*CONSTANTS(:,162)+ ALGEBRAIC(:,191).*ALGEBRAIC(:,189).*CONSTANTS(:,160)+ ALGEBRAIC(:,189).*CONSTANTS(:,160).*CONSTANTS(:,162)+ ALGEBRAIC(:,190).*CONSTANTS(:,162).*CONSTANTS(:,160);
    ALGEBRAIC(:,196) =  ALGEBRAIC(:,192).*ALGEBRAIC(:,191).*ALGEBRAIC(:,189)+ ALGEBRAIC(:,190).*CONSTANTS(:,162).*ALGEBRAIC(:,188)+ ALGEBRAIC(:,189).*CONSTANTS(:,162).*ALGEBRAIC(:,188)+ ALGEBRAIC(:,191).*ALGEBRAIC(:,189).*ALGEBRAIC(:,188);
    ALGEBRAIC(:,197) = ALGEBRAIC(:,193)./(ALGEBRAIC(:,193)+ALGEBRAIC(:,194)+ALGEBRAIC(:,195)+ALGEBRAIC(:,196));
    ALGEBRAIC(:,198) = ALGEBRAIC(:,194)./(ALGEBRAIC(:,193)+ALGEBRAIC(:,194)+ALGEBRAIC(:,195)+ALGEBRAIC(:,196));
    ALGEBRAIC(:,201) =  3.00000.*( ALGEBRAIC(:,197).*ALGEBRAIC(:,190) -  ALGEBRAIC(:,198).*ALGEBRAIC(:,191));
    ALGEBRAIC(:,199) = ALGEBRAIC(:,195)./(ALGEBRAIC(:,193)+ALGEBRAIC(:,194)+ALGEBRAIC(:,195)+ALGEBRAIC(:,196));
    ALGEBRAIC(:,200) = ALGEBRAIC(:,196)./(ALGEBRAIC(:,193)+ALGEBRAIC(:,194)+ALGEBRAIC(:,195)+ALGEBRAIC(:,196));
    ALGEBRAIC(:,202) =  2.00000.*( ALGEBRAIC(:,200).*CONSTANTS(:,160) -  ALGEBRAIC(:,199).*ALGEBRAIC(:,188));
    ALGEBRAIC(:,203) =  CONSTANTS(:,163).*( CONSTANTS(:,9).*ALGEBRAIC(:,201)+ CONSTANTS(:,11).*ALGEBRAIC(:,202));
    ALGEBRAIC(:,204) = 1.00000./(1.00000+exp( - (STATES(:,1) - 10.8968)./23.9871));
    ALGEBRAIC(:,205) =  CONSTANTS(:,127).*ALGEBRAIC(:,204).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,67) =  CONSTANTS(:,38).*CONSTANTS(:,37).*CONSTANTS(:,116).*CONSTANTS(:,117).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,12) = piecewise({VOI>=CONSTANTS(:,15)&VOI<=CONSTANTS(:,16)&(VOI - CONSTANTS(:,15)) -  floor((VOI - CONSTANTS(:,15))./CONSTANTS(:,18)).*CONSTANTS(:,18)<=CONSTANTS(:,19), CONSTANTS(:,17) }, 0.00000);
    ALGEBRAIC(:,99) = ( 0.500000.*(STATES(:,4)+STATES(:,6)+CONSTANTS(:,35)+ 4.00000.*STATES(:,10)))./1000.00;
    ALGEBRAIC(:,106) = exp(  - CONSTANTS(:,135).*1.00000.*(power(ALGEBRAIC(:,99), 1.0 ./ 2)./(1.00000+power(ALGEBRAIC(:,99), 1.0 ./ 2)) -  0.300000.*ALGEBRAIC(:,99)));
    ALGEBRAIC(:,109) = ( 1.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,106).*STATES(:,6).*exp( 1.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,142).*CONSTANTS(:,4)))./(exp( 1.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,112) =  (1.00000 - CONSTANTS(:,55)).*( (1.00000 - ALGEBRAIC(:,91)).*CONSTANTS(:,134).*ALGEBRAIC(:,109).*STATES(:,25).*( ALGEBRAIC(:,78).*(1.00000 - STATES(:,34))+ STATES(:,30).*ALGEBRAIC(:,81).*STATES(:,34))+ ALGEBRAIC(:,91).*CONSTANTS(:,139).*ALGEBRAIC(:,109).*STATES(:,25).*( ALGEBRAIC(:,82).*(1.00000 - STATES(:,34))+ STATES(:,30).*ALGEBRAIC(:,83).*STATES(:,34)));
    ALGEBRAIC(:,207) = (STATES(:,7) - STATES(:,6))./CONSTANTS(:,107);
    ALGEBRAIC(:,87) = exp(  - CONSTANTS(:,135).*1.00000.*(power(ALGEBRAIC(:,84), 1.0 ./ 2)./(1.00000+power(ALGEBRAIC(:,84), 1.0 ./ 2)) -  0.300000.*ALGEBRAIC(:,84)));
    ALGEBRAIC(:,90) = ( 1.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,87).*STATES(:,7).*exp( 1.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,142).*CONSTANTS(:,4)))./(exp( 1.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,96) =  CONSTANTS(:,55).*( (1.00000 - ALGEBRAIC(:,91)).*CONSTANTS(:,134).*ALGEBRAIC(:,90).*STATES(:,25).*( ALGEBRAIC(:,78).*(1.00000 - STATES(:,33))+ STATES(:,30).*ALGEBRAIC(:,81).*STATES(:,33))+ ALGEBRAIC(:,91).*CONSTANTS(:,139).*ALGEBRAIC(:,90).*STATES(:,25).*( ALGEBRAIC(:,82).*(1.00000 - STATES(:,33))+ STATES(:,30).*ALGEBRAIC(:,83).*STATES(:,33)));
    ALGEBRAIC(:,64) =  (( CONSTANTS(:,6).*CONSTANTS(:,7))./( CONSTANTS(:,9).*CONSTANTS(:,8))).*log(CONSTANTS(:,2)./STATES(:,4));
    ALGEBRAIC(:,68) = 1.00000./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,50));
    ALGEBRAIC(:,69) =  CONSTANTS(:,42).*(STATES(:,1) - ALGEBRAIC(:,64)).*power(STATES(:,11), 3.00000).*( (1.00000 - ALGEBRAIC(:,68)).*STATES(:,12).*STATES(:,13)+ ALGEBRAIC(:,68).*STATES(:,14).*STATES(:,15));
    ALGEBRAIC(:,70) = 1.00000./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,50));
    ALGEBRAIC(:,71) =  CONSTANTS(:,119).*(STATES(:,1) - ALGEBRAIC(:,64)).*STATES(:,16).*( (1.00000 - ALGEBRAIC(:,70)).*STATES(:,17)+ ALGEBRAIC(:,70).*STATES(:,18));
    ALGEBRAIC(:,151) = 1.00000./(1.00000+power(CONSTANTS(:,73)./STATES(:,10), 2.00000));
    ALGEBRAIC(:,124) = exp( CONSTANTS(:,71).*ALGEBRAIC(:,29));
    ALGEBRAIC(:,131) = 1.00000+ (CONSTANTS(:,2)./CONSTANTS(:,64)).*(1.00000+1.00000./ALGEBRAIC(:,124));
    ALGEBRAIC(:,132) = CONSTANTS(:,2)./( CONSTANTS(:,64).*ALGEBRAIC(:,124).*ALGEBRAIC(:,131));
    ALGEBRAIC(:,135) =  ALGEBRAIC(:,132).*CONSTANTS(:,68);
    ALGEBRAIC(:,125) = 1.00000+ (STATES(:,4)./CONSTANTS(:,64)).*(1.00000+ALGEBRAIC(:,124));
    ALGEBRAIC(:,126) = ( STATES(:,4).*ALGEBRAIC(:,124))./( CONSTANTS(:,64).*ALGEBRAIC(:,125));
    ALGEBRAIC(:,138) =  ALGEBRAIC(:,126).*CONSTANTS(:,68);
    ALGEBRAIC(:,128) = 1.00000+ (STATES(:,4)./CONSTANTS(:,62)).*(1.00000+STATES(:,4)./CONSTANTS(:,63));
    ALGEBRAIC(:,129) = ( STATES(:,4).*STATES(:,4))./( ALGEBRAIC(:,128).*CONSTANTS(:,62).*CONSTANTS(:,63));
    ALGEBRAIC(:,141) =  ALGEBRAIC(:,129).*ALGEBRAIC(:,126).*CONSTANTS(:,66);
    ALGEBRAIC(:,142) =  ALGEBRAIC(:,132).*CONSTANTS(:,148).*CONSTANTS(:,66);
    ALGEBRAIC(:,133) = 1.00000./ALGEBRAIC(:,131);
    ALGEBRAIC(:,134) =  ALGEBRAIC(:,133).*CONSTANTS(:,67);
    ALGEBRAIC(:,136) = ALGEBRAIC(:,134)+ALGEBRAIC(:,135);
    ALGEBRAIC(:,123) = exp( CONSTANTS(:,72).*ALGEBRAIC(:,29));
    ALGEBRAIC(:,127) = 1.00000./ALGEBRAIC(:,125);
    ALGEBRAIC(:,137) = ( ALGEBRAIC(:,127).*CONSTANTS(:,67))./ALGEBRAIC(:,123);
    ALGEBRAIC(:,139) = ALGEBRAIC(:,137)+ALGEBRAIC(:,138);
    ALGEBRAIC(:,130) = 1.00000./ALGEBRAIC(:,128);
    ALGEBRAIC(:,140) =  ALGEBRAIC(:,130).*STATES(:,10).*CONSTANTS(:,69);
    ALGEBRAIC(:,143) =  CONSTANTS(:,151).*ALGEBRAIC(:,139).*(ALGEBRAIC(:,141)+ALGEBRAIC(:,140))+ CONSTANTS(:,152).*ALGEBRAIC(:,141).*(CONSTANTS(:,151)+ALGEBRAIC(:,136));
    ALGEBRAIC(:,144) =  CONSTANTS(:,150).*ALGEBRAIC(:,141).*(ALGEBRAIC(:,139)+CONSTANTS(:,152))+ ALGEBRAIC(:,139).*ALGEBRAIC(:,140).*(CONSTANTS(:,150)+ALGEBRAIC(:,142));
    ALGEBRAIC(:,145) =  CONSTANTS(:,150).*ALGEBRAIC(:,136).*(ALGEBRAIC(:,141)+ALGEBRAIC(:,140))+ ALGEBRAIC(:,142).*ALGEBRAIC(:,140).*(CONSTANTS(:,151)+ALGEBRAIC(:,136));
    ALGEBRAIC(:,146) =  CONSTANTS(:,151).*ALGEBRAIC(:,142).*(ALGEBRAIC(:,139)+CONSTANTS(:,152))+ ALGEBRAIC(:,136).*CONSTANTS(:,152).*(CONSTANTS(:,150)+ALGEBRAIC(:,142));
    ALGEBRAIC(:,147) = ALGEBRAIC(:,143)./(ALGEBRAIC(:,143)+ALGEBRAIC(:,144)+ALGEBRAIC(:,145)+ALGEBRAIC(:,146));
    ALGEBRAIC(:,148) = ALGEBRAIC(:,144)./(ALGEBRAIC(:,143)+ALGEBRAIC(:,144)+ALGEBRAIC(:,145)+ALGEBRAIC(:,146));
    ALGEBRAIC(:,149) = ALGEBRAIC(:,145)./(ALGEBRAIC(:,143)+ALGEBRAIC(:,144)+ALGEBRAIC(:,145)+ALGEBRAIC(:,146));
    ALGEBRAIC(:,150) = ALGEBRAIC(:,146)./(ALGEBRAIC(:,143)+ALGEBRAIC(:,144)+ALGEBRAIC(:,145)+ALGEBRAIC(:,146));
    ALGEBRAIC(:,152) = ( 3.00000.*( ALGEBRAIC(:,150).*ALGEBRAIC(:,141) -  ALGEBRAIC(:,147).*ALGEBRAIC(:,142))+ ALGEBRAIC(:,149).*ALGEBRAIC(:,138)) -  ALGEBRAIC(:,148).*ALGEBRAIC(:,135);
    ALGEBRAIC(:,153) =  ALGEBRAIC(:,148).*CONSTANTS(:,151) -  ALGEBRAIC(:,147).*CONSTANTS(:,150);
    ALGEBRAIC(:,154) =  (1.00000 - CONSTANTS(:,61)).*CONSTANTS(:,153).*ALGEBRAIC(:,151).*( CONSTANTS(:,9).*ALGEBRAIC(:,152)+ CONSTANTS(:,10).*ALGEBRAIC(:,153));
    ALGEBRAIC(:,206) = ( CONSTANTS(:,98).*ALGEBRAIC(:,26).*( STATES(:,4).*exp(ALGEBRAIC(:,29)) - CONSTANTS(:,2)))./(exp(ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,105) = exp(  - CONSTANTS(:,135).*1.00000.*(power(ALGEBRAIC(:,99), 1.0 ./ 2)./(1.00000+power(ALGEBRAIC(:,99), 1.0 ./ 2)) -  0.300000.*ALGEBRAIC(:,99)));
    ALGEBRAIC(:,108) = ( 1.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,105).*STATES(:,4).*exp( 1.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,141).*CONSTANTS(:,2)))./(exp( 1.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,111) =  (1.00000 - CONSTANTS(:,55)).*( (1.00000 - ALGEBRAIC(:,91)).*CONSTANTS(:,133).*ALGEBRAIC(:,108).*STATES(:,25).*( ALGEBRAIC(:,78).*(1.00000 - STATES(:,34))+ STATES(:,30).*ALGEBRAIC(:,81).*STATES(:,34))+ ALGEBRAIC(:,91).*CONSTANTS(:,138).*ALGEBRAIC(:,108).*STATES(:,25).*( ALGEBRAIC(:,82).*(1.00000 - STATES(:,34))+ STATES(:,30).*ALGEBRAIC(:,83).*STATES(:,34)));
    ALGEBRAIC(:,209) = (STATES(:,5) - STATES(:,4))./CONSTANTS(:,106);
    ALGEBRAIC(:,181) = 1.00000./(1.00000+power(CONSTANTS(:,73)./STATES(:,3), 2.00000));
    ALGEBRAIC(:,161) = 1.00000+ (CONSTANTS(:,2)./CONSTANTS(:,64)).*(1.00000+1.00000./ALGEBRAIC(:,124));
    ALGEBRAIC(:,162) = CONSTANTS(:,2)./( CONSTANTS(:,64).*ALGEBRAIC(:,124).*ALGEBRAIC(:,161));
    ALGEBRAIC(:,165) =  ALGEBRAIC(:,162).*CONSTANTS(:,68);
    ALGEBRAIC(:,155) = 1.00000+ (STATES(:,5)./CONSTANTS(:,64)).*(1.00000+ALGEBRAIC(:,124));
    ALGEBRAIC(:,156) = ( STATES(:,5).*ALGEBRAIC(:,124))./( CONSTANTS(:,64).*ALGEBRAIC(:,155));
    ALGEBRAIC(:,168) =  ALGEBRAIC(:,156).*CONSTANTS(:,68);
    ALGEBRAIC(:,158) = 1.00000+ (STATES(:,5)./CONSTANTS(:,62)).*(1.00000+STATES(:,5)./CONSTANTS(:,63));
    ALGEBRAIC(:,159) = ( STATES(:,5).*STATES(:,5))./( ALGEBRAIC(:,158).*CONSTANTS(:,62).*CONSTANTS(:,63));
    ALGEBRAIC(:,171) =  ALGEBRAIC(:,159).*ALGEBRAIC(:,156).*CONSTANTS(:,66);
    ALGEBRAIC(:,172) =  ALGEBRAIC(:,162).*CONSTANTS(:,155).*CONSTANTS(:,66);
    ALGEBRAIC(:,163) = 1.00000./ALGEBRAIC(:,161);
    ALGEBRAIC(:,164) =  ALGEBRAIC(:,163).*CONSTANTS(:,67);
    ALGEBRAIC(:,166) = ALGEBRAIC(:,164)+ALGEBRAIC(:,165);
    ALGEBRAIC(:,157) = 1.00000./ALGEBRAIC(:,155);
    ALGEBRAIC(:,167) = ( ALGEBRAIC(:,157).*CONSTANTS(:,67))./ALGEBRAIC(:,123);
    ALGEBRAIC(:,169) = ALGEBRAIC(:,167)+ALGEBRAIC(:,168);
    ALGEBRAIC(:,160) = 1.00000./ALGEBRAIC(:,158);
    ALGEBRAIC(:,170) =  ALGEBRAIC(:,160).*STATES(:,3).*CONSTANTS(:,69);
    ALGEBRAIC(:,173) =  CONSTANTS(:,158).*ALGEBRAIC(:,169).*(ALGEBRAIC(:,171)+ALGEBRAIC(:,170))+ CONSTANTS(:,159).*ALGEBRAIC(:,171).*(CONSTANTS(:,158)+ALGEBRAIC(:,166));
    ALGEBRAIC(:,174) =  CONSTANTS(:,157).*ALGEBRAIC(:,171).*(ALGEBRAIC(:,169)+CONSTANTS(:,159))+ ALGEBRAIC(:,169).*ALGEBRAIC(:,170).*(CONSTANTS(:,157)+ALGEBRAIC(:,172));
    ALGEBRAIC(:,175) =  CONSTANTS(:,157).*ALGEBRAIC(:,166).*(ALGEBRAIC(:,171)+ALGEBRAIC(:,170))+ ALGEBRAIC(:,172).*ALGEBRAIC(:,170).*(CONSTANTS(:,158)+ALGEBRAIC(:,166));
    ALGEBRAIC(:,176) =  CONSTANTS(:,158).*ALGEBRAIC(:,172).*(ALGEBRAIC(:,169)+CONSTANTS(:,159))+ ALGEBRAIC(:,166).*CONSTANTS(:,159).*(CONSTANTS(:,157)+ALGEBRAIC(:,172));
    ALGEBRAIC(:,177) = ALGEBRAIC(:,173)./(ALGEBRAIC(:,173)+ALGEBRAIC(:,174)+ALGEBRAIC(:,175)+ALGEBRAIC(:,176));
    ALGEBRAIC(:,178) = ALGEBRAIC(:,174)./(ALGEBRAIC(:,173)+ALGEBRAIC(:,174)+ALGEBRAIC(:,175)+ALGEBRAIC(:,176));
    ALGEBRAIC(:,179) = ALGEBRAIC(:,175)./(ALGEBRAIC(:,173)+ALGEBRAIC(:,174)+ALGEBRAIC(:,175)+ALGEBRAIC(:,176));
    ALGEBRAIC(:,180) = ALGEBRAIC(:,176)./(ALGEBRAIC(:,173)+ALGEBRAIC(:,174)+ALGEBRAIC(:,175)+ALGEBRAIC(:,176));
    ALGEBRAIC(:,182) = ( 3.00000.*( ALGEBRAIC(:,180).*ALGEBRAIC(:,171) -  ALGEBRAIC(:,177).*ALGEBRAIC(:,172))+ ALGEBRAIC(:,179).*ALGEBRAIC(:,168)) -  ALGEBRAIC(:,178).*ALGEBRAIC(:,165);
    ALGEBRAIC(:,183) =  ALGEBRAIC(:,178).*CONSTANTS(:,158) -  ALGEBRAIC(:,177).*CONSTANTS(:,157);
    ALGEBRAIC(:,184) =  CONSTANTS(:,61).*CONSTANTS(:,153).*ALGEBRAIC(:,181).*( CONSTANTS(:,9).*ALGEBRAIC(:,182)+ CONSTANTS(:,10).*ALGEBRAIC(:,183));
    ALGEBRAIC(:,86) = exp(  - CONSTANTS(:,135).*1.00000.*(power(ALGEBRAIC(:,84), 1.0 ./ 2)./(1.00000+power(ALGEBRAIC(:,84), 1.0 ./ 2)) -  0.300000.*ALGEBRAIC(:,84)));
    ALGEBRAIC(:,89) = ( 1.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,86).*STATES(:,5).*exp( 1.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,141).*CONSTANTS(:,2)))./(exp( 1.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,93) =  CONSTANTS(:,55).*( (1.00000 - ALGEBRAIC(:,91)).*CONSTANTS(:,133).*ALGEBRAIC(:,89).*STATES(:,25).*( ALGEBRAIC(:,78).*(1.00000 - STATES(:,33))+ STATES(:,30).*ALGEBRAIC(:,81).*STATES(:,33))+ ALGEBRAIC(:,91).*CONSTANTS(:,138).*ALGEBRAIC(:,89).*STATES(:,25).*( ALGEBRAIC(:,82).*(1.00000 - STATES(:,33))+ STATES(:,30).*ALGEBRAIC(:,83).*STATES(:,33)));
    ALGEBRAIC(:,212) = (STATES(:,3) - STATES(:,10))./CONSTANTS(:,108);
    ALGEBRAIC(:,214) = 1.00000./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,50));
    ALGEBRAIC(:,216) =  CONSTANTS(:,111).*( (1.00000 - ALGEBRAIC(:,214)).*STATES(:,42)+ ALGEBRAIC(:,214).*STATES(:,43));
    ALGEBRAIC(:,57) = 1.00000./(1.00000+( CONSTANTS(:,29).*CONSTANTS(:,30))./power(CONSTANTS(:,30)+STATES(:,3), 2.00000)+( CONSTANTS(:,31).*CONSTANTS(:,32))./power(CONSTANTS(:,32)+STATES(:,3), 2.00000));
    ALGEBRAIC(:,102) = exp(  - CONSTANTS(:,135).*4.00000.*(power(ALGEBRAIC(:,99), 1.0 ./ 2)./(1.00000+power(ALGEBRAIC(:,99), 1.0 ./ 2)) -  0.300000.*ALGEBRAIC(:,99)));
    ALGEBRAIC(:,107) = ( 4.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,102).*STATES(:,10).*exp( 2.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,140).*CONSTANTS(:,3)))./(exp( 2.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,110) =  (1.00000 - CONSTANTS(:,55)).*( (1.00000 - ALGEBRAIC(:,91)).*CONSTANTS(:,122).*ALGEBRAIC(:,107).*STATES(:,25).*( ALGEBRAIC(:,78).*(1.00000 - STATES(:,34))+ STATES(:,30).*ALGEBRAIC(:,81).*STATES(:,34))+ ALGEBRAIC(:,91).*CONSTANTS(:,132).*ALGEBRAIC(:,107).*STATES(:,25).*( ALGEBRAIC(:,82).*(1.00000 - STATES(:,34))+ STATES(:,30).*ALGEBRAIC(:,83).*STATES(:,34)));
    ALGEBRAIC(:,113) = ALGEBRAIC(:,92)+ALGEBRAIC(:,110);
    ALGEBRAIC(:,114) = ALGEBRAIC(:,93)+ALGEBRAIC(:,111);
    ALGEBRAIC(:,115) = ALGEBRAIC(:,96)+ALGEBRAIC(:,112);
    ALGEBRAIC(:,210) = ( CONSTANTS(:,100).*STATES(:,10))./(CONSTANTS(:,101)+STATES(:,10));
    ALGEBRAIC(:,208) = ( CONSTANTS(:,99).*4.00000.*ALGEBRAIC(:,26).*( ALGEBRAIC(:,102).*STATES(:,10).*exp( 2.00000.*ALGEBRAIC(:,29)) -  CONSTANTS(:,140).*CONSTANTS(:,3)))./(exp( 2.00000.*ALGEBRAIC(:,29)) - 1.00000);
    ALGEBRAIC(:,211) =  (( CONSTANTS(:,105).*CONSTANTS(:,102))./(1.00000+CONSTANTS(:,104)./STATES(:,3))).*(STATES(:,1) - CONSTANTS(:,115));
    ALGEBRAIC(:,213) =  (( (1.00000 - CONSTANTS(:,105)).*CONSTANTS(:,102))./(1.00000+CONSTANTS(:,104)./STATES(:,10))).*(STATES(:,1) - CONSTANTS(:,115));
    ALGEBRAIC(:,215) = ALGEBRAIC(:,211)+ALGEBRAIC(:,213);
    ALGEBRAIC(:,217) =  CONSTANTS(:,103).*(STATES(:,1) - CONSTANTS(:,115));
    ALGEBRAIC(:,218) = ( CONSTANTS(:,130).*0.00542500.*STATES(:,10))./(STATES(:,10)+0.000920000);
    ALGEBRAIC(:,219) = ( CONSTANTS(:,130).*2.75000.*0.00542500.*STATES(:,10))./((STATES(:,10)+0.000920000) - 0.000170000);
    ALGEBRAIC(:,220) = 1.00000./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,50));
    ALGEBRAIC(:,221) = ( 0.00488250.*STATES(:,8))./15.0000;
    ALGEBRAIC(:,222) =  CONSTANTS(:,112).*(( (1.00000 - ALGEBRAIC(:,220)).*ALGEBRAIC(:,218)+ ALGEBRAIC(:,220).*ALGEBRAIC(:,219)) - ALGEBRAIC(:,221));
    ALGEBRAIC(:,54) = 1.00000./(1.00000+( CONSTANTS(:,114).*CONSTANTS(:,26))./power(CONSTANTS(:,26)+STATES(:,10), 2.00000)+( CONSTANTS(:,27).*CONSTANTS(:,28))./power(CONSTANTS(:,28)+STATES(:,10), 2.00000));
    ALGEBRAIC(:,223) = (STATES(:,8) - STATES(:,9))./60.0000;
    ALGEBRAIC(:,60) = 1.00000./(1.00000+( CONSTANTS(:,33).*CONSTANTS(:,34))./power(CONSTANTS(:,34)+STATES(:,9), 2.00000));
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