# Generated Code

The following is matlab code generated by the CellML API from this CellML file. (Back to language selection)

The raw code is available.

```function [VOI, STATES, ALGEBRAIC, CONSTANTS] = mainFunction()
% This is the "main function".  In Matlab, things work best if you rename this function to match the filename.
[VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel();
end

function [algebraicVariableCount] = getAlgebraicVariableCount()
% Used later when setting a global variable with the number of algebraic variables.
% Note: This is not the "main method".
algebraicVariableCount =115;
end
% There are a total of 39 entries in each of the rate and state variable arrays.
% There are a total of 125 entries in the constant variable array.
%

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

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

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

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

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

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

function [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends()
LEGEND_STATES = ''; LEGEND_ALGEBRAIC = ''; LEGEND_VOI = ''; LEGEND_CONSTANTS = '';
LEGEND_ALGEBRAIC(:,23) = strpad('I_app in component Protocol (uA_per_uF)');
LEGEND_VOI = strpad('time in component environment (msec)');
LEGEND_ALGEBRAIC(:,10) = strpad('V_clamp in component Protocol (mV)');
LEGEND_STATES(:,1) = strpad('V_m in component membrane_potential (mV)');
LEGEND_CONSTANTS(:,1) = strpad('R_clamp in component Protocol (uF_per_mS)');
LEGEND_CONSTANTS(:,2) = strpad('epi in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,3) = strpad('R in component parameters (joule_per_kelvin_per_kilomole)');
LEGEND_CONSTANTS(:,97) = strpad('Frdy in component parameters (coulomb_per_mole)');
LEGEND_CONSTANTS(:,107) = strpad('Temp in component parameters (kelvin)');
LEGEND_CONSTANTS(:,111) = strpad('FoRT in component parameters (per_mV)');
LEGEND_CONSTANTS(:,112) = strpad('Qpow in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,5) = strpad('cellLength in component parameters (um)');
LEGEND_CONSTANTS(:,6) = strpad('junctionLength in component parameters (um)');
LEGEND_CONSTANTS(:,7) = strpad('distSLcyto in component parameters (um)');
LEGEND_CONSTANTS(:,8) = strpad('distJuncSL in component parameters (um)');
LEGEND_CONSTANTS(:,9) = strpad('DcaJuncSL in component parameters (cm2_per_sec)');
LEGEND_CONSTANTS(:,10) = strpad('DcaSLcyto in component parameters (cm2_per_sec)');
LEGEND_CONSTANTS(:,11) = strpad('DnaJuncSL in component parameters (cm2_per_sec)');
LEGEND_CONSTANTS(:,12) = strpad('DnaSLcyto in component parameters (cm2_per_sec)');
LEGEND_CONSTANTS(:,108) = strpad('Vcell in component parameters (liter)');
LEGEND_CONSTANTS(:,113) = strpad('Vmyo in component parameters (liter)');
LEGEND_CONSTANTS(:,114) = strpad('Vsr in component parameters (liter)');
LEGEND_CONSTANTS(:,115) = strpad('Vsl in component parameters (liter)');
LEGEND_CONSTANTS(:,116) = strpad('Vjunc in component parameters (liter)');
LEGEND_CONSTANTS(:,109) = strpad('SAjunc in component parameters (um2)');
LEGEND_CONSTANTS(:,110) = strpad('SAsl in component parameters (um2)');
LEGEND_CONSTANTS(:,13) = strpad('J_ca_juncsl in component parameters (liters_per_msec)');
LEGEND_CONSTANTS(:,14) = strpad('J_ca_slmyo in component parameters (liters_per_msec)');
LEGEND_CONSTANTS(:,15) = strpad('J_na_juncsl in component parameters (liters_per_msec)');
LEGEND_CONSTANTS(:,16) = strpad('J_na_slmyo in component parameters (liters_per_msec)');
LEGEND_CONSTANTS(:,17) = strpad('Fjunc in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,100) = strpad('Fsl in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,18) = strpad('Fjunc_CaL in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,101) = strpad('Fsl_CaL in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,117) = strpad('Cli in component parameters (mM)');
LEGEND_CONSTANTS(:,118) = strpad('Clo in component parameters (mM)');
LEGEND_CONSTANTS(:,19) = strpad('Ko in component parameters (mM)');
LEGEND_CONSTANTS(:,20) = strpad('Nao in component parameters (mM)');
LEGEND_CONSTANTS(:,21) = strpad('Cao in component parameters (mM)');
LEGEND_CONSTANTS(:,22) = strpad('Mgi in component parameters (mM)');
LEGEND_ALGEBRAIC(:,27) = strpad('ena_junc in component parameters (mV)');
LEGEND_ALGEBRAIC(:,31) = strpad('ena_sl in component parameters (mV)');
LEGEND_ALGEBRAIC(:,33) = strpad('ek in component parameters (mV)');
LEGEND_ALGEBRAIC(:,34) = strpad('eca_junc in component parameters (mV)');
LEGEND_ALGEBRAIC(:,35) = strpad('eca_sl in component parameters (mV)');
LEGEND_CONSTANTS(:,124) = strpad('ecl in component parameters (mV)');
LEGEND_CONSTANTS(:,23) = strpad('GNa in component parameters (mS_per_uF)');
LEGEND_CONSTANTS(:,24) = strpad('GNaB in component parameters (mS_per_uF)');
LEGEND_CONSTANTS(:,25) = strpad('IbarNaK in component parameters (uA_per_uF)');
LEGEND_CONSTANTS(:,26) = strpad('KmNaip in component parameters (mM)');
LEGEND_CONSTANTS(:,27) = strpad('KmKo in component parameters (mM)');
LEGEND_CONSTANTS(:,28) = strpad('Q10NaK in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,29) = strpad('Q10KmNai in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,30) = strpad('pNaK in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,31) = strpad('gkp in component parameters (mS_per_uF)');
LEGEND_CONSTANTS(:,32) = strpad('GClCa in component parameters (mS_per_uF)');
LEGEND_CONSTANTS(:,33) = strpad('GClB in component parameters (mS_per_uF)');
LEGEND_CONSTANTS(:,34) = strpad('KdClCa in component parameters (mM)');
LEGEND_CONSTANTS(:,35) = strpad('pNa in component parameters (cm_per_sec)');
LEGEND_CONSTANTS(:,36) = strpad('pCa in component parameters (cm_per_sec)');
LEGEND_CONSTANTS(:,37) = strpad('pK in component parameters (cm_per_sec)');
LEGEND_CONSTANTS(:,38) = strpad('Q10CaL in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,39) = strpad('IbarNCX in component parameters (uA_per_uF)');
LEGEND_CONSTANTS(:,40) = strpad('KmCai in component parameters (mM)');
LEGEND_CONSTANTS(:,41) = strpad('KmCao in component parameters (mM)');
LEGEND_CONSTANTS(:,42) = strpad('KmNai in component parameters (mM)');
LEGEND_CONSTANTS(:,43) = strpad('KmNao in component parameters (mM)');
LEGEND_CONSTANTS(:,44) = strpad('ksat in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,45) = strpad('nu in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,46) = strpad('Kdact in component parameters (mM)');
LEGEND_CONSTANTS(:,47) = strpad('Q10NCX in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,48) = strpad('IbarSLCaP in component parameters (uA_per_uF)');
LEGEND_CONSTANTS(:,49) = strpad('KmPCa in component parameters (mM)');
LEGEND_CONSTANTS(:,50) = strpad('GCaB in component parameters (mS_per_uF)');
LEGEND_CONSTANTS(:,51) = strpad('Q10SLCaP in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,52) = strpad('Q10SRCaP in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,53) = strpad('Vmax_SRCaP in component parameters (mM_per_msec)');
LEGEND_CONSTANTS(:,54) = strpad('Kmf in component parameters (mM)');
LEGEND_CONSTANTS(:,55) = strpad('Kmr in component parameters (mM)');
LEGEND_CONSTANTS(:,56) = strpad('hillSRCaP in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,57) = strpad('ks in component parameters (per_msec)');
LEGEND_CONSTANTS(:,58) = strpad('koCa in component parameters (per_mM2_per_msec)');
LEGEND_CONSTANTS(:,59) = strpad('kom in component parameters (per_msec)');
LEGEND_CONSTANTS(:,106) = strpad('kiCa in component parameters (per_mM_per_msec)');
LEGEND_CONSTANTS(:,60) = strpad('kim in component parameters (per_msec)');
LEGEND_CONSTANTS(:,61) = strpad('ec50SR in component parameters (mM)');
LEGEND_CONSTANTS(:,62) = strpad('Bmax_Naj in component parameters (mM)');
LEGEND_CONSTANTS(:,63) = strpad('Bmax_Nasl in component parameters (mM)');
LEGEND_CONSTANTS(:,64) = strpad('koff_na in component parameters (per_msec)');
LEGEND_CONSTANTS(:,65) = strpad('kon_na in component parameters (per_mM_per_msec)');
LEGEND_CONSTANTS(:,66) = strpad('Bmax_TnClow in component parameters (mM)');
LEGEND_CONSTANTS(:,67) = strpad('koff_tncl in component parameters (per_msec)');
LEGEND_CONSTANTS(:,68) = strpad('kon_tncl in component parameters (per_mM_per_msec)');
LEGEND_CONSTANTS(:,69) = strpad('Bmax_TnChigh in component parameters (mM)');
LEGEND_CONSTANTS(:,70) = strpad('koff_tnchca in component parameters (per_msec)');
LEGEND_CONSTANTS(:,71) = strpad('kon_tnchca in component parameters (per_mM_per_msec)');
LEGEND_CONSTANTS(:,72) = strpad('koff_tnchmg in component parameters (per_msec)');
LEGEND_CONSTANTS(:,73) = strpad('kon_tnchmg in component parameters (per_mM_per_msec)');
LEGEND_CONSTANTS(:,74) = strpad('Bmax_CaM in component parameters (mM)');
LEGEND_CONSTANTS(:,75) = strpad('koff_cam in component parameters (per_msec)');
LEGEND_CONSTANTS(:,76) = strpad('kon_cam in component parameters (per_mM_per_msec)');
LEGEND_CONSTANTS(:,77) = strpad('Bmax_myosin in component parameters (mM)');
LEGEND_CONSTANTS(:,78) = strpad('koff_myoca in component parameters (per_msec)');
LEGEND_CONSTANTS(:,79) = strpad('kon_myoca in component parameters (per_mM_per_msec)');
LEGEND_CONSTANTS(:,80) = strpad('koff_myomg in component parameters (per_msec)');
LEGEND_CONSTANTS(:,81) = strpad('kon_myomg in component parameters (per_mM_per_msec)');
LEGEND_CONSTANTS(:,82) = strpad('Bmax_SR in component parameters (mM)');
LEGEND_CONSTANTS(:,83) = strpad('koff_sr in component parameters (per_msec)');
LEGEND_CONSTANTS(:,84) = strpad('kon_sr in component parameters (per_mM_per_msec)');
LEGEND_CONSTANTS(:,119) = strpad('Bmax_SLlowsl in component parameters (mM)');
LEGEND_CONSTANTS(:,120) = strpad('Bmax_SLlowj in component parameters (mM)');
LEGEND_CONSTANTS(:,85) = strpad('koff_sll in component parameters (per_msec)');
LEGEND_CONSTANTS(:,86) = strpad('kon_sll in component parameters (per_mM_per_msec)');
LEGEND_CONSTANTS(:,121) = strpad('Bmax_SLhighsl in component parameters (mM)');
LEGEND_CONSTANTS(:,122) = strpad('Bmax_SLhighj in component parameters (mM)');
LEGEND_CONSTANTS(:,87) = strpad('koff_slh in component parameters (per_msec)');
LEGEND_CONSTANTS(:,88) = strpad('kon_slh in component parameters (per_mM_per_msec)');
LEGEND_CONSTANTS(:,123) = strpad('Bmax_Csqn in component parameters (mM)');
LEGEND_CONSTANTS(:,89) = strpad('koff_csqn in component parameters (per_msec)');
LEGEND_CONSTANTS(:,90) = strpad('kon_csqn in component parameters (per_mM_per_msec)');
LEGEND_STATES(:,2) = strpad('Na_j in component Na_Concentrations (mM)');
LEGEND_STATES(:,3) = strpad('Na_sl in component Na_Concentrations (mM)');
LEGEND_STATES(:,4) = strpad('K_i in component K_Concentration (mM)');
LEGEND_STATES(:,5) = strpad('Ca_j in component Ca_Concentrations (mM)');
LEGEND_STATES(:,6) = strpad('Ca_sl in component Ca_Concentrations (mM)');
LEGEND_ALGEBRAIC(:,1) = strpad('mss in component I_Na (dimensionless)');
LEGEND_ALGEBRAIC(:,12) = strpad('taum in component I_Na (msec)');
LEGEND_ALGEBRAIC(:,2) = strpad('ah in component I_Na (dimensionless)');
LEGEND_ALGEBRAIC(:,13) = strpad('bh in component I_Na (dimensionless)');
LEGEND_ALGEBRAIC(:,25) = strpad('tauh in component I_Na (msec)');
LEGEND_ALGEBRAIC(:,29) = strpad('hss in component I_Na (dimensionless)');
LEGEND_ALGEBRAIC(:,3) = strpad('aj in component I_Na (dimensionless)');
LEGEND_ALGEBRAIC(:,14) = strpad('bj in component I_Na (dimensionless)');
LEGEND_ALGEBRAIC(:,26) = strpad('tauj in component I_Na (msec)');
LEGEND_ALGEBRAIC(:,30) = strpad('jss in component I_Na (dimensionless)');
LEGEND_STATES(:,7) = strpad('m in component I_Na (dimensionless)');
LEGEND_STATES(:,8) = strpad('h in component I_Na (dimensionless)');
LEGEND_STATES(:,9) = strpad('j in component I_Na (dimensionless)');
LEGEND_ALGEBRAIC(:,36) = strpad('I_Na_junc in component I_Na (uA_per_uF)');
LEGEND_ALGEBRAIC(:,37) = strpad('I_Na_sl in component I_Na (uA_per_uF)');
LEGEND_ALGEBRAIC(:,38) = strpad('I_Na in component I_Na (uA_per_uF)');
LEGEND_ALGEBRAIC(:,39) = strpad('I_nabk_junc in component I_NaBK (uA_per_uF)');
LEGEND_ALGEBRAIC(:,40) = strpad('I_nabk_sl in component I_NaBK (uA_per_uF)');
LEGEND_ALGEBRAIC(:,41) = strpad('I_nabk in component I_NaBK (uA_per_uF)');
LEGEND_CONSTANTS(:,102) = strpad('sigma in component I_NaK (dimensionless)');
LEGEND_ALGEBRAIC(:,42) = strpad('fnak in component I_NaK (dimensionless)');
LEGEND_ALGEBRAIC(:,43) = strpad('I_nak_junc in component I_NaK (uA_per_uF)');
LEGEND_ALGEBRAIC(:,44) = strpad('I_nak_sl in component I_NaK (uA_per_uF)');
LEGEND_ALGEBRAIC(:,45) = strpad('I_nak in component I_NaK (uA_per_uF)');
LEGEND_CONSTANTS(:,103) = strpad('gkr in component I_Kr (mS_per_uF)');
LEGEND_ALGEBRAIC(:,15) = strpad('tauxr in component I_Kr (msec)');
LEGEND_STATES(:,10) = strpad('x_kr in component I_Kr (dimensionless)');
LEGEND_ALGEBRAIC(:,46) = strpad('rkr in component I_Kr (dimensionless)');
LEGEND_ALGEBRAIC(:,47) = strpad('I_kr in component I_Kr (uA_per_uF)');
LEGEND_ALGEBRAIC(:,48) = strpad('kp_kp in component I_Kp (dimensionless)');
LEGEND_ALGEBRAIC(:,49) = strpad('I_kp_junc in component I_Kp (uA_per_uF)');
LEGEND_ALGEBRAIC(:,50) = strpad('I_kp_sl in component I_Kp (uA_per_uF)');
LEGEND_ALGEBRAIC(:,51) = strpad('I_kp in component I_Kp (uA_per_uF)');
LEGEND_ALGEBRAIC(:,52) = strpad('eks in component I_Ks (mV)');
LEGEND_CONSTANTS(:,91) = strpad('gks_junc in component I_Ks (mS_per_uF)');
LEGEND_CONSTANTS(:,92) = strpad('gks_sl in component I_Ks (mS_per_uF)');
LEGEND_ALGEBRAIC(:,5) = strpad('xsss in component I_Ks (dimensionless)');
LEGEND_ALGEBRAIC(:,16) = strpad('tauxs in component I_Ks (msec)');
LEGEND_STATES(:,11) = strpad('x_ks in component I_Ks (dimensionless)');
LEGEND_ALGEBRAIC(:,53) = strpad('I_ks_junc in component I_Ks (uA_per_uF)');
LEGEND_ALGEBRAIC(:,54) = strpad('I_ks_sl in component I_Ks (uA_per_uF)');
LEGEND_ALGEBRAIC(:,55) = strpad('I_ks in component I_Ks (uA_per_uF)');
LEGEND_STATES(:,12) = strpad('Na_i in component Na_Concentrations (mM)');
LEGEND_CONSTANTS(:,104) = strpad('GtoSlow in component I_to (mS_per_uF)');
LEGEND_CONSTANTS(:,105) = strpad('GtoFast in component I_to (mS_per_uF)');
LEGEND_ALGEBRAIC(:,6) = strpad('xtoss in component I_to (dimensionless)');
LEGEND_ALGEBRAIC(:,7) = strpad('ytoss in component I_to (dimensionless)');
LEGEND_ALGEBRAIC(:,17) = strpad('tauxtos in component I_to (msec)');
LEGEND_ALGEBRAIC(:,18) = strpad('tauytos in component I_to (msec)');
LEGEND_STATES(:,13) = strpad('x_to_s in component I_to (dimensionless)');
LEGEND_STATES(:,14) = strpad('y_to_s in component I_to (dimensionless)');
LEGEND_ALGEBRAIC(:,56) = strpad('I_tos in component I_to (uA_per_uF)');
LEGEND_ALGEBRAIC(:,19) = strpad('tauxtof in component I_to (msec)');
LEGEND_ALGEBRAIC(:,20) = strpad('tauytof in component I_to (msec)');
LEGEND_STATES(:,15) = strpad('x_to_f in component I_to (dimensionless)');
LEGEND_STATES(:,16) = strpad('y_to_f in component I_to (dimensionless)');
LEGEND_ALGEBRAIC(:,57) = strpad('I_tof in component I_to (uA_per_uF)');
LEGEND_ALGEBRAIC(:,58) = strpad('I_to in component I_to (uA_per_uF)');
LEGEND_ALGEBRAIC(:,59) = strpad('aki in component I_Ki (dimensionless)');
LEGEND_ALGEBRAIC(:,60) = strpad('bki in component I_Ki (dimensionless)');
LEGEND_ALGEBRAIC(:,61) = strpad('kiss in component I_Ki (dimensionless)');
LEGEND_ALGEBRAIC(:,62) = strpad('I_ki in component I_Ki (uA_per_uF)');
LEGEND_ALGEBRAIC(:,63) = strpad('I_ClCa_junc in component I_ClCa (uA_per_uF)');
LEGEND_ALGEBRAIC(:,64) = strpad('I_ClCa_sl in component I_ClCa (uA_per_uF)');
LEGEND_ALGEBRAIC(:,65) = strpad('I_ClCa in component I_ClCa (uA_per_uF)');
LEGEND_ALGEBRAIC(:,66) = strpad('I_Clbk in component I_ClCa (uA_per_uF)');
LEGEND_ALGEBRAIC(:,8) = strpad('fss in component I_Ca (dimensionless)');
LEGEND_ALGEBRAIC(:,9) = strpad('dss in component I_Ca (dimensionless)');
LEGEND_ALGEBRAIC(:,21) = strpad('taud in component I_Ca (msec)');
LEGEND_ALGEBRAIC(:,22) = strpad('tauf in component I_Ca (msec)');
LEGEND_STATES(:,17) = strpad('d in component I_Ca (dimensionless)');
LEGEND_STATES(:,18) = strpad('f in component I_Ca (dimensionless)');
LEGEND_STATES(:,19) = strpad('f_Ca_Bj in component I_Ca (dimensionless)');
LEGEND_STATES(:,20) = strpad('f_Ca_Bsl in component I_Ca (dimensionless)');
LEGEND_CONSTANTS(:,93) = strpad('fcaCaMSL in component I_Ca (dimensionless)');
LEGEND_CONSTANTS(:,94) = strpad('fcaCaj in component I_Ca (dimensionless)');
LEGEND_ALGEBRAIC(:,67) = strpad('ibarca_j in component I_Ca (uA_per_uF)');
LEGEND_ALGEBRAIC(:,68) = strpad('ibarca_sl in component I_Ca (uA_per_uF)');
LEGEND_ALGEBRAIC(:,69) = strpad('ibark in component I_Ca (uA_per_uF)');
LEGEND_ALGEBRAIC(:,70) = strpad('ibarna_j in component I_Ca (uA_per_uF)');
LEGEND_ALGEBRAIC(:,71) = strpad('ibarna_sl in component I_Ca (uA_per_uF)');
LEGEND_ALGEBRAIC(:,72) = strpad('I_Ca_junc in component I_Ca (uA_per_uF)');
LEGEND_ALGEBRAIC(:,73) = strpad('I_Ca_sl in component I_Ca (uA_per_uF)');
LEGEND_ALGEBRAIC(:,74) = strpad('I_Ca in component I_Ca (uA_per_uF)');
LEGEND_ALGEBRAIC(:,75) = strpad('I_CaK in component I_Ca (uA_per_uF)');
LEGEND_ALGEBRAIC(:,76) = strpad('I_CaNa_junc in component I_Ca (uA_per_uF)');
LEGEND_ALGEBRAIC(:,77) = strpad('I_CaNa_sl in component I_Ca (uA_per_uF)');
LEGEND_ALGEBRAIC(:,78) = strpad('I_CaNa in component I_Ca (uA_per_uF)');
LEGEND_ALGEBRAIC(:,80) = strpad('I_Catot in component I_Ca (uA_per_uF)');
LEGEND_ALGEBRAIC(:,79) = strpad('Ka_junc in component I_NCX (dimensionless)');
LEGEND_ALGEBRAIC(:,81) = strpad('Ka_sl in component I_NCX (dimensionless)');
LEGEND_ALGEBRAIC(:,82) = strpad('s1_junc in component I_NCX (mM4)');
LEGEND_ALGEBRAIC(:,83) = strpad('s1_sl in component I_NCX (mM4)');
LEGEND_ALGEBRAIC(:,84) = strpad('s2_junc in component I_NCX (mM4)');
LEGEND_ALGEBRAIC(:,85) = strpad('s3_junc in component I_NCX (mM4)');
LEGEND_ALGEBRAIC(:,86) = strpad('s2_sl in component I_NCX (mM4)');
LEGEND_ALGEBRAIC(:,87) = strpad('s3_sl in component I_NCX (mM4)');
LEGEND_ALGEBRAIC(:,88) = strpad('I_ncx_junc in component I_NCX (uA_per_uF)');
LEGEND_ALGEBRAIC(:,89) = strpad('I_ncx_sl in component I_NCX (uA_per_uF)');
LEGEND_ALGEBRAIC(:,91) = strpad('I_ncx in component I_NCX (uA_per_uF)');
LEGEND_ALGEBRAIC(:,92) = strpad('I_pca_junc in component I_PCa (uA_per_uF)');
LEGEND_ALGEBRAIC(:,94) = strpad('I_pca_sl in component I_PCa (uA_per_uF)');
LEGEND_ALGEBRAIC(:,95) = strpad('I_pca in component I_PCa (uA_per_uF)');
LEGEND_ALGEBRAIC(:,96) = strpad('I_cabk_junc in component I_CaBK (uA_per_uF)');
LEGEND_ALGEBRAIC(:,97) = strpad('I_cabk_sl in component I_CaBK (uA_per_uF)');
LEGEND_ALGEBRAIC(:,98) = strpad('I_cabk in component I_CaBK (uA_per_uF)');
LEGEND_CONSTANTS(:,95) = strpad('MaxSR in component SR_Fluxes (dimensionless)');
LEGEND_CONSTANTS(:,96) = strpad('MinSR in component SR_Fluxes (dimensionless)');
LEGEND_ALGEBRAIC(:,11) = strpad('kCaSR in component SR_Fluxes (dimensionless)');
LEGEND_ALGEBRAIC(:,24) = strpad('koSRCa in component SR_Fluxes (per_mM2_per_msec)');
LEGEND_ALGEBRAIC(:,28) = strpad('kiSRCa in component SR_Fluxes (per_mM_per_msec)');
LEGEND_ALGEBRAIC(:,32) = strpad('RI in component SR_Fluxes (mM)');
LEGEND_STATES(:,21) = strpad('Ry_Rr in component SR_Fluxes (mM)');
LEGEND_STATES(:,22) = strpad('Ry_Ro in component SR_Fluxes (mM)');
LEGEND_STATES(:,23) = strpad('Ry_Ri in component SR_Fluxes (mM)');
LEGEND_ALGEBRAIC(:,99) = strpad('J_SRCarel in component SR_Fluxes (mM_per_msec)');
LEGEND_ALGEBRAIC(:,100) = strpad('J_serca in component SR_Fluxes (mM_per_msec)');
LEGEND_ALGEBRAIC(:,101) = strpad('J_SRleak in component SR_Fluxes (mM_per_msec)');
LEGEND_STATES(:,24) = strpad('Ca_sr in component SR_Ca_Concentrations (mM)');
LEGEND_STATES(:,25) = strpad('Ca_i in component Ca_Concentrations (mM)');
LEGEND_STATES(:,26) = strpad('Na_Bj in component Na_Buffers (mM)');
LEGEND_STATES(:,27) = strpad('Na_Bsl in component Na_Buffers (mM)');
LEGEND_ALGEBRAIC(:,103) = strpad('dNa_Bj_dt in component Na_Buffers (mM_per_msec)');
LEGEND_ALGEBRAIC(:,104) = strpad('dNa_Bsl_dt in component Na_Buffers (mM_per_msec)');
LEGEND_STATES(:,28) = strpad('Tn_CL in component Cytosolic_Ca_Buffers (mM)');
LEGEND_STATES(:,29) = strpad('Tn_CHc in component Cytosolic_Ca_Buffers (mM)');
LEGEND_STATES(:,30) = strpad('Tn_CHm in component Cytosolic_Ca_Buffers (mM)');
LEGEND_STATES(:,31) = strpad('CaM in component Cytosolic_Ca_Buffers (mM)');
LEGEND_STATES(:,32) = strpad('Myo_c in component Cytosolic_Ca_Buffers (mM)');
LEGEND_STATES(:,33) = strpad('Myo_m in component Cytosolic_Ca_Buffers (mM)');
LEGEND_STATES(:,34) = strpad('SRB in component Cytosolic_Ca_Buffers (mM)');
LEGEND_ALGEBRAIC(:,102) = strpad('J_CaB_cytosol in component Cytosolic_Ca_Buffers (mM_per_msec)');
LEGEND_STATES(:,35) = strpad('SLL_j in component Junctional_and_SL_Ca_Buffers (mM)');
LEGEND_STATES(:,36) = strpad('SLL_sl in component Junctional_and_SL_Ca_Buffers (mM)');
LEGEND_STATES(:,37) = strpad('SLH_j in component Junctional_and_SL_Ca_Buffers (mM)');
LEGEND_STATES(:,38) = strpad('SLH_sl in component Junctional_and_SL_Ca_Buffers (mM)');
LEGEND_ALGEBRAIC(:,105) = strpad('J_CaB_junction in component Junctional_and_SL_Ca_Buffers (mM_per_msec)');
LEGEND_ALGEBRAIC(:,106) = strpad('J_CaB_sl in component Junctional_and_SL_Ca_Buffers (mM_per_msec)');
LEGEND_STATES(:,39) = strpad('Csqn_b in component SR_Ca_Concentrations (mM)');
LEGEND_ALGEBRAIC(:,107) = strpad('I_Na_tot_junc in component Na_Concentrations (uA_per_uF)');
LEGEND_ALGEBRAIC(:,108) = strpad('I_Na_tot_sl in component Na_Concentrations (uA_per_uF)');
LEGEND_ALGEBRAIC(:,93) = strpad('I_Na_tot_sl2 in component Na_Concentrations (uA_per_uF)');
LEGEND_ALGEBRAIC(:,90) = strpad('I_Na_tot_junc2 in component Na_Concentrations (uA_per_uF)');
LEGEND_ALGEBRAIC(:,109) = strpad('I_K_tot in component K_Concentration (uA_per_uF)');
LEGEND_ALGEBRAIC(:,110) = strpad('I_Ca_tot_junc in component Ca_Concentrations (uA_per_uF)');
LEGEND_ALGEBRAIC(:,111) = strpad('I_Ca_tot_sl in component Ca_Concentrations (uA_per_uF)');
LEGEND_ALGEBRAIC(:,112) = strpad('I_Na_tot in component membrane_potential (uA_per_uF)');
LEGEND_ALGEBRAIC(:,113) = strpad('I_Cl_tot in component membrane_potential (uA_per_uF)');
LEGEND_ALGEBRAIC(:,114) = strpad('I_Ca_tot in component membrane_potential (uA_per_uF)');
LEGEND_ALGEBRAIC(:,115) = strpad('I_tot in component membrane_potential (uA_per_uF)');
LEGEND_RATES(:,7) = strpad('d/dt m in component I_Na (dimensionless)');
LEGEND_RATES(:,8) = strpad('d/dt h in component I_Na (dimensionless)');
LEGEND_RATES(:,9) = strpad('d/dt j in component I_Na (dimensionless)');
LEGEND_RATES(:,10) = strpad('d/dt x_kr in component I_Kr (dimensionless)');
LEGEND_RATES(:,11) = strpad('d/dt x_ks in component I_Ks (dimensionless)');
LEGEND_RATES(:,13) = strpad('d/dt x_to_s in component I_to (dimensionless)');
LEGEND_RATES(:,14) = strpad('d/dt y_to_s in component I_to (dimensionless)');
LEGEND_RATES(:,15) = strpad('d/dt x_to_f in component I_to (dimensionless)');
LEGEND_RATES(:,16) = strpad('d/dt y_to_f in component I_to (dimensionless)');
LEGEND_RATES(:,17) = strpad('d/dt d in component I_Ca (dimensionless)');
LEGEND_RATES(:,18) = strpad('d/dt f in component I_Ca (dimensionless)');
LEGEND_RATES(:,19) = strpad('d/dt f_Ca_Bj in component I_Ca (dimensionless)');
LEGEND_RATES(:,20) = strpad('d/dt f_Ca_Bsl in component I_Ca (dimensionless)');
LEGEND_RATES(:,21) = strpad('d/dt Ry_Rr in component SR_Fluxes (mM)');
LEGEND_RATES(:,22) = strpad('d/dt Ry_Ro in component SR_Fluxes (mM)');
LEGEND_RATES(:,23) = strpad('d/dt Ry_Ri in component SR_Fluxes (mM)');
LEGEND_RATES(:,26) = strpad('d/dt Na_Bj in component Na_Buffers (mM)');
LEGEND_RATES(:,27) = strpad('d/dt Na_Bsl in component Na_Buffers (mM)');
LEGEND_RATES(:,28) = strpad('d/dt Tn_CL in component Cytosolic_Ca_Buffers (mM)');
LEGEND_RATES(:,29) = strpad('d/dt Tn_CHc in component Cytosolic_Ca_Buffers (mM)');
LEGEND_RATES(:,30) = strpad('d/dt Tn_CHm in component Cytosolic_Ca_Buffers (mM)');
LEGEND_RATES(:,31) = strpad('d/dt CaM in component Cytosolic_Ca_Buffers (mM)');
LEGEND_RATES(:,32) = strpad('d/dt Myo_c in component Cytosolic_Ca_Buffers (mM)');
LEGEND_RATES(:,33) = strpad('d/dt Myo_m in component Cytosolic_Ca_Buffers (mM)');
LEGEND_RATES(:,34) = strpad('d/dt SRB in component Cytosolic_Ca_Buffers (mM)');
LEGEND_RATES(:,35) = strpad('d/dt SLL_j in component Junctional_and_SL_Ca_Buffers (mM)');
LEGEND_RATES(:,36) = strpad('d/dt SLL_sl in component Junctional_and_SL_Ca_Buffers (mM)');
LEGEND_RATES(:,37) = strpad('d/dt SLH_j in component Junctional_and_SL_Ca_Buffers (mM)');
LEGEND_RATES(:,38) = strpad('d/dt SLH_sl in component Junctional_and_SL_Ca_Buffers (mM)');
LEGEND_RATES(:,39) = strpad('d/dt Csqn_b in component SR_Ca_Concentrations (mM)');
LEGEND_RATES(:,24) = strpad('d/dt Ca_sr in component SR_Ca_Concentrations (mM)');
LEGEND_RATES(:,2) = strpad('d/dt Na_j in component Na_Concentrations (mM)');
LEGEND_RATES(:,3) = strpad('d/dt Na_sl in component Na_Concentrations (mM)');
LEGEND_RATES(:,12) = strpad('d/dt Na_i in component Na_Concentrations (mM)');
LEGEND_RATES(:,4) = strpad('d/dt K_i in component K_Concentration (mM)');
LEGEND_RATES(:,5) = strpad('d/dt Ca_j in component Ca_Concentrations (mM)');
LEGEND_RATES(:,6) = strpad('d/dt Ca_sl in component Ca_Concentrations (mM)');
LEGEND_RATES(:,25) = strpad('d/dt Ca_i in component Ca_Concentrations (mM)');
LEGEND_RATES(:,1) = strpad('d/dt V_m in component membrane_potential (mV)');
LEGEND_STATES  = LEGEND_STATES';
LEGEND_ALGEBRAIC = LEGEND_ALGEBRAIC';
LEGEND_RATES = LEGEND_RATES';
LEGEND_CONSTANTS = LEGEND_CONSTANTS';
end

function [STATES, CONSTANTS] = initConsts()
VOI = 0; CONSTANTS = []; STATES = []; ALGEBRAIC = [];
STATES(:,1) = -8.09763e1;
CONSTANTS(:,1) = 0.02;
STATES(:,2) = 9.06;
STATES(:,3) = 9.06;
STATES(:,4) = 120;
STATES(:,5) = 1.737475e-4;
STATES(:,6) = 1.031812e-4;
STATES(:,7) = 1.405627e-3;
STATES(:,8) = 9.867005e-1;
STATES(:,9) = 9.91562e-1;
STATES(:,10) = 8.641386e-3;
STATES(:,11) = 5.412034e-3;
STATES(:,12) = 9.06;
STATES(:,13) = 4.051574e-3;
STATES(:,14) = 9.945511e-1;
STATES(:,15) = 4.051574e-3;
STATES(:,16) = 9.945511e-1;
STATES(:,17) = 7.175662e-6;
STATES(:,18) = 1.000681;
STATES(:,19) = 2.421991e-2;
STATES(:,20) = 1.452605e-2;
STATES(:,21) = 8.884332e-1;
STATES(:,22) = 8.156628e-7;
STATES(:,23) = 1.024274e-7;
STATES(:,24) = 0.1e-1;
STATES(:,25) = 8.597401e-5;
STATES(:,26) = 3.539892;
STATES(:,27) = 7.720854e-1;
STATES(:,28) = 8.773191e-3;
STATES(:,29) = 1.078283e-1;
STATES(:,30) = 1.524002e-2;
STATES(:,31) = 2.911916e-4;
STATES(:,32) = 1.298754e-3;
STATES(:,33) = 1.381982e-1;
STATES(:,34) = 2.143165e-3;
STATES(:,35) = 9.566355e-3;
STATES(:,36) = 1.110363e-1;
STATES(:,37) = 7.347888e-3;
STATES(:,38) = 7.297378e-2;
STATES(:,39) = 1.242988;
CONSTANTS(:,2) = 1.00000;
CONSTANTS(:,3) = 8314.00;
CONSTANTS(:,4) = 1.38100e-10;
CONSTANTS(:,5) = 100.000;
CONSTANTS(:,6) = 0.160000;
CONSTANTS(:,7) = 0.450000;
CONSTANTS(:,8) = 0.500000;
CONSTANTS(:,9) = 1.64000e-06;
CONSTANTS(:,10) = 1.22000e-06;
CONSTANTS(:,11) = 1.09000e-05;
CONSTANTS(:,12) = 1.79000e-05;
CONSTANTS(:,13) = 8.24130e-13;
CONSTANTS(:,14) = 3.27430e-12;
CONSTANTS(:,15) = 1.83130e-14;
CONSTANTS(:,16) = 1.63860e-12;
CONSTANTS(:,17) = 0.110000;
CONSTANTS(:,18) = 0.900000;
CONSTANTS(:,19) = 5.40000;
CONSTANTS(:,20) = 140.000;
CONSTANTS(:,21) = 1.80000;
CONSTANTS(:,22) = 1.00000;
CONSTANTS(:,23) = 23.0000;
CONSTANTS(:,24) = 0.000597000;
CONSTANTS(:,25) =  1.00000.*1.80000;
CONSTANTS(:,26) = 11.0000;
CONSTANTS(:,27) = 1.50000;
CONSTANTS(:,28) = 1.63000;
CONSTANTS(:,29) = 1.39000;
CONSTANTS(:,30) = 0.0183300;
CONSTANTS(:,31) =  2.00000.*0.00100000;
CONSTANTS(:,32) =  0.500000.*0.109625;
CONSTANTS(:,33) =  1.00000.*0.00900000;
CONSTANTS(:,34) = 0.100000;
CONSTANTS(:,35) =  0.500000.*1.50000e-08;
CONSTANTS(:,36) =  0.500000.*0.000540000;
CONSTANTS(:,37) =  0.500000.*2.70000e-07;
CONSTANTS(:,38) = 1.80000;
CONSTANTS(:,39) =  1.00000.*4.50000;
CONSTANTS(:,40) = 0.00359000;
CONSTANTS(:,41) = 1.30000;
CONSTANTS(:,42) = 12.2900;
CONSTANTS(:,43) = 87.5000;
CONSTANTS(:,44) = 0.320000;
CONSTANTS(:,45) = 0.270000;
CONSTANTS(:,46) = 0.000150000;
CONSTANTS(:,47) = 1.57000;
CONSTANTS(:,48) = 0.0673000;
CONSTANTS(:,49) = 0.000500000;
CONSTANTS(:,50) = 0.000551300;
CONSTANTS(:,51) = 2.35000;
CONSTANTS(:,52) = 2.60000;
CONSTANTS(:,53) = 0.00531140;
CONSTANTS(:,54) = 0.000246000;
CONSTANTS(:,55) = 1.70000;
CONSTANTS(:,56) = 1.78700;
CONSTANTS(:,57) = 25.0000;
CONSTANTS(:,58) = 10.0000;
CONSTANTS(:,59) = 0.0600000;
CONSTANTS(:,60) = 0.00500000;
CONSTANTS(:,61) = 0.450000;
CONSTANTS(:,62) = 7.56100;
CONSTANTS(:,63) = 1.65000;
CONSTANTS(:,64) = 0.00100000;
CONSTANTS(:,65) = 0.000100000;
CONSTANTS(:,66) = 0.0700000;
CONSTANTS(:,67) = 0.0196000;
CONSTANTS(:,68) = 32.7000;
CONSTANTS(:,69) = 0.140000;
CONSTANTS(:,70) = 3.20000e-05;
CONSTANTS(:,71) = 2.37000;
CONSTANTS(:,72) = 0.00333000;
CONSTANTS(:,73) = 0.00300000;
CONSTANTS(:,74) = 0.0240000;
CONSTANTS(:,75) = 0.238000;
CONSTANTS(:,76) = 34.0000;
CONSTANTS(:,77) = 0.140000;
CONSTANTS(:,78) = 0.000460000;
CONSTANTS(:,79) = 13.8000;
CONSTANTS(:,80) = 5.70000e-05;
CONSTANTS(:,81) = 0.0157000;
CONSTANTS(:,82) =  19.0000.*0.000900000;
CONSTANTS(:,83) = 0.0600000;
CONSTANTS(:,84) = 100.000;
CONSTANTS(:,85) = 1.30000;
CONSTANTS(:,86) = 100.000;
CONSTANTS(:,87) = 0.0300000;
CONSTANTS(:,88) = 100.000;
CONSTANTS(:,89) = 65.0000;
CONSTANTS(:,90) = 100.000;
CONSTANTS(:,91) = 0.00350000;
CONSTANTS(:,92) = 0.00350000;
CONSTANTS(:,93) = 0.00000;
CONSTANTS(:,94) = 0.00000;
CONSTANTS(:,95) = 15.0000;
CONSTANTS(:,96) = 1.00000;
CONSTANTS(:,124) = 0.00000;
CONSTANTS(:,97) = 96485.0;
CONSTANTS(:,98) = 10.2500;
CONSTANTS(:,99) = 0.0150000;
CONSTANTS(:,100) = 1.00000 - CONSTANTS(:,17);
CONSTANTS(:,101) = 1.00000 - CONSTANTS(:,18);
CONSTANTS(:,102) = (exp(CONSTANTS(:,20)./67.3000) - 1.00000)./7.00000;
CONSTANTS(:,103) =  0.0350000.*power((CONSTANTS(:,19)./5.40000), 1.0 ./ 2);
CONSTANTS(:,104) = piecewise({CONSTANTS(:,2)==1.00000,  1.00000.*0.130000.*0.120000 },  0.130000.*0.300000.*0.964000);
CONSTANTS(:,105) = piecewise({CONSTANTS(:,2)==1.00000,  1.00000.*0.130000.*0.880000 },  0.130000.*0.300000.*0.0360000);
CONSTANTS(:,106) = 0.500000;
CONSTANTS(:,107) = 310.000;
CONSTANTS(:,108) =   pi.*power(CONSTANTS(:,98), 2.00000).*CONSTANTS(:,5).*1.00000e-15;
CONSTANTS(:,109) =  20150.0.* pi.*2.00000.*CONSTANTS(:,6).*CONSTANTS(:,99);
CONSTANTS(:,110) =   pi.*2.00000.*CONSTANTS(:,98).*CONSTANTS(:,5);
CONSTANTS(:,111) = CONSTANTS(:,97)./( CONSTANTS(:,3).*CONSTANTS(:,107));
CONSTANTS(:,112) = (CONSTANTS(:,107) - 310.000)./10.0000;
CONSTANTS(:,113) =  0.650000.*CONSTANTS(:,108);
CONSTANTS(:,114) =  0.0350000.*CONSTANTS(:,108);
CONSTANTS(:,115) =  0.0200000.*CONSTANTS(:,108);
CONSTANTS(:,116) =  0.0539000.*0.0100000.*CONSTANTS(:,108);
CONSTANTS(:,117) = 15.0000;
CONSTANTS(:,118) = 150.000;
CONSTANTS(:,119) = ( 0.0374000.*CONSTANTS(:,113))./CONSTANTS(:,115);
CONSTANTS(:,120) =  (( 0.00460000.*CONSTANTS(:,113))./CONSTANTS(:,116)).*0.100000;
CONSTANTS(:,121) = ( 0.0134000.*CONSTANTS(:,113))./CONSTANTS(:,115);
CONSTANTS(:,122) =  (( 0.00165000.*CONSTANTS(:,113))./CONSTANTS(:,116)).*0.100000;
CONSTANTS(:,123) = ( 0.140000.*CONSTANTS(:,113))./CONSTANTS(:,114);
CONSTANTS(:,124) =  (1.00000./CONSTANTS(:,111)).*log(CONSTANTS(:,117)./CONSTANTS(:,118));
if (isempty(STATES)), warning('Initial values for states not set');, end
end

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

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

% Compute result of a piecewise function
function x = piecewise(cases, default)
set = [0];
for i = 1:2:length(cases)
if (length(cases{i+1}) == 1)
x(cases{i} & ~set,:) = cases{i+1};
else
x(cases{i} & ~set,:) = cases{i+1}(cases{i} & ~set);
end
set = set | cases{i};
if(set), break, end
end
if (length(default) == 1)
x(~set,:) = default;
else
x(~set,:) = default(~set);
end
end

% Pad out or shorten strings to a set length
req_length = 160;
insize = size(strin,2);
if insize > req_length
strout = strin(1:req_length);
else
strout = [strin, blanks(req_length - insize)];
end
end

```
Source
Derived from workspace Grandi, Pasqualini and Bers, 2010 at changeset 8a2c891da5f2.
Collaboration
To begin collaborating on this work, please use your git client and issue this command: