# 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 =56;
end
% There are a total of 6 entries in each of the rate and state variable arrays.
% There are a total of 46 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 (ms)');
LEGEND_CONSTANTS(:,1) = strpad('V_myo in component cell_geometry (um3)');
LEGEND_CONSTANTS(:,2) = strpad('V_SR in component cell_geometry (um3)');
LEGEND_CONSTANTS(:,3) = strpad('A_cap in component cell_geometry (um2)');
LEGEND_ALGEBRAIC(:,1) = strpad('V in component membrane (mV)');
LEGEND_CONSTANTS(:,4) = strpad('R in component membrane (mJ_per_mole_K)');
LEGEND_CONSTANTS(:,5) = strpad('T in component membrane (kelvin)');
LEGEND_CONSTANTS(:,6) = strpad('F in component membrane (C_per_mole)');
LEGEND_ALGEBRAIC(:,4) = strpad('FVRT in component membrane (dimensionless)');
LEGEND_ALGEBRAIC(:,5) = strpad('FVRT_Ca in component membrane (dimensionless)');
LEGEND_CONSTANTS(:,7) = strpad('g_D in component CaRU (um3_per_ms)');
LEGEND_CONSTANTS(:,8) = strpad('J_R in component CaRU (um3_per_ms)');
LEGEND_CONSTANTS(:,9) = strpad('J_L in component CaRU (um3_per_ms)');
LEGEND_CONSTANTS(:,10) = strpad('N in component CaRU (dimensionless)');
LEGEND_STATES(:,1) = strpad('Ca_i in component intracellular_ion_concentrations (mM)');
LEGEND_CONSTANTS(:,11) = strpad('Ca_o in component extracellular_ion_concentrations (mM)');
LEGEND_STATES(:,2) = strpad('Ca_SR in component intracellular_ion_concentrations (mM)');
LEGEND_ALGEBRAIC(:,35) = strpad('I_RyR in component RyR_current (mM_per_ms)');
LEGEND_ALGEBRAIC(:,44) = strpad('I_LCC in component LCC_current (mM_per_ms)');
LEGEND_ALGEBRAIC(:,16) = strpad('C_oc in component DS_Calcium_Concentrations (mM)');
LEGEND_ALGEBRAIC(:,14) = strpad('C_co in component DS_Calcium_Concentrations (mM)');
LEGEND_CONSTANTS(:,12) = strpad('V_L in component CaRU_Transitions (mV)');
LEGEND_CONSTANTS(:,13) = strpad('del_VL in component CaRU_Transitions (mV)');
LEGEND_CONSTANTS(:,14) = strpad('phi_L in component CaRU_Transitions (dimensionless)');
LEGEND_CONSTANTS(:,15) = strpad('t_L in component CaRU_Transitions (ms)');
LEGEND_CONSTANTS(:,16) = strpad('tau_L in component CaRU_Transitions (ms)');
LEGEND_CONSTANTS(:,44) = strpad('t_R in component CaRU_Transitions (ms)');
LEGEND_CONSTANTS(:,17) = strpad('tau_R in component CaRU_Transitions (ms)');
LEGEND_CONSTANTS(:,18) = strpad('phi_R in component CaRU_Transitions (dimensionless)');
LEGEND_CONSTANTS(:,19) = strpad('theta_R in component CaRU_Transitions (dimensionless)');
LEGEND_CONSTANTS(:,20) = strpad('K_RyR in component CaRU_Transitions (mM)');
LEGEND_CONSTANTS(:,21) = strpad('K_L in component CaRU_Transitions (mM)');
LEGEND_CONSTANTS(:,22) = strpad('a in component CaRU_Transitions (dimensionless)');
LEGEND_CONSTANTS(:,23) = strpad('b in component CaRU_Transitions (dimensionless)');
LEGEND_CONSTANTS(:,24) = strpad('c in component CaRU_Transitions (dimensionless)');
LEGEND_CONSTANTS(:,25) = strpad('d in component CaRU_Transitions (dimensionless)');
LEGEND_ALGEBRAIC(:,6) = strpad('expVL in component CaRU_Transitions (dimensionless)');
LEGEND_ALGEBRAIC(:,8) = strpad('alpha_p in component CaRU_Transitions (per_ms)');
LEGEND_CONSTANTS(:,45) = strpad('alpha_m in component CaRU_Transitions (per_ms)');
LEGEND_ALGEBRAIC(:,17) = strpad('beta_poc in component CaRU_Transitions (per_ms)');
LEGEND_ALGEBRAIC(:,9) = strpad('beta_pcc in component CaRU_Transitions (per_ms)');
LEGEND_CONSTANTS(:,46) = strpad('beta_m in component CaRU_Transitions (per_ms)');
LEGEND_ALGEBRAIC(:,15) = strpad('epsilon_pco in component CaRU_Transitions (per_ms)');
LEGEND_ALGEBRAIC(:,10) = strpad('epsilon_pcc in component CaRU_Transitions (per_ms)');
LEGEND_ALGEBRAIC(:,11) = strpad('epsilon_m in component CaRU_Transitions (per_ms)');
LEGEND_ALGEBRAIC(:,18) = strpad('mu_poc in component CaRU_Transitions (per_ms)');
LEGEND_ALGEBRAIC(:,12) = strpad('mu_pcc in component CaRU_Transitions (per_ms)');
LEGEND_ALGEBRAIC(:,19) = strpad('mu_moc in component CaRU_Transitions (per_ms)');
LEGEND_ALGEBRAIC(:,13) = strpad('mu_mcc in component CaRU_Transitions (per_ms)');
LEGEND_ALGEBRAIC(:,2) = strpad('C_cc in component DS_Calcium_Concentrations (mM)');
LEGEND_ALGEBRAIC(:,7) = strpad('C_oo in component DS_Calcium_Concentrations (mM)');
LEGEND_ALGEBRAIC(:,23) = strpad('J_Loo in component LCC_and_RyR_fluxes (um3_mM_per_ms)');
LEGEND_ALGEBRAIC(:,22) = strpad('J_Loc in component LCC_and_RyR_fluxes (um3_mM_per_ms)');
LEGEND_ALGEBRAIC(:,20) = strpad('J_Rco in component LCC_and_RyR_fluxes (um3_mM_per_ms)');
LEGEND_ALGEBRAIC(:,21) = strpad('J_Roo in component LCC_and_RyR_fluxes (um3_mM_per_ms)');
LEGEND_ALGEBRAIC(:,24) = strpad('denom in component CaRU_states (per_ms3)');
LEGEND_ALGEBRAIC(:,25) = strpad('y_oc in component CaRU_states (dimensionless)');
LEGEND_ALGEBRAIC(:,26) = strpad('y_co in component CaRU_states (dimensionless)');
LEGEND_ALGEBRAIC(:,27) = strpad('y_oo in component CaRU_states (dimensionless)');
LEGEND_ALGEBRAIC(:,28) = strpad('y_cc in component CaRU_states (dimensionless)');
LEGEND_ALGEBRAIC(:,30) = strpad('y_ci in component CaRU_states (dimensionless)');
LEGEND_ALGEBRAIC(:,33) = strpad('y_oi in component CaRU_states (dimensionless)');
LEGEND_ALGEBRAIC(:,36) = strpad('y_ic in component CaRU_states (dimensionless)');
LEGEND_ALGEBRAIC(:,39) = strpad('y_io in component CaRU_states (dimensionless)');
LEGEND_ALGEBRAIC(:,42) = strpad('y_ii in component CaRU_states (dimensionless)');
LEGEND_ALGEBRAIC(:,31) = strpad('r_1 in component CaRU_reduced_states (per_ms)');
LEGEND_ALGEBRAIC(:,34) = strpad('r_2 in component CaRU_reduced_states (per_ms)');
LEGEND_ALGEBRAIC(:,37) = strpad('r_3 in component CaRU_reduced_states (per_ms)');
LEGEND_ALGEBRAIC(:,40) = strpad('r_4 in component CaRU_reduced_states (per_ms)');
LEGEND_ALGEBRAIC(:,43) = strpad('r_5 in component CaRU_reduced_states (per_ms)');
LEGEND_ALGEBRAIC(:,45) = strpad('r_6 in component CaRU_reduced_states (per_ms)');
LEGEND_ALGEBRAIC(:,47) = strpad('r_7 in component CaRU_reduced_states (per_ms)');
LEGEND_ALGEBRAIC(:,49) = strpad('r_8 in component CaRU_reduced_states (per_ms)');
LEGEND_STATES(:,3) = strpad('z_1 in component CaRU_reduced_states (dimensionless)');
LEGEND_STATES(:,4) = strpad('z_2 in component CaRU_reduced_states (dimensionless)');
LEGEND_STATES(:,5) = strpad('z_3 in component CaRU_reduced_states (dimensionless)');
LEGEND_ALGEBRAIC(:,51) = strpad('z_4 in component CaRU_reduced_states (dimensionless)');
LEGEND_ALGEBRAIC(:,29) = strpad('J_R1 in component RyR_current (um3_mM_per_ms)');
LEGEND_ALGEBRAIC(:,32) = strpad('J_R3 in component RyR_current (um3_mM_per_ms)');
LEGEND_ALGEBRAIC(:,38) = strpad('J_L1 in component LCC_current (um3_mM_per_ms)');
LEGEND_ALGEBRAIC(:,41) = strpad('J_L2 in component LCC_current (um3_mM_per_ms)');
LEGEND_CONSTANTS(:,26) = strpad('K_mNa in component Na_Ca_Exchanger (mM)');
LEGEND_CONSTANTS(:,27) = strpad('K_mCa in component Na_Ca_Exchanger (mM)');
LEGEND_CONSTANTS(:,28) = strpad('eta in component Na_Ca_Exchanger (dimensionless)');
LEGEND_CONSTANTS(:,29) = strpad('k_sat in component Na_Ca_Exchanger (dimensionless)');
LEGEND_CONSTANTS(:,30) = strpad('g_NCX in component Na_Ca_Exchanger (mM_per_ms)');
LEGEND_CONSTANTS(:,31) = strpad('Na_i in component intracellular_ion_concentrations (mM)');
LEGEND_CONSTANTS(:,32) = strpad('Na_o in component extracellular_ion_concentrations (mM)');
LEGEND_ALGEBRAIC(:,46) = strpad('I_NaCa in component Na_Ca_Exchanger (mM_per_ms)');
LEGEND_CONSTANTS(:,33) = strpad('g_SERCA in component SERCA (mM_per_ms)');
LEGEND_CONSTANTS(:,34) = strpad('K_SERCA in component SERCA (mM)');
LEGEND_ALGEBRAIC(:,48) = strpad('I_SERCA in component SERCA (mM_per_ms)');
LEGEND_CONSTANTS(:,35) = strpad('g_pCa in component Sarcolemmal_Ca_pump (mM_per_ms)');
LEGEND_CONSTANTS(:,36) = strpad('K_mpCa in component Sarcolemmal_Ca_pump (mM)');
LEGEND_ALGEBRAIC(:,50) = strpad('I_pCa in component Sarcolemmal_Ca_pump (mM_per_ms)');
LEGEND_ALGEBRAIC(:,52) = strpad('E_Ca in component Background_Ca_current (mV)');
LEGEND_CONSTANTS(:,37) = strpad('g_CaB in component Background_Ca_current (mM_per_mV_ms)');
LEGEND_ALGEBRAIC(:,53) = strpad('I_CaB in component Background_Ca_current (mM_per_ms)');
LEGEND_CONSTANTS(:,38) = strpad('g_SRl in component SR_Ca_leak_current (per_ms)');
LEGEND_ALGEBRAIC(:,54) = strpad('I_SR in component SR_Ca_leak_current (mM_per_ms)');
LEGEND_CONSTANTS(:,39) = strpad('k_m_TRPN in component troponin_Ca_buffer (per_ms)');
LEGEND_CONSTANTS(:,40) = strpad('k_p_TRPN in component troponin_Ca_buffer (per_mM_ms)');
LEGEND_CONSTANTS(:,41) = strpad('B_TRPN in component troponin_Ca_buffer (mM)');
LEGEND_STATES(:,6) = strpad('TRPN in component intracellular_ion_concentrations (mM)');
LEGEND_ALGEBRAIC(:,55) = strpad('I_TRPN in component troponin_Ca_buffer (mM_per_ms)');
LEGEND_CONSTANTS(:,42) = strpad('k_CMDN in component calmodulin_Ca_buffer (mM)');
LEGEND_CONSTANTS(:,43) = strpad('B_CMDN in component calmodulin_Ca_buffer (mM)');
LEGEND_ALGEBRAIC(:,56) = strpad('beta_CMDN in component calmodulin_Ca_buffer (dimensionless)');
LEGEND_ALGEBRAIC(:,3) = strpad('CaSR_plot in component intracellular_ion_concentrations (mM)');
LEGEND_RATES(:,3) = strpad('d/dt z_1 in component CaRU_reduced_states (dimensionless)');
LEGEND_RATES(:,4) = strpad('d/dt z_2 in component CaRU_reduced_states (dimensionless)');
LEGEND_RATES(:,5) = strpad('d/dt z_3 in component CaRU_reduced_states (dimensionless)');
LEGEND_RATES(:,6) = strpad('d/dt TRPN in component intracellular_ion_concentrations (mM)');
LEGEND_RATES(:,1) = strpad('d/dt Ca_i in component intracellular_ion_concentrations (mM)');
LEGEND_RATES(:,2) = strpad('d/dt Ca_SR in component intracellular_ion_concentrations (mM)');
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) = 25.84e3;
CONSTANTS(:,2) = 2.098e3;
CONSTANTS(:,3) = 1.534e4;
CONSTANTS(:,4) = 8314.5;
CONSTANTS(:,5) = 295;
CONSTANTS(:,6) = 96487;
CONSTANTS(:,7) = 0.065;
CONSTANTS(:,8) = 0.02;
CONSTANTS(:,9) = 9.13e-4;
CONSTANTS(:,10) = 50000;
STATES(:,1) = 0.0001;
CONSTANTS(:,11) = 1;
STATES(:,2) = 700e-3;
CONSTANTS(:,12) = -2;
CONSTANTS(:,13) = 7;
CONSTANTS(:,14) = 2.35;
CONSTANTS(:,15) = 1;
CONSTANTS(:,16) = 650;
CONSTANTS(:,17) = 2.43;
CONSTANTS(:,18) = 0.05;
CONSTANTS(:,19) = 0.012;
CONSTANTS(:,20) = 41e-3;
CONSTANTS(:,21) = 0.22e-3;
CONSTANTS(:,22) = 0.0625;
CONSTANTS(:,23) = 14;
CONSTANTS(:,24) = 0.01;
CONSTANTS(:,25) = 100;
STATES(:,3) = 0.98859;
STATES(:,4) = 0.0087302;
STATES(:,5) = 0.0026566;
CONSTANTS(:,26) = 87.5;
CONSTANTS(:,27) = 1.38;
CONSTANTS(:,28) = 0.35;
CONSTANTS(:,29) = 0.1;
CONSTANTS(:,30) = 38.5e-3;
CONSTANTS(:,31) = 10;
CONSTANTS(:,32) = 140;
CONSTANTS(:,33) = 0.45e-3;
CONSTANTS(:,34) = 0.5e-3;
CONSTANTS(:,35) = 0.0035e-3;
CONSTANTS(:,36) = 0.5e-3;
CONSTANTS(:,37) = 2.6875e-8;
CONSTANTS(:,38) = 1.8951e-5;
CONSTANTS(:,39) = 0.04;
CONSTANTS(:,40) = 0.04e3;
CONSTANTS(:,41) = 70e-3;
STATES(:,6) = 0.0636364;
CONSTANTS(:,42) = 2.382e-3;
CONSTANTS(:,43) = 50e-3;
CONSTANTS(:,44) =  1.17000.*CONSTANTS(:,15);
CONSTANTS(:,45) = CONSTANTS(:,14)./CONSTANTS(:,15);
CONSTANTS(:,46) = CONSTANTS(:,18)./CONSTANTS(:,44);
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(:,1) = piecewise({VOI>=0.00000&VOI<=200.000, 0.00000 },  - 80.0000);
ALGEBRAIC(:,4) = ( CONSTANTS(:,6).*ALGEBRAIC(:,1))./( CONSTANTS(:,4).*CONSTANTS(:,5));
ALGEBRAIC(:,5) =  2.00000.*ALGEBRAIC(:,4);
ALGEBRAIC(:,16) = piecewise({abs(ALGEBRAIC(:,5))>1.00000e-09, (STATES(:,1)+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*CONSTANTS(:,11).*ALGEBRAIC(:,5).*exp( - ALGEBRAIC(:,5)))./(1.00000 - exp( - ALGEBRAIC(:,5))))./(1.00000+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*ALGEBRAIC(:,5))./(1.00000 - exp( - ALGEBRAIC(:,5)))) }, (STATES(:,1)+ (CONSTANTS(:,9)./CONSTANTS(:,7)).*CONSTANTS(:,11))./(1.00000+CONSTANTS(:,9)./CONSTANTS(:,7)));
ALGEBRAIC(:,18) = (power(ALGEBRAIC(:,16), 2.00000)+ CONSTANTS(:,24).*power(CONSTANTS(:,20), 2.00000))./( CONSTANTS(:,17).*(power(ALGEBRAIC(:,16), 2.00000)+power(CONSTANTS(:,20), 2.00000)));
ALGEBRAIC(:,12) = (power(STATES(:,1), 2.00000)+ CONSTANTS(:,24).*power(CONSTANTS(:,20), 2.00000))./( CONSTANTS(:,17).*(power(STATES(:,1), 2.00000)+power(CONSTANTS(:,20), 2.00000)));
ALGEBRAIC(:,6) = exp((ALGEBRAIC(:,1) - CONSTANTS(:,12))./CONSTANTS(:,13));
ALGEBRAIC(:,8) = ALGEBRAIC(:,6)./( CONSTANTS(:,15).*(ALGEBRAIC(:,6)+1.00000));
ALGEBRAIC(:,9) = power(STATES(:,1), 2.00000)./( CONSTANTS(:,44).*(power(STATES(:,1), 2.00000)+power(CONSTANTS(:,20), 2.00000)));
ALGEBRAIC(:,17) = power(ALGEBRAIC(:,16), 2.00000)./( CONSTANTS(:,44).*(power(ALGEBRAIC(:,16), 2.00000)+power(CONSTANTS(:,20), 2.00000)));
ALGEBRAIC(:,24) =  (ALGEBRAIC(:,8)+CONSTANTS(:,45)).*( (CONSTANTS(:,45)+CONSTANTS(:,46)+ALGEBRAIC(:,17)).*(CONSTANTS(:,46)+ALGEBRAIC(:,9))+ ALGEBRAIC(:,8).*(CONSTANTS(:,46)+ALGEBRAIC(:,17)));
ALGEBRAIC(:,25) = ( ALGEBRAIC(:,8).*CONSTANTS(:,46).*(ALGEBRAIC(:,8)+CONSTANTS(:,45)+CONSTANTS(:,46)+ALGEBRAIC(:,9)))./ALGEBRAIC(:,24);
ALGEBRAIC(:,28) = ( CONSTANTS(:,45).*CONSTANTS(:,46).*(CONSTANTS(:,45)+ALGEBRAIC(:,8)+CONSTANTS(:,46)+ALGEBRAIC(:,17)))./ALGEBRAIC(:,24);
ALGEBRAIC(:,31) =  ALGEBRAIC(:,25).*ALGEBRAIC(:,18)+ ALGEBRAIC(:,28).*ALGEBRAIC(:,12);
ALGEBRAIC(:,19) = ( CONSTANTS(:,19).*CONSTANTS(:,25).*(power(ALGEBRAIC(:,16), 2.00000)+ CONSTANTS(:,24).*power(CONSTANTS(:,20), 2.00000)))./( CONSTANTS(:,17).*( CONSTANTS(:,25).*power(ALGEBRAIC(:,16), 2.00000)+ CONSTANTS(:,24).*power(CONSTANTS(:,20), 2.00000)));
ALGEBRAIC(:,13) = ( CONSTANTS(:,19).*CONSTANTS(:,25).*(power(STATES(:,1), 2.00000)+ CONSTANTS(:,24).*power(CONSTANTS(:,20), 2.00000)))./( CONSTANTS(:,17).*( CONSTANTS(:,25).*power(STATES(:,1), 2.00000)+ CONSTANTS(:,24).*power(CONSTANTS(:,20), 2.00000)));
ALGEBRAIC(:,34) = ( ALGEBRAIC(:,8).*ALGEBRAIC(:,19)+ CONSTANTS(:,45).*ALGEBRAIC(:,13))./(ALGEBRAIC(:,8)+CONSTANTS(:,45));
ALGEBRAIC(:,14) = (STATES(:,1)+ (CONSTANTS(:,8)./CONSTANTS(:,7)).*STATES(:,2))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7));
ALGEBRAIC(:,15) = ( ALGEBRAIC(:,14).*(ALGEBRAIC(:,6)+CONSTANTS(:,22)))./( CONSTANTS(:,16).*CONSTANTS(:,21).*(ALGEBRAIC(:,6)+1.00000));
ALGEBRAIC(:,10) = ( STATES(:,1).*(ALGEBRAIC(:,6)+CONSTANTS(:,22)))./( CONSTANTS(:,16).*CONSTANTS(:,21).*(ALGEBRAIC(:,6)+1.00000));
ALGEBRAIC(:,26) = ( CONSTANTS(:,45).*( ALGEBRAIC(:,9).*(CONSTANTS(:,45)+CONSTANTS(:,46)+ALGEBRAIC(:,17))+ ALGEBRAIC(:,17).*ALGEBRAIC(:,8)))./ALGEBRAIC(:,24);
ALGEBRAIC(:,43) =  ALGEBRAIC(:,26).*ALGEBRAIC(:,15)+ ALGEBRAIC(:,28).*ALGEBRAIC(:,10);
ALGEBRAIC(:,11) = ( CONSTANTS(:,23).*(ALGEBRAIC(:,6)+CONSTANTS(:,22)))./( CONSTANTS(:,16).*( CONSTANTS(:,23).*ALGEBRAIC(:,6)+CONSTANTS(:,22)));
ALGEBRAIC(:,45) = ALGEBRAIC(:,11);
RATES(:,3) =   - (ALGEBRAIC(:,31)+ALGEBRAIC(:,43)).*STATES(:,3)+ ALGEBRAIC(:,34).*STATES(:,4)+ ALGEBRAIC(:,45).*STATES(:,5);
ALGEBRAIC(:,47) = ( CONSTANTS(:,45).*ALGEBRAIC(:,10))./(ALGEBRAIC(:,8)+CONSTANTS(:,45));
ALGEBRAIC(:,49) = ALGEBRAIC(:,11);
ALGEBRAIC(:,51) = ((1.00000 - STATES(:,3)) - STATES(:,4)) - STATES(:,5);
RATES(:,4) = ( ALGEBRAIC(:,31).*STATES(:,3) -  (ALGEBRAIC(:,34)+ALGEBRAIC(:,47)).*STATES(:,4))+ ALGEBRAIC(:,49).*ALGEBRAIC(:,51);
ALGEBRAIC(:,37) = ( CONSTANTS(:,46).*ALGEBRAIC(:,12))./(CONSTANTS(:,46)+ALGEBRAIC(:,9));
ALGEBRAIC(:,40) = ALGEBRAIC(:,13);
RATES(:,5) = ( ALGEBRAIC(:,43).*STATES(:,3) -  (ALGEBRAIC(:,45)+ALGEBRAIC(:,37)).*STATES(:,5))+ ALGEBRAIC(:,40).*ALGEBRAIC(:,51);
ALGEBRAIC(:,20) = ( CONSTANTS(:,8).*(STATES(:,2) - STATES(:,1)))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7));
ALGEBRAIC(:,21) = piecewise({abs(ALGEBRAIC(:,5))>1.00000e-05, ( CONSTANTS(:,8).*((STATES(:,2) - STATES(:,1))+ (( (CONSTANTS(:,9)./CONSTANTS(:,7)).*ALGEBRAIC(:,5))./(1.00000 - exp( - ALGEBRAIC(:,5)))).*(STATES(:,2) -  CONSTANTS(:,11).*exp( - ALGEBRAIC(:,5)))))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7)+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*ALGEBRAIC(:,5))./(1.00000 - exp( - ALGEBRAIC(:,5)))) }, ( CONSTANTS(:,8).*((STATES(:,2) - STATES(:,1))+ (( (CONSTANTS(:,9)./CONSTANTS(:,7)).*1.00000e-05)./(1.00000 - exp( - 1.00000e-05))).*(STATES(:,2) -  CONSTANTS(:,11).*exp( - 1.00000e-05))))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7)+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*1.00000e-05)./(1.00000 - exp( - 1.00000e-05))));
ALGEBRAIC(:,27) = ( ALGEBRAIC(:,8).*( ALGEBRAIC(:,17).*(ALGEBRAIC(:,8)+CONSTANTS(:,46)+ALGEBRAIC(:,9))+ ALGEBRAIC(:,9).*CONSTANTS(:,45)))./ALGEBRAIC(:,24);
ALGEBRAIC(:,29) =  ALGEBRAIC(:,27).*ALGEBRAIC(:,21)+ ALGEBRAIC(:,20).*ALGEBRAIC(:,26);
ALGEBRAIC(:,32) = ( ALGEBRAIC(:,20).*ALGEBRAIC(:,9))./(CONSTANTS(:,46)+ALGEBRAIC(:,9));
ALGEBRAIC(:,35) = ( ( STATES(:,3).*ALGEBRAIC(:,29)+ STATES(:,5).*ALGEBRAIC(:,32)).*CONSTANTS(:,10))./CONSTANTS(:,1);
ALGEBRAIC(:,48) = ( CONSTANTS(:,33).*power(STATES(:,1), 2.00000))./(power(CONSTANTS(:,34), 2.00000)+power(STATES(:,1), 2.00000));
ALGEBRAIC(:,54) =  CONSTANTS(:,38).*(STATES(:,2) - STATES(:,1));
RATES(:,2) =  (CONSTANTS(:,1)./CONSTANTS(:,2)).*(( - ALGEBRAIC(:,35)+ALGEBRAIC(:,48)) - ALGEBRAIC(:,54));
ALGEBRAIC(:,55) =  CONSTANTS(:,39).*(CONSTANTS(:,41) - STATES(:,6)) -  CONSTANTS(:,40).*STATES(:,6).*STATES(:,1);
RATES(:,6) = ALGEBRAIC(:,55);
ALGEBRAIC(:,23) = piecewise({abs(ALGEBRAIC(:,5))>1.00000e-05, ( (( CONSTANTS(:,9).*ALGEBRAIC(:,5))./(1.00000 - exp( - ALGEBRAIC(:,5)))).*(( CONSTANTS(:,11).*exp( - ALGEBRAIC(:,5)) - STATES(:,1))+ (CONSTANTS(:,8)./CONSTANTS(:,7)).*( CONSTANTS(:,11).*exp( - ALGEBRAIC(:,5)) - STATES(:,2))))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7)+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*ALGEBRAIC(:,5))./(1.00000 - exp(ALGEBRAIC(:,5)))) }, ( (( CONSTANTS(:,9).*1.00000e-05)./(1.00000 - exp( - 1.00000e-05))).*(( CONSTANTS(:,11).*exp( - 1.00000e-05) - STATES(:,1))+ (CONSTANTS(:,8)./CONSTANTS(:,7)).*( CONSTANTS(:,11).*exp( - 1.00000e-05) - STATES(:,2))))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7)+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*1.00000e-05)./(1.00000 - exp( - 1.00000e-05))));
ALGEBRAIC(:,22) = piecewise({abs(ALGEBRAIC(:,5))>1.00000e-05, ( (( CONSTANTS(:,9).*ALGEBRAIC(:,5))./(1.00000 - exp( - ALGEBRAIC(:,5)))).*( CONSTANTS(:,11).*exp( - ALGEBRAIC(:,5)) - STATES(:,1)))./(1.00000+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*ALGEBRAIC(:,5))./(1.00000 - exp( - ALGEBRAIC(:,5)))) }, ( (( CONSTANTS(:,9).*1.00000e-05)./(1.00000 - exp( - 1.00000e-05))).*( CONSTANTS(:,11).*exp( - 1.00000e-05) - STATES(:,1)))./(1.00000+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*1.00000e-05)./(1.00000 - exp( - 1.00000e-05))));
ALGEBRAIC(:,38) =  ALGEBRAIC(:,23).*ALGEBRAIC(:,27)+ ALGEBRAIC(:,22).*ALGEBRAIC(:,25);
ALGEBRAIC(:,41) = ( ALGEBRAIC(:,22).*ALGEBRAIC(:,8))./(ALGEBRAIC(:,8)+CONSTANTS(:,45));
ALGEBRAIC(:,44) = ( ( STATES(:,3).*ALGEBRAIC(:,38)+ STATES(:,4).*ALGEBRAIC(:,41)).*CONSTANTS(:,10))./CONSTANTS(:,1);
ALGEBRAIC(:,46) = ( CONSTANTS(:,30).*( exp( CONSTANTS(:,28).*ALGEBRAIC(:,4)).*power(CONSTANTS(:,31), 3.00000).*CONSTANTS(:,11) -  exp( (CONSTANTS(:,28) - 1.00000).*ALGEBRAIC(:,4)).*power(CONSTANTS(:,32), 3.00000).*STATES(:,1)))./( (power(CONSTANTS(:,32), 3.00000)+power(CONSTANTS(:,26), 3.00000)).*(CONSTANTS(:,11)+CONSTANTS(:,27)).*(1.00000+ CONSTANTS(:,29).*exp( (CONSTANTS(:,28) - 1.00000).*ALGEBRAIC(:,4))));
ALGEBRAIC(:,50) = ( CONSTANTS(:,35).*STATES(:,1))./(CONSTANTS(:,36)+STATES(:,1));
ALGEBRAIC(:,52) =  (( CONSTANTS(:,4).*CONSTANTS(:,5))./( 2.00000.*CONSTANTS(:,6))).*log(CONSTANTS(:,11)./STATES(:,1));
ALGEBRAIC(:,53) =  CONSTANTS(:,37).*(ALGEBRAIC(:,52) - ALGEBRAIC(:,1));
ALGEBRAIC(:,56) = power(1.00000+( CONSTANTS(:,42).*CONSTANTS(:,43))./power(CONSTANTS(:,42)+STATES(:,1), 2.00000),  - 1.00000);
RATES(:,1) =  ALGEBRAIC(:,56).*(((((ALGEBRAIC(:,44)+ALGEBRAIC(:,35)) - ALGEBRAIC(:,48))+ALGEBRAIC(:,54)+ALGEBRAIC(:,46)) - ALGEBRAIC(:,50))+ALGEBRAIC(:,53)+ALGEBRAIC(:,55));
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) = piecewise({VOI>=0.00000&VOI<=200.000, 0.00000 },  - 80.0000);
ALGEBRAIC(:,4) = ( CONSTANTS(:,6).*ALGEBRAIC(:,1))./( CONSTANTS(:,4).*CONSTANTS(:,5));
ALGEBRAIC(:,5) =  2.00000.*ALGEBRAIC(:,4);
ALGEBRAIC(:,16) = piecewise({abs(ALGEBRAIC(:,5))>1.00000e-09, (STATES(:,1)+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*CONSTANTS(:,11).*ALGEBRAIC(:,5).*exp( - ALGEBRAIC(:,5)))./(1.00000 - exp( - ALGEBRAIC(:,5))))./(1.00000+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*ALGEBRAIC(:,5))./(1.00000 - exp( - ALGEBRAIC(:,5)))) }, (STATES(:,1)+ (CONSTANTS(:,9)./CONSTANTS(:,7)).*CONSTANTS(:,11))./(1.00000+CONSTANTS(:,9)./CONSTANTS(:,7)));
ALGEBRAIC(:,18) = (power(ALGEBRAIC(:,16), 2.00000)+ CONSTANTS(:,24).*power(CONSTANTS(:,20), 2.00000))./( CONSTANTS(:,17).*(power(ALGEBRAIC(:,16), 2.00000)+power(CONSTANTS(:,20), 2.00000)));
ALGEBRAIC(:,12) = (power(STATES(:,1), 2.00000)+ CONSTANTS(:,24).*power(CONSTANTS(:,20), 2.00000))./( CONSTANTS(:,17).*(power(STATES(:,1), 2.00000)+power(CONSTANTS(:,20), 2.00000)));
ALGEBRAIC(:,6) = exp((ALGEBRAIC(:,1) - CONSTANTS(:,12))./CONSTANTS(:,13));
ALGEBRAIC(:,8) = ALGEBRAIC(:,6)./( CONSTANTS(:,15).*(ALGEBRAIC(:,6)+1.00000));
ALGEBRAIC(:,9) = power(STATES(:,1), 2.00000)./( CONSTANTS(:,44).*(power(STATES(:,1), 2.00000)+power(CONSTANTS(:,20), 2.00000)));
ALGEBRAIC(:,17) = power(ALGEBRAIC(:,16), 2.00000)./( CONSTANTS(:,44).*(power(ALGEBRAIC(:,16), 2.00000)+power(CONSTANTS(:,20), 2.00000)));
ALGEBRAIC(:,24) =  (ALGEBRAIC(:,8)+CONSTANTS(:,45)).*( (CONSTANTS(:,45)+CONSTANTS(:,46)+ALGEBRAIC(:,17)).*(CONSTANTS(:,46)+ALGEBRAIC(:,9))+ ALGEBRAIC(:,8).*(CONSTANTS(:,46)+ALGEBRAIC(:,17)));
ALGEBRAIC(:,25) = ( ALGEBRAIC(:,8).*CONSTANTS(:,46).*(ALGEBRAIC(:,8)+CONSTANTS(:,45)+CONSTANTS(:,46)+ALGEBRAIC(:,9)))./ALGEBRAIC(:,24);
ALGEBRAIC(:,28) = ( CONSTANTS(:,45).*CONSTANTS(:,46).*(CONSTANTS(:,45)+ALGEBRAIC(:,8)+CONSTANTS(:,46)+ALGEBRAIC(:,17)))./ALGEBRAIC(:,24);
ALGEBRAIC(:,31) =  ALGEBRAIC(:,25).*ALGEBRAIC(:,18)+ ALGEBRAIC(:,28).*ALGEBRAIC(:,12);
ALGEBRAIC(:,19) = ( CONSTANTS(:,19).*CONSTANTS(:,25).*(power(ALGEBRAIC(:,16), 2.00000)+ CONSTANTS(:,24).*power(CONSTANTS(:,20), 2.00000)))./( CONSTANTS(:,17).*( CONSTANTS(:,25).*power(ALGEBRAIC(:,16), 2.00000)+ CONSTANTS(:,24).*power(CONSTANTS(:,20), 2.00000)));
ALGEBRAIC(:,13) = ( CONSTANTS(:,19).*CONSTANTS(:,25).*(power(STATES(:,1), 2.00000)+ CONSTANTS(:,24).*power(CONSTANTS(:,20), 2.00000)))./( CONSTANTS(:,17).*( CONSTANTS(:,25).*power(STATES(:,1), 2.00000)+ CONSTANTS(:,24).*power(CONSTANTS(:,20), 2.00000)));
ALGEBRAIC(:,34) = ( ALGEBRAIC(:,8).*ALGEBRAIC(:,19)+ CONSTANTS(:,45).*ALGEBRAIC(:,13))./(ALGEBRAIC(:,8)+CONSTANTS(:,45));
ALGEBRAIC(:,14) = (STATES(:,1)+ (CONSTANTS(:,8)./CONSTANTS(:,7)).*STATES(:,2))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7));
ALGEBRAIC(:,15) = ( ALGEBRAIC(:,14).*(ALGEBRAIC(:,6)+CONSTANTS(:,22)))./( CONSTANTS(:,16).*CONSTANTS(:,21).*(ALGEBRAIC(:,6)+1.00000));
ALGEBRAIC(:,10) = ( STATES(:,1).*(ALGEBRAIC(:,6)+CONSTANTS(:,22)))./( CONSTANTS(:,16).*CONSTANTS(:,21).*(ALGEBRAIC(:,6)+1.00000));
ALGEBRAIC(:,26) = ( CONSTANTS(:,45).*( ALGEBRAIC(:,9).*(CONSTANTS(:,45)+CONSTANTS(:,46)+ALGEBRAIC(:,17))+ ALGEBRAIC(:,17).*ALGEBRAIC(:,8)))./ALGEBRAIC(:,24);
ALGEBRAIC(:,43) =  ALGEBRAIC(:,26).*ALGEBRAIC(:,15)+ ALGEBRAIC(:,28).*ALGEBRAIC(:,10);
ALGEBRAIC(:,11) = ( CONSTANTS(:,23).*(ALGEBRAIC(:,6)+CONSTANTS(:,22)))./( CONSTANTS(:,16).*( CONSTANTS(:,23).*ALGEBRAIC(:,6)+CONSTANTS(:,22)));
ALGEBRAIC(:,45) = ALGEBRAIC(:,11);
ALGEBRAIC(:,47) = ( CONSTANTS(:,45).*ALGEBRAIC(:,10))./(ALGEBRAIC(:,8)+CONSTANTS(:,45));
ALGEBRAIC(:,49) = ALGEBRAIC(:,11);
ALGEBRAIC(:,51) = ((1.00000 - STATES(:,3)) - STATES(:,4)) - STATES(:,5);
ALGEBRAIC(:,37) = ( CONSTANTS(:,46).*ALGEBRAIC(:,12))./(CONSTANTS(:,46)+ALGEBRAIC(:,9));
ALGEBRAIC(:,40) = ALGEBRAIC(:,13);
ALGEBRAIC(:,20) = ( CONSTANTS(:,8).*(STATES(:,2) - STATES(:,1)))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7));
ALGEBRAIC(:,21) = piecewise({abs(ALGEBRAIC(:,5))>1.00000e-05, ( CONSTANTS(:,8).*((STATES(:,2) - STATES(:,1))+ (( (CONSTANTS(:,9)./CONSTANTS(:,7)).*ALGEBRAIC(:,5))./(1.00000 - exp( - ALGEBRAIC(:,5)))).*(STATES(:,2) -  CONSTANTS(:,11).*exp( - ALGEBRAIC(:,5)))))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7)+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*ALGEBRAIC(:,5))./(1.00000 - exp( - ALGEBRAIC(:,5)))) }, ( CONSTANTS(:,8).*((STATES(:,2) - STATES(:,1))+ (( (CONSTANTS(:,9)./CONSTANTS(:,7)).*1.00000e-05)./(1.00000 - exp( - 1.00000e-05))).*(STATES(:,2) -  CONSTANTS(:,11).*exp( - 1.00000e-05))))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7)+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*1.00000e-05)./(1.00000 - exp( - 1.00000e-05))));
ALGEBRAIC(:,27) = ( ALGEBRAIC(:,8).*( ALGEBRAIC(:,17).*(ALGEBRAIC(:,8)+CONSTANTS(:,46)+ALGEBRAIC(:,9))+ ALGEBRAIC(:,9).*CONSTANTS(:,45)))./ALGEBRAIC(:,24);
ALGEBRAIC(:,29) =  ALGEBRAIC(:,27).*ALGEBRAIC(:,21)+ ALGEBRAIC(:,20).*ALGEBRAIC(:,26);
ALGEBRAIC(:,32) = ( ALGEBRAIC(:,20).*ALGEBRAIC(:,9))./(CONSTANTS(:,46)+ALGEBRAIC(:,9));
ALGEBRAIC(:,35) = ( ( STATES(:,3).*ALGEBRAIC(:,29)+ STATES(:,5).*ALGEBRAIC(:,32)).*CONSTANTS(:,10))./CONSTANTS(:,1);
ALGEBRAIC(:,48) = ( CONSTANTS(:,33).*power(STATES(:,1), 2.00000))./(power(CONSTANTS(:,34), 2.00000)+power(STATES(:,1), 2.00000));
ALGEBRAIC(:,54) =  CONSTANTS(:,38).*(STATES(:,2) - STATES(:,1));
ALGEBRAIC(:,55) =  CONSTANTS(:,39).*(CONSTANTS(:,41) - STATES(:,6)) -  CONSTANTS(:,40).*STATES(:,6).*STATES(:,1);
ALGEBRAIC(:,23) = piecewise({abs(ALGEBRAIC(:,5))>1.00000e-05, ( (( CONSTANTS(:,9).*ALGEBRAIC(:,5))./(1.00000 - exp( - ALGEBRAIC(:,5)))).*(( CONSTANTS(:,11).*exp( - ALGEBRAIC(:,5)) - STATES(:,1))+ (CONSTANTS(:,8)./CONSTANTS(:,7)).*( CONSTANTS(:,11).*exp( - ALGEBRAIC(:,5)) - STATES(:,2))))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7)+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*ALGEBRAIC(:,5))./(1.00000 - exp(ALGEBRAIC(:,5)))) }, ( (( CONSTANTS(:,9).*1.00000e-05)./(1.00000 - exp( - 1.00000e-05))).*(( CONSTANTS(:,11).*exp( - 1.00000e-05) - STATES(:,1))+ (CONSTANTS(:,8)./CONSTANTS(:,7)).*( CONSTANTS(:,11).*exp( - 1.00000e-05) - STATES(:,2))))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7)+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*1.00000e-05)./(1.00000 - exp( - 1.00000e-05))));
ALGEBRAIC(:,22) = piecewise({abs(ALGEBRAIC(:,5))>1.00000e-05, ( (( CONSTANTS(:,9).*ALGEBRAIC(:,5))./(1.00000 - exp( - ALGEBRAIC(:,5)))).*( CONSTANTS(:,11).*exp( - ALGEBRAIC(:,5)) - STATES(:,1)))./(1.00000+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*ALGEBRAIC(:,5))./(1.00000 - exp( - ALGEBRAIC(:,5)))) }, ( (( CONSTANTS(:,9).*1.00000e-05)./(1.00000 - exp( - 1.00000e-05))).*( CONSTANTS(:,11).*exp( - 1.00000e-05) - STATES(:,1)))./(1.00000+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*1.00000e-05)./(1.00000 - exp( - 1.00000e-05))));
ALGEBRAIC(:,38) =  ALGEBRAIC(:,23).*ALGEBRAIC(:,27)+ ALGEBRAIC(:,22).*ALGEBRAIC(:,25);
ALGEBRAIC(:,41) = ( ALGEBRAIC(:,22).*ALGEBRAIC(:,8))./(ALGEBRAIC(:,8)+CONSTANTS(:,45));
ALGEBRAIC(:,44) = ( ( STATES(:,3).*ALGEBRAIC(:,38)+ STATES(:,4).*ALGEBRAIC(:,41)).*CONSTANTS(:,10))./CONSTANTS(:,1);
ALGEBRAIC(:,46) = ( CONSTANTS(:,30).*( exp( CONSTANTS(:,28).*ALGEBRAIC(:,4)).*power(CONSTANTS(:,31), 3.00000).*CONSTANTS(:,11) -  exp( (CONSTANTS(:,28) - 1.00000).*ALGEBRAIC(:,4)).*power(CONSTANTS(:,32), 3.00000).*STATES(:,1)))./( (power(CONSTANTS(:,32), 3.00000)+power(CONSTANTS(:,26), 3.00000)).*(CONSTANTS(:,11)+CONSTANTS(:,27)).*(1.00000+ CONSTANTS(:,29).*exp( (CONSTANTS(:,28) - 1.00000).*ALGEBRAIC(:,4))));
ALGEBRAIC(:,50) = ( CONSTANTS(:,35).*STATES(:,1))./(CONSTANTS(:,36)+STATES(:,1));
ALGEBRAIC(:,52) =  (( CONSTANTS(:,4).*CONSTANTS(:,5))./( 2.00000.*CONSTANTS(:,6))).*log(CONSTANTS(:,11)./STATES(:,1));
ALGEBRAIC(:,53) =  CONSTANTS(:,37).*(ALGEBRAIC(:,52) - ALGEBRAIC(:,1));
ALGEBRAIC(:,56) = power(1.00000+( CONSTANTS(:,42).*CONSTANTS(:,43))./power(CONSTANTS(:,42)+STATES(:,1), 2.00000),  - 1.00000);
ALGEBRAIC(:,2) = STATES(:,1);
ALGEBRAIC(:,3) = ( STATES(:,2).*CONSTANTS(:,2))./CONSTANTS(:,1);
ALGEBRAIC(:,7) = piecewise({abs(ALGEBRAIC(:,5))>1.00000e-09, (STATES(:,1)+ (CONSTANTS(:,8)./CONSTANTS(:,7)).*STATES(:,2)+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*CONSTANTS(:,11).*ALGEBRAIC(:,5).*exp( - ALGEBRAIC(:,5)))./(1.00000 - exp( - ALGEBRAIC(:,5))))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7)+( (CONSTANTS(:,9)./CONSTANTS(:,7)).*ALGEBRAIC(:,5))./(1.00000 - exp( - ALGEBRAIC(:,5)))) }, (STATES(:,1)+ (CONSTANTS(:,8)./CONSTANTS(:,7)).*STATES(:,2)+ (CONSTANTS(:,9)./CONSTANTS(:,7)).*CONSTANTS(:,11))./(1.00000+CONSTANTS(:,8)./CONSTANTS(:,7)+CONSTANTS(:,9)./CONSTANTS(:,7)));
ALGEBRAIC(:,30) = CONSTANTS(:,45)./(ALGEBRAIC(:,8)+CONSTANTS(:,45));
ALGEBRAIC(:,33) = ALGEBRAIC(:,8)./(ALGEBRAIC(:,8)+CONSTANTS(:,45));
ALGEBRAIC(:,36) = CONSTANTS(:,46)./(ALGEBRAIC(:,9)+CONSTANTS(:,46));
ALGEBRAIC(:,39) = ALGEBRAIC(:,9)./(ALGEBRAIC(:,9)+CONSTANTS(:,46));
ALGEBRAIC(:,42) = (((((((1.00000 - ALGEBRAIC(:,25)) - ALGEBRAIC(:,26)) - ALGEBRAIC(:,27)) - ALGEBRAIC(:,28)) - ALGEBRAIC(:,30)) - ALGEBRAIC(:,36)) - ALGEBRAIC(:,33)) - ALGEBRAIC(:,39);
end

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

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

Source
Derived from workspace Hinch, Greenstein, Tanskanen, Xu, Winslow, 2004 at changeset a1dd1cd2d20a.
Collaboration
To begin collaborating on this work, please use your git client and issue this command: