# 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 =42;
end
% There are a total of 27 entries in each of the rate and state variable arrays.
% There are a total of 64 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 (second)');
LEGEND_CONSTANTS(:,1) = strpad('O2_x in component Environment (molar)');
LEGEND_CONSTANTS(:,2) = strpad('X_AtC in component Environment (mole_per_second_per_l_cell)');
LEGEND_CONSTANTS(:,3) = strpad('RT in component fixed_parameters (kilojoule_per_mole)');
LEGEND_CONSTANTS(:,4) = strpad('F in component fixed_parameters (kilojoule_per_mole_per_millivolt)');
LEGEND_CONSTANTS(:,5) = strpad('dG_C1o in component fixed_parameters (kilojoule_per_mole)');
LEGEND_CONSTANTS(:,6) = strpad('dG_C3o in component fixed_parameters (kilojoule_per_mole)');
LEGEND_CONSTANTS(:,7) = strpad('dG_C4o in component fixed_parameters (kilojoule_per_mole)');
LEGEND_ALGEBRAIC(:,14) = strpad('dG_C1op in component fixed_parameters (kilojoule_per_mole)');
LEGEND_ALGEBRAIC(:,15) = strpad('dG_C3op in component fixed_parameters (kilojoule_per_mole)');
LEGEND_ALGEBRAIC(:,16) = strpad('dG_C4op in component fixed_parameters (kilojoule_per_mole)');
LEGEND_CONSTANTS(:,8) = strpad('dG_F1o in component fixed_parameters (kilojoule_per_mole)');
LEGEND_ALGEBRAIC(:,12) = strpad('dG_H in component fixed_parameters (kilojoule_per_mole)');
LEGEND_CONSTANTS(:,51) = strpad('k_dHPI in component fixed_parameters (molar)');
LEGEND_CONSTANTS(:,52) = strpad('k_dHatp in component fixed_parameters (molar)');
LEGEND_CONSTANTS(:,53) = strpad('k_dHadp in component fixed_parameters (molar)');
LEGEND_CONSTANTS(:,9) = strpad('K_DT in component fixed_parameters (molar)');
LEGEND_CONSTANTS(:,10) = strpad('K_DD in component fixed_parameters (molar)');
LEGEND_CONSTANTS(:,11) = strpad('K_AK in component fixed_parameters (dimensionless)');
LEGEND_CONSTANTS(:,12) = strpad('K_CK in component fixed_parameters (per_molar)');
LEGEND_CONSTANTS(:,57) = strpad('W_m in component fixed_parameters (l_water_per_l_mito)');
LEGEND_CONSTANTS(:,60) = strpad('W_c in component fixed_parameters (l_water_per_l_cyto)');
LEGEND_CONSTANTS(:,58) = strpad('W_x in component fixed_parameters (l_water_per_l_mito)');
LEGEND_CONSTANTS(:,59) = strpad('W_i in component fixed_parameters (l_water_per_l_mito)');
LEGEND_CONSTANTS(:,13) = strpad('V_cyto in component fixed_parameters (cyto_per_cell)');
LEGEND_CONSTANTS(:,14) = strpad('V_mito in component fixed_parameters (mito_per_cell)');
LEGEND_CONSTANTS(:,62) = strpad('Rm_cyto in component fixed_parameters (mito_per_cyto)');
LEGEND_CONSTANTS(:,55) = strpad('Rm_cell in component fixed_parameters (mito_per_cell)');
LEGEND_CONSTANTS(:,63) = strpad('Rc_cell in component fixed_parameters (cyto_per_cell)');
LEGEND_CONSTANTS(:,15) = strpad('n_A in component fixed_parameters (dimensionless)');
LEGEND_CONSTANTS(:,16) = strpad('C_tot in component fixed_parameters (molar)');
LEGEND_CONSTANTS(:,17) = strpad('CR_tot in component fixed_parameters (molar)');
LEGEND_CONSTANTS(:,18) = strpad('Q_tot in component fixed_parameters (molar)');
LEGEND_CONSTANTS(:,19) = strpad('NAD_tot in component fixed_parameters (molar)');
LEGEND_CONSTANTS(:,20) = strpad('pH_C in component fixed_parameters (dimensionless)');
LEGEND_CONSTANTS(:,54) = strpad('H_c in component fixed_parameters (molar)');
LEGEND_CONSTANTS(:,21) = strpad('K_c in component fixed_parameters (molar)');
LEGEND_CONSTANTS(:,61) = strpad('H_i in component fixed_parameters (molar)');
LEGEND_CONSTANTS(:,56) = strpad('K_i in component fixed_parameters (molar)');
LEGEND_ALGEBRAIC(:,10) = strpad('H_x in component dH_x_dt (molar)');
LEGEND_STATES(:,1) = strpad('deltaPsi in component ddeltaPsi_dt (millivolt)');
LEGEND_CONSTANTS(:,22) = strpad('k_PI1 in component adjustable_parameters (molar)');
LEGEND_CONSTANTS(:,23) = strpad('k_PI2 in component adjustable_parameters (molar)');
LEGEND_CONSTANTS(:,24) = strpad('k_PI3 in component adjustable_parameters (molar)');
LEGEND_CONSTANTS(:,25) = strpad('k_PI4 in component adjustable_parameters (molar)');
LEGEND_CONSTANTS(:,26) = strpad('k_PIH in component adjustable_parameters (molar)');
LEGEND_CONSTANTS(:,27) = strpad('r in component adjustable_parameters (dimensionless)');
LEGEND_CONSTANTS(:,28) = strpad('X_DH in component adjustable_parameters (mole_per_second_per_l_mito_per_molar)');
LEGEND_CONSTANTS(:,29) = strpad('X_C1 in component adjustable_parameters (mole_per_second_per_l_mito_per_molar_per_molar)');
LEGEND_CONSTANTS(:,30) = strpad('X_C3 in component adjustable_parameters (mole_per_second_per_l_mito_per_molar_per_half_molar)');
LEGEND_CONSTANTS(:,31) = strpad('X_C4 in component adjustable_parameters (mole_per_second_per_l_mito_per_molar)');
LEGEND_CONSTANTS(:,32) = strpad('X_F1 in component adjustable_parameters (mole_per_second_per_l_mito_per_molar_per_molar)');
LEGEND_CONSTANTS(:,33) = strpad('X_ANT in component adjustable_parameters (mole_per_second_per_l_mito)');
LEGEND_CONSTANTS(:,34) = strpad('X_PI1 in component adjustable_parameters (mole_per_second_per_l_mito_per_molar)');
LEGEND_CONSTANTS(:,35) = strpad('X_KH in component adjustable_parameters (mole_per_second_per_l_mito_per_molar_per_molar)');
LEGEND_CONSTANTS(:,36) = strpad('X_Hle in component adjustable_parameters (mole_per_second_per_l_mito_per_molar_per_millivolt)');
LEGEND_CONSTANTS(:,37) = strpad('X_K in component adjustable_parameters (mole_per_second_per_l_mito_per_molar_per_millivolt)');
LEGEND_CONSTANTS(:,38) = strpad('k_mADP in component adjustable_parameters (molar)');
LEGEND_CONSTANTS(:,39) = strpad('X_AK in component adjustable_parameters (mole_per_second_per_l_mito_per_molar_per_molar)');
LEGEND_CONSTANTS(:,40) = strpad('X_CK in component adjustable_parameters (mole_per_second_per_l_mito_per_molar_per_molar)');
LEGEND_CONSTANTS(:,41) = strpad('X_MgA in component adjustable_parameters (mole_per_second_per_l_mito_per_molar_per_molar)');
LEGEND_CONSTANTS(:,42) = strpad('k_O2 in component adjustable_parameters (molar)');
LEGEND_CONSTANTS(:,43) = strpad('x_buff in component adjustable_parameters (per_molar)');
LEGEND_CONSTANTS(:,44) = strpad('C_IM in component adjustable_parameters (mole_per_l_mito_per_millivolt)');
LEGEND_CONSTANTS(:,45) = strpad('X_A in component adjustable_parameters (micron_per_second)');
LEGEND_CONSTANTS(:,46) = strpad('X_PI2 in component adjustable_parameters (micron_per_second)');
LEGEND_CONSTANTS(:,47) = strpad('gamma in component adjustable_parameters (per_micron)');
LEGEND_ALGEBRAIC(:,1) = strpad('NAD_x in component dNAD_x_dt (molar)');
LEGEND_STATES(:,2) = strpad('NADH_x in component dNADH_x_dt (molar)');
LEGEND_ALGEBRAIC(:,3) = strpad('QH2_x in component dQH2_x_dt (molar)');
LEGEND_STATES(:,3) = strpad('Q_x in component dQ_x_dt (molar)');
LEGEND_ALGEBRAIC(:,5) = strpad('Cred_x in component dCred_x_dt (molar)');
LEGEND_STATES(:,4) = strpad('Cox_x in component dCox_x_dt (molar)');
LEGEND_ALGEBRAIC(:,7) = strpad('ATP_fx in component dATP_fx_dt (molar)');
LEGEND_STATES(:,5) = strpad('ATP_x in component dATP_x_dt (molar)');
LEGEND_STATES(:,6) = strpad('ATP_mx in component dATP_mx_dt (molar)');
LEGEND_ALGEBRAIC(:,9) = strpad('ADP_fx in component dADP_fx_dt (molar)');
LEGEND_STATES(:,7) = strpad('ADP_x in component dADP_x_dt (molar)');
LEGEND_STATES(:,8) = strpad('ADP_mx in component dADP_mx_dt (molar)');
LEGEND_STATES(:,9) = strpad('pH_x in component dH_x_dt (dimensionless)');
LEGEND_ALGEBRAIC(:,21) = strpad('J_DH in component J_DH (mole_per_second_per_l_mito)');
LEGEND_ALGEBRAIC(:,23) = strpad('J_C1 in component J_C1 (mole_per_second_per_l_mito)');
LEGEND_ALGEBRAIC(:,24) = strpad('J_C3 in component J_C3 (mole_per_second_per_l_mito)');
LEGEND_ALGEBRAIC(:,25) = strpad('J_C4 in component J_C4 (mole_per_second_per_l_mito)');
LEGEND_ALGEBRAIC(:,26) = strpad('J_F1 in component J_F1 (mole_per_second_per_l_mito)');
LEGEND_ALGEBRAIC(:,34) = strpad('J_PI1 in component J_PI1 (mole_per_second_per_l_mito)');
LEGEND_ALGEBRAIC(:,40) = strpad('J_KH in component J_KH (mole_per_second_per_l_mito)');
LEGEND_ALGEBRAIC(:,36) = strpad('J_Hle in component J_Hle (mole_per_second_per_l_mito)');
LEGEND_STATES(:,10) = strpad('K_x in component dK_x_dt (molar)');
LEGEND_ALGEBRAIC(:,42) = strpad('J_K in component J_K (mole_per_second_per_l_mito)');
LEGEND_STATES(:,11) = strpad('Mg_x in component dMg_x_dt (molar)');
LEGEND_ALGEBRAIC(:,11) = strpad('J_MgATP_x in component J_MgATP_x (mole_per_second_per_l_mito)');
LEGEND_ALGEBRAIC(:,13) = strpad('J_MgADP_x in component J_MgADP_x (mole_per_second_per_l_mito)');
LEGEND_ALGEBRAIC(:,29) = strpad('J_ANT in component J_ANT (mole_per_second_per_l_mito)');
LEGEND_STATES(:,12) = strpad('PI_x in component dPI_x_dt (molar)');
LEGEND_ALGEBRAIC(:,17) = strpad('ATP_fi in component dATP_fi_dt (molar)');
LEGEND_STATES(:,13) = strpad('ATP_i in component dATP_i_dt (molar)');
LEGEND_STATES(:,14) = strpad('ATP_mi in component dATP_mi_dt (molar)');
LEGEND_ALGEBRAIC(:,18) = strpad('ADP_fi in component dADP_fi_dt (molar)');
LEGEND_STATES(:,15) = strpad('ADP_i in component dADP_i_dt (molar)');
LEGEND_STATES(:,16) = strpad('ADP_mi in component dADP_mi_dt (molar)');
LEGEND_ALGEBRAIC(:,35) = strpad('J_ATP in component J_ATP (mole_per_second_per_l_mito)');
LEGEND_ALGEBRAIC(:,37) = strpad('J_AKi in component J_AKi (mole_per_second_per_l_mito)');
LEGEND_ALGEBRAIC(:,33) = strpad('J_ADP in component J_ADP (mole_per_second_per_l_mito)');
LEGEND_STATES(:,17) = strpad('AMP_i in component dAMP_i_dt (molar)');
LEGEND_ALGEBRAIC(:,31) = strpad('J_AMP in component J_AMP (mole_per_second_per_l_mito)');
LEGEND_ALGEBRAIC(:,20) = strpad('J_MgATP_i in component J_MgATP_i (mole_per_second_per_l_mito)');
LEGEND_ALGEBRAIC(:,22) = strpad('J_MgADP_i in component J_MgADP_i (mole_per_second_per_l_mito)');
LEGEND_STATES(:,18) = strpad('PI_i in component dPI_i_dt (molar)');
LEGEND_ALGEBRAIC(:,38) = strpad('J_PI2 in component J_PI2 (mole_per_second_per_l_mito)');
LEGEND_STATES(:,19) = strpad('Mg_i in component dMg_i_dt (molar)');
LEGEND_STATES(:,20) = strpad('ATP_c in component dATP_c_dt (molar)');
LEGEND_ALGEBRAIC(:,39) = strpad('J_AKc in component J_AKc (mole_per_second_per_l_cyto)');
LEGEND_CONSTANTS(:,64) = strpad('J_AtC in component J_AtC (mole_per_second_per_l_cell)');
LEGEND_ALGEBRAIC(:,41) = strpad('J_CKc in component J_CKc (mole_per_second_per_l_cyto)');
LEGEND_STATES(:,21) = strpad('ADP_c in component dADP_c_dt (molar)');
LEGEND_STATES(:,22) = strpad('AMP_c in component dAMP_c_dt (molar)');
LEGEND_STATES(:,23) = strpad('ATP_mc in component dATP_mc_dt (molar)');
LEGEND_ALGEBRAIC(:,6) = strpad('J_MgATP_c in component J_MgATP_c (mole_per_second_per_l_cyto)');
LEGEND_STATES(:,24) = strpad('ADP_mc in component dADP_mc_dt (molar)');
LEGEND_ALGEBRAIC(:,8) = strpad('J_MgADP_c in component J_MgADP_c (mole_per_second_per_l_cyto)');
LEGEND_STATES(:,25) = strpad('PI_c in component dPI_c_dt (molar)');
LEGEND_STATES(:,26) = strpad('Mg_c in component dMg_c_dt (molar)');
LEGEND_STATES(:,27) = strpad('PCr_c in component dPCr_c_dt (molar)');
LEGEND_ALGEBRAIC(:,2) = strpad('ATP_fc in component dATP_fc_dt (molar)');
LEGEND_ALGEBRAIC(:,4) = strpad('ADP_fc in component dADP_fc_dt (molar)');
LEGEND_ALGEBRAIC(:,19) = strpad('Cr_c in component dCr_c_dt (molar)');
LEGEND_CONSTANTS(:,48) = strpad('mincon in component J_ANT (molar)');
LEGEND_ALGEBRAIC(:,27) = strpad('Psi_x in component J_ANT (millivolt)');
LEGEND_ALGEBRAIC(:,28) = strpad('Psi_i in component J_ANT (millivolt)');
LEGEND_ALGEBRAIC(:,30) = strpad('H2PIi in component J_PI1 (molar)');
LEGEND_ALGEBRAIC(:,32) = strpad('H2PIx in component J_PI1 (molar)');
LEGEND_CONSTANTS(:,49) = strpad('mincond in component J_Hle (millivolt)');
LEGEND_CONSTANTS(:,50) = strpad('mincond in component J_K (millivolt)');
LEGEND_RATES(:,9) = strpad('d/dt pH_x in component dH_x_dt (dimensionless)');
LEGEND_RATES(:,10) = strpad('d/dt K_x in component dK_x_dt (molar)');
LEGEND_RATES(:,11) = strpad('d/dt Mg_x in component dMg_x_dt (molar)');
LEGEND_RATES(:,2) = strpad('d/dt NADH_x in component dNADH_x_dt (molar)');
LEGEND_RATES(:,3) = strpad('d/dt Q_x in component dQ_x_dt (molar)');
LEGEND_RATES(:,4) = strpad('d/dt Cox_x in component dCox_x_dt (molar)');
LEGEND_RATES(:,5) = strpad('d/dt ATP_x in component dATP_x_dt (molar)');
LEGEND_RATES(:,7) = strpad('d/dt ADP_x in component dADP_x_dt (molar)');
LEGEND_RATES(:,6) = strpad('d/dt ATP_mx in component dATP_mx_dt (molar)');
LEGEND_RATES(:,8) = strpad('d/dt ADP_mx in component dADP_mx_dt (molar)');
LEGEND_RATES(:,12) = strpad('d/dt PI_x in component dPI_x_dt (molar)');
LEGEND_RATES(:,13) = strpad('d/dt ATP_i in component dATP_i_dt (molar)');
LEGEND_RATES(:,15) = strpad('d/dt ADP_i in component dADP_i_dt (molar)');
LEGEND_RATES(:,17) = strpad('d/dt AMP_i in component dAMP_i_dt (molar)');
LEGEND_RATES(:,14) = strpad('d/dt ATP_mi in component dATP_mi_dt (molar)');
LEGEND_RATES(:,16) = strpad('d/dt ADP_mi in component dADP_mi_dt (molar)');
LEGEND_RATES(:,18) = strpad('d/dt PI_i in component dPI_i_dt (molar)');
LEGEND_RATES(:,19) = strpad('d/dt Mg_i in component dMg_i_dt (molar)');
LEGEND_RATES(:,20) = strpad('d/dt ATP_c in component dATP_c_dt (molar)');
LEGEND_RATES(:,21) = strpad('d/dt ADP_c in component dADP_c_dt (molar)');
LEGEND_RATES(:,22) = strpad('d/dt AMP_c in component dAMP_c_dt (molar)');
LEGEND_RATES(:,23) = strpad('d/dt ATP_mc in component dATP_mc_dt (molar)');
LEGEND_RATES(:,24) = strpad('d/dt ADP_mc in component dADP_mc_dt (molar)');
LEGEND_RATES(:,25) = strpad('d/dt PI_c in component dPI_c_dt (molar)');
LEGEND_RATES(:,26) = strpad('d/dt Mg_c in component dMg_c_dt (molar)');
LEGEND_RATES(:,27) = strpad('d/dt PCr_c in component dPCr_c_dt (molar)');
LEGEND_RATES(:,1) = strpad('d/dt deltaPsi in component ddeltaPsi_dt (millivolt)');
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) = 3.48e-5;
CONSTANTS(:,2) = 0e-4;
CONSTANTS(:,3) = 2.5775;
CONSTANTS(:,4) = 0.096484;
CONSTANTS(:,5) = -69.37;
CONSTANTS(:,6) = -32.53;
CONSTANTS(:,7) = -122.94;
CONSTANTS(:,8) = 36.03;
CONSTANTS(:,9) = 24e-6;
CONSTANTS(:,10) = 347e-6;
CONSTANTS(:,11) = 0.4331;
CONSTANTS(:,12) = 1.66e9;
CONSTANTS(:,13) = 0.894;
CONSTANTS(:,14) = 0.056;
CONSTANTS(:,15) = 3;
CONSTANTS(:,16) = 2.7e-3;
CONSTANTS(:,17) = 42.7e-3;
CONSTANTS(:,18) = 1.35e-3;
CONSTANTS(:,19) = 2.97e-3;
CONSTANTS(:,20) = 7;
CONSTANTS(:,21) = 0.15;
STATES(:,1) = 166.67;
CONSTANTS(:,22) = 0.1553e-3;
CONSTANTS(:,23) = 0.8222e-3;
CONSTANTS(:,24) = 0.3601e-3;
CONSTANTS(:,25) = 5.651e-3;
CONSTANTS(:,26) = 2.542e-4;
CONSTANTS(:,27) = 4.559;
CONSTANTS(:,28) = 0.0866;
CONSTANTS(:,29) = 4.405e3;
CONSTANTS(:,30) = 4.887;
CONSTANTS(:,31) = 6.766e-5;
CONSTANTS(:,32) = 1e3;
CONSTANTS(:,33) = 8.123e-3;
CONSTANTS(:,34) = 3.85e5;
CONSTANTS(:,35) = 5.651e7;
CONSTANTS(:,36) = 200;
CONSTANTS(:,37) = 0;
CONSTANTS(:,38) = 3.5e-6;
CONSTANTS(:,39) = 1e7;
CONSTANTS(:,40) = 1e7;
CONSTANTS(:,41) = 1e7;
CONSTANTS(:,42) = 1.2e-4;
CONSTANTS(:,43) = 100;
CONSTANTS(:,44) = 6.75e-6;
CONSTANTS(:,45) = 85;
CONSTANTS(:,46) = 327;
CONSTANTS(:,47) = 5.99;
STATES(:,2) = 0.0015723;
STATES(:,3) = 6.75e-4;
STATES(:,4) = 1.35e-3;
STATES(:,5) = 0.0026657;
STATES(:,6) = 0.0026046;
STATES(:,7) = 0.0073343;
STATES(:,8) = 0.0054765;
STATES(:,9) = 7;
STATES(:,10) = 0.14661;
STATES(:,11) = 1.0229e-3;
STATES(:,12) = 1.72e-4;
STATES(:,13) = 0.0065339;
STATES(:,14) = 0.0063812;
STATES(:,15) = 6.5773e-5;
STATES(:,16) = 4.8866e-5;
STATES(:,17) = 2.8837e-7;
STATES(:,18) = 1.72e-4;
STATES(:,19) = 0.0010029;
STATES(:,20) = 0.0081312;
STATES(:,21) = 6.85e-5;
STATES(:,22) = 3.0911e-7;
STATES(:,23) = 0.0079786;
STATES(:,24) = 5.1958e-5;
STATES(:,25) = 8.7702e-3;
STATES(:,26) = 0.001003;
STATES(:,27) = 23.589e-3;
CONSTANTS(:,48) = 1e-9;
CONSTANTS(:,49) = 1e-6;
CONSTANTS(:,50) = 1e-6;
CONSTANTS(:,51) =  1.00000.*power(10.0000,  - 6.75000);
CONSTANTS(:,52) =  1.00000.*power(10.0000,  - 6.48000);
CONSTANTS(:,53) =  1.00000.*power(10.0000,  - 6.29000);
CONSTANTS(:,54) =  1.00000.*power(10.0000,  - CONSTANTS(:,20));
CONSTANTS(:,55) = CONSTANTS(:,14);
CONSTANTS(:,56) = CONSTANTS(:,21);
CONSTANTS(:,57) =  0.664000.*1.09000;
CONSTANTS(:,58) =  0.900000.*CONSTANTS(:,57);
CONSTANTS(:,59) =  0.100000.*CONSTANTS(:,57);
CONSTANTS(:,60) =  0.807000.*1.04400;
CONSTANTS(:,61) = CONSTANTS(:,54);
CONSTANTS(:,62) = CONSTANTS(:,14)./CONSTANTS(:,13);
CONSTANTS(:,63) = CONSTANTS(:,13);
CONSTANTS(:,64) = CONSTANTS(:,2);
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(:,2) = STATES(:,20) - STATES(:,23);
ALGEBRAIC(:,6) =  CONSTANTS(:,41).*1.00000.*( ALGEBRAIC(:,2).*STATES(:,26) -  CONSTANTS(:,9).*STATES(:,23));
RATES(:,23) = ALGEBRAIC(:,6)./CONSTANTS(:,60);
ALGEBRAIC(:,4) = STATES(:,21) - STATES(:,24);
ALGEBRAIC(:,8) =  CONSTANTS(:,41).*1.00000.*( ALGEBRAIC(:,4).*STATES(:,26) -  CONSTANTS(:,10).*STATES(:,24));
RATES(:,24) = ALGEBRAIC(:,8)./CONSTANTS(:,60);
RATES(:,26) = ( - ALGEBRAIC(:,6) - ALGEBRAIC(:,8))./CONSTANTS(:,60);
ALGEBRAIC(:,7) = STATES(:,5) - STATES(:,6);
ALGEBRAIC(:,11) =  CONSTANTS(:,41).*( ALGEBRAIC(:,7).*STATES(:,11) -  CONSTANTS(:,9).*STATES(:,6));
RATES(:,6) = ALGEBRAIC(:,11)./CONSTANTS(:,58);
ALGEBRAIC(:,9) = STATES(:,7) - STATES(:,8);
ALGEBRAIC(:,13) =  CONSTANTS(:,41).*( ALGEBRAIC(:,9).*STATES(:,11) -  CONSTANTS(:,10).*STATES(:,8));
RATES(:,11) = ( - ALGEBRAIC(:,13) - ALGEBRAIC(:,11))./CONSTANTS(:,58);
RATES(:,8) = ALGEBRAIC(:,13)./CONSTANTS(:,58);
ALGEBRAIC(:,17) = STATES(:,13) - STATES(:,14);
ALGEBRAIC(:,20) =  CONSTANTS(:,41).*( ALGEBRAIC(:,17).*STATES(:,19) -  CONSTANTS(:,9).*STATES(:,14));
RATES(:,14) = ALGEBRAIC(:,20)./CONSTANTS(:,59);
ALGEBRAIC(:,18) = STATES(:,15) - STATES(:,16);
ALGEBRAIC(:,22) =  CONSTANTS(:,41).*( ALGEBRAIC(:,18).*STATES(:,19) -  CONSTANTS(:,10).*STATES(:,16));
RATES(:,16) = ALGEBRAIC(:,22)./CONSTANTS(:,59);
RATES(:,19) = ( - ALGEBRAIC(:,22) - ALGEBRAIC(:,20))./CONSTANTS(:,59);
ALGEBRAIC(:,1) = CONSTANTS(:,19) - STATES(:,2);
ALGEBRAIC(:,21) = ( CONSTANTS(:,28).*( CONSTANTS(:,27).*ALGEBRAIC(:,1) - STATES(:,2)).*(1.00000+STATES(:,12)./CONSTANTS(:,22)))./(1.00000+STATES(:,12)./CONSTANTS(:,23));
ALGEBRAIC(:,10) =  1.00000.*power(10.0000,  - STATES(:,9));
ALGEBRAIC(:,14) = CONSTANTS(:,5) -  1.00000.*CONSTANTS(:,3).*log(ALGEBRAIC(:,10)./1.00000e-07);
ALGEBRAIC(:,12) =  CONSTANTS(:,4).*STATES(:,1)+ CONSTANTS(:,3).*log(CONSTANTS(:,61)./ALGEBRAIC(:,10));
ALGEBRAIC(:,3) = CONSTANTS(:,18) - STATES(:,3);
ALGEBRAIC(:,23) =  CONSTANTS(:,29).*( exp( - (ALGEBRAIC(:,14)+ 4.00000.*ALGEBRAIC(:,12))./CONSTANTS(:,3)).*STATES(:,2).*STATES(:,3) -  ALGEBRAIC(:,1).*ALGEBRAIC(:,3));
RATES(:,2) = (ALGEBRAIC(:,21) - ALGEBRAIC(:,23))./CONSTANTS(:,58);
ALGEBRAIC(:,15) = CONSTANTS(:,6)+ 2.00000.*CONSTANTS(:,3).*log(ALGEBRAIC(:,10)./1.00000e-07);
ALGEBRAIC(:,5) = CONSTANTS(:,16) - STATES(:,4);
ALGEBRAIC(:,24) =  (( CONSTANTS(:,30).*(1.00000+STATES(:,12)./CONSTANTS(:,24)))./(1.00000+STATES(:,12)./CONSTANTS(:,25))).*( exp( - ((ALGEBRAIC(:,15)+ 4.00000.*ALGEBRAIC(:,12)) -  2.00000.*CONSTANTS(:,4).*STATES(:,1))./( 2.00000.*CONSTANTS(:,3))).*STATES(:,4).*power(ALGEBRAIC(:,3), 1.0 ./ 2) -  ALGEBRAIC(:,5).*power(STATES(:,3), 1.0 ./ 2));
RATES(:,3) =  - (ALGEBRAIC(:,23) - ALGEBRAIC(:,24))./CONSTANTS(:,58);
ALGEBRAIC(:,16) = CONSTANTS(:,7) -  2.00000.*CONSTANTS(:,3).*log(ALGEBRAIC(:,10)./1.00000e-07);
ALGEBRAIC(:,25) = piecewise({CONSTANTS(:,1)<1.00000e-12, 0.00000 },  (( CONSTANTS(:,31).*CONSTANTS(:,1))./(CONSTANTS(:,1)+CONSTANTS(:,42))).*(ALGEBRAIC(:,5)./CONSTANTS(:,16)).*( exp( - (ALGEBRAIC(:,16)+ 2.00000.*ALGEBRAIC(:,12))./( 2.00000.*CONSTANTS(:,3))).*ALGEBRAIC(:,5).*power(CONSTANTS(:,1)./1.00000, 0.250000) -  STATES(:,4).*exp(( CONSTANTS(:,4).*STATES(:,1))./CONSTANTS(:,3))));
RATES(:,4) =  - ( 2.00000.*ALGEBRAIC(:,24) -  2.00000.*ALGEBRAIC(:,25))./CONSTANTS(:,58);
ALGEBRAIC(:,26) =  CONSTANTS(:,32).*( (( exp( - (CONSTANTS(:,8) -  CONSTANTS(:,15).*ALGEBRAIC(:,12))./CONSTANTS(:,3)).*CONSTANTS(:,10))./CONSTANTS(:,9)).*STATES(:,8).*STATES(:,12) -  STATES(:,6).*1.00000);
ALGEBRAIC(:,27) =   - 0.650000.*STATES(:,1);
ALGEBRAIC(:,28) =  0.350000.*STATES(:,1);
ALGEBRAIC(:,29) = piecewise({ALGEBRAIC(:,18)>CONSTANTS(:,48)||ALGEBRAIC(:,17)>CONSTANTS(:,48),  CONSTANTS(:,33).*(ALGEBRAIC(:,18)./(ALGEBRAIC(:,18)+ ALGEBRAIC(:,17).*exp((  - CONSTANTS(:,4).*ALGEBRAIC(:,28))./CONSTANTS(:,3))) - ALGEBRAIC(:,9)./(ALGEBRAIC(:,9)+ ALGEBRAIC(:,7).*exp((  - CONSTANTS(:,4).*ALGEBRAIC(:,27))./CONSTANTS(:,3)))).*(ALGEBRAIC(:,18)./(ALGEBRAIC(:,18)+CONSTANTS(:,38))) }, 0.00000);
RATES(:,5) = (ALGEBRAIC(:,26) - ALGEBRAIC(:,29))./CONSTANTS(:,58);
RATES(:,7) = ( - ALGEBRAIC(:,26)+ALGEBRAIC(:,29))./CONSTANTS(:,58);
ALGEBRAIC(:,30) = ( STATES(:,18).*CONSTANTS(:,61))./(CONSTANTS(:,61)+CONSTANTS(:,51));
ALGEBRAIC(:,32) = ( STATES(:,12).*ALGEBRAIC(:,10))./(ALGEBRAIC(:,10)+CONSTANTS(:,51));
ALGEBRAIC(:,34) = ( CONSTANTS(:,34).*( CONSTANTS(:,61).*ALGEBRAIC(:,30) -  ALGEBRAIC(:,10).*ALGEBRAIC(:,32)))./(ALGEBRAIC(:,30)+CONSTANTS(:,26));
RATES(:,12) = ( - ALGEBRAIC(:,26)+ALGEBRAIC(:,34))./CONSTANTS(:,58);
ALGEBRAIC(:,35) =  CONSTANTS(:,47).*CONSTANTS(:,45).*(STATES(:,20) - STATES(:,13));
ALGEBRAIC(:,37) =  CONSTANTS(:,39).*( CONSTANTS(:,11).*STATES(:,15).*STATES(:,15) -  STATES(:,17).*STATES(:,13));
RATES(:,13) = (ALGEBRAIC(:,35)+ALGEBRAIC(:,29)+ALGEBRAIC(:,37))./CONSTANTS(:,59);
ALGEBRAIC(:,33) =  CONSTANTS(:,47).*CONSTANTS(:,45).*(STATES(:,21) - STATES(:,15));
RATES(:,15) = ((ALGEBRAIC(:,33) - ALGEBRAIC(:,29)) -  2.00000.*ALGEBRAIC(:,37))./CONSTANTS(:,59);
ALGEBRAIC(:,31) =  CONSTANTS(:,47).*CONSTANTS(:,45).*(STATES(:,22) - STATES(:,17));
RATES(:,17) = (ALGEBRAIC(:,31)+ALGEBRAIC(:,37))./CONSTANTS(:,59);
ALGEBRAIC(:,38) =  CONSTANTS(:,47).*CONSTANTS(:,46).*(STATES(:,25) - STATES(:,18));
RATES(:,18) = ( - ALGEBRAIC(:,34)+ALGEBRAIC(:,38))./CONSTANTS(:,59);
ALGEBRAIC(:,39) =  CONSTANTS(:,39).*1.00000.*( CONSTANTS(:,11).*STATES(:,21).*STATES(:,21) -  STATES(:,22).*STATES(:,20));
RATES(:,22) = (  - CONSTANTS(:,62).*ALGEBRAIC(:,31)+ALGEBRAIC(:,39))./CONSTANTS(:,60);
RATES(:,25) = (  - ALGEBRAIC(:,38).*CONSTANTS(:,62)+CONSTANTS(:,64)./CONSTANTS(:,63))./CONSTANTS(:,60);
ALGEBRAIC(:,40) =  CONSTANTS(:,35).*( CONSTANTS(:,56).*ALGEBRAIC(:,10) -  STATES(:,10).*CONSTANTS(:,61));
ALGEBRAIC(:,36) = piecewise({abs(STATES(:,1))>CONSTANTS(:,49), ( CONSTANTS(:,36).*STATES(:,1).*( CONSTANTS(:,61).*exp(( CONSTANTS(:,4).*STATES(:,1))./CONSTANTS(:,3)) - ALGEBRAIC(:,10)))./(exp(( CONSTANTS(:,4).*STATES(:,1))./CONSTANTS(:,3)) - 1.00000) }, ( CONSTANTS(:,36).*CONSTANTS(:,3).*(CONSTANTS(:,61) - ALGEBRAIC(:,10)))./CONSTANTS(:,4));
RATES(:,9) = ( ( - 1.00000./2.30300).*CONSTANTS(:,43).*((((((ALGEBRAIC(:,21) -  5.00000.*ALGEBRAIC(:,23)) -  2.00000.*ALGEBRAIC(:,24)) -  4.00000.*ALGEBRAIC(:,25))+ (CONSTANTS(:,15) - 1.00000).*ALGEBRAIC(:,26)+ 2.00000.*ALGEBRAIC(:,34)) - ALGEBRAIC(:,40))+ALGEBRAIC(:,36)))./CONSTANTS(:,58);
ALGEBRAIC(:,19) = CONSTANTS(:,17) - STATES(:,27);
ALGEBRAIC(:,41) =  CONSTANTS(:,40).*1.00000.*( CONSTANTS(:,12).*STATES(:,21).*STATES(:,27).*CONSTANTS(:,54) -  STATES(:,20).*ALGEBRAIC(:,19));
RATES(:,20) = (((  - CONSTANTS(:,62).*ALGEBRAIC(:,35)+ALGEBRAIC(:,39)) - CONSTANTS(:,64)./CONSTANTS(:,63))+ALGEBRAIC(:,41))./CONSTANTS(:,60);
RATES(:,21) = (((  - CONSTANTS(:,62).*ALGEBRAIC(:,33) -  2.00000.*ALGEBRAIC(:,39))+CONSTANTS(:,64)./CONSTANTS(:,63)) - ALGEBRAIC(:,41))./CONSTANTS(:,60);
RATES(:,27) =  - ALGEBRAIC(:,41)./CONSTANTS(:,60);
ALGEBRAIC(:,42) = piecewise({abs(STATES(:,1))>CONSTANTS(:,50), ( CONSTANTS(:,37).*STATES(:,1).*( CONSTANTS(:,56).*exp(( CONSTANTS(:,4).*STATES(:,1))./CONSTANTS(:,3)) - STATES(:,10)))./(exp(( CONSTANTS(:,4).*STATES(:,1))./CONSTANTS(:,3)) - 1.00000) }, ( CONSTANTS(:,37).*CONSTANTS(:,3).*(CONSTANTS(:,56) - STATES(:,10)))./CONSTANTS(:,4));
RATES(:,10) = (ALGEBRAIC(:,40)+ALGEBRAIC(:,42))./CONSTANTS(:,58);
RATES(:,1) = ((((( 4.00000.*ALGEBRAIC(:,23)+ 2.00000.*ALGEBRAIC(:,24)+ 4.00000.*ALGEBRAIC(:,25)) -  CONSTANTS(:,15).*ALGEBRAIC(:,26)) - ALGEBRAIC(:,29)) - ALGEBRAIC(:,36)) - ALGEBRAIC(:,42))./CONSTANTS(:,44);
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(:,2) = STATES(:,20) - STATES(:,23);
ALGEBRAIC(:,6) =  CONSTANTS(:,41).*1.00000.*( ALGEBRAIC(:,2).*STATES(:,26) -  CONSTANTS(:,9).*STATES(:,23));
ALGEBRAIC(:,4) = STATES(:,21) - STATES(:,24);
ALGEBRAIC(:,8) =  CONSTANTS(:,41).*1.00000.*( ALGEBRAIC(:,4).*STATES(:,26) -  CONSTANTS(:,10).*STATES(:,24));
ALGEBRAIC(:,7) = STATES(:,5) - STATES(:,6);
ALGEBRAIC(:,11) =  CONSTANTS(:,41).*( ALGEBRAIC(:,7).*STATES(:,11) -  CONSTANTS(:,9).*STATES(:,6));
ALGEBRAIC(:,9) = STATES(:,7) - STATES(:,8);
ALGEBRAIC(:,13) =  CONSTANTS(:,41).*( ALGEBRAIC(:,9).*STATES(:,11) -  CONSTANTS(:,10).*STATES(:,8));
ALGEBRAIC(:,17) = STATES(:,13) - STATES(:,14);
ALGEBRAIC(:,20) =  CONSTANTS(:,41).*( ALGEBRAIC(:,17).*STATES(:,19) -  CONSTANTS(:,9).*STATES(:,14));
ALGEBRAIC(:,18) = STATES(:,15) - STATES(:,16);
ALGEBRAIC(:,22) =  CONSTANTS(:,41).*( ALGEBRAIC(:,18).*STATES(:,19) -  CONSTANTS(:,10).*STATES(:,16));
ALGEBRAIC(:,1) = CONSTANTS(:,19) - STATES(:,2);
ALGEBRAIC(:,21) = ( CONSTANTS(:,28).*( CONSTANTS(:,27).*ALGEBRAIC(:,1) - STATES(:,2)).*(1.00000+STATES(:,12)./CONSTANTS(:,22)))./(1.00000+STATES(:,12)./CONSTANTS(:,23));
ALGEBRAIC(:,10) =  1.00000.*power(10.0000,  - STATES(:,9));
ALGEBRAIC(:,14) = CONSTANTS(:,5) -  1.00000.*CONSTANTS(:,3).*log(ALGEBRAIC(:,10)./1.00000e-07);
ALGEBRAIC(:,12) =  CONSTANTS(:,4).*STATES(:,1)+ CONSTANTS(:,3).*log(CONSTANTS(:,61)./ALGEBRAIC(:,10));
ALGEBRAIC(:,3) = CONSTANTS(:,18) - STATES(:,3);
ALGEBRAIC(:,23) =  CONSTANTS(:,29).*( exp( - (ALGEBRAIC(:,14)+ 4.00000.*ALGEBRAIC(:,12))./CONSTANTS(:,3)).*STATES(:,2).*STATES(:,3) -  ALGEBRAIC(:,1).*ALGEBRAIC(:,3));
ALGEBRAIC(:,15) = CONSTANTS(:,6)+ 2.00000.*CONSTANTS(:,3).*log(ALGEBRAIC(:,10)./1.00000e-07);
ALGEBRAIC(:,5) = CONSTANTS(:,16) - STATES(:,4);
ALGEBRAIC(:,24) =  (( CONSTANTS(:,30).*(1.00000+STATES(:,12)./CONSTANTS(:,24)))./(1.00000+STATES(:,12)./CONSTANTS(:,25))).*( exp( - ((ALGEBRAIC(:,15)+ 4.00000.*ALGEBRAIC(:,12)) -  2.00000.*CONSTANTS(:,4).*STATES(:,1))./( 2.00000.*CONSTANTS(:,3))).*STATES(:,4).*power(ALGEBRAIC(:,3), 1.0 ./ 2) -  ALGEBRAIC(:,5).*power(STATES(:,3), 1.0 ./ 2));
ALGEBRAIC(:,16) = CONSTANTS(:,7) -  2.00000.*CONSTANTS(:,3).*log(ALGEBRAIC(:,10)./1.00000e-07);
ALGEBRAIC(:,25) = piecewise({CONSTANTS(:,1)<1.00000e-12, 0.00000 },  (( CONSTANTS(:,31).*CONSTANTS(:,1))./(CONSTANTS(:,1)+CONSTANTS(:,42))).*(ALGEBRAIC(:,5)./CONSTANTS(:,16)).*( exp( - (ALGEBRAIC(:,16)+ 2.00000.*ALGEBRAIC(:,12))./( 2.00000.*CONSTANTS(:,3))).*ALGEBRAIC(:,5).*power(CONSTANTS(:,1)./1.00000, 0.250000) -  STATES(:,4).*exp(( CONSTANTS(:,4).*STATES(:,1))./CONSTANTS(:,3))));
ALGEBRAIC(:,26) =  CONSTANTS(:,32).*( (( exp( - (CONSTANTS(:,8) -  CONSTANTS(:,15).*ALGEBRAIC(:,12))./CONSTANTS(:,3)).*CONSTANTS(:,10))./CONSTANTS(:,9)).*STATES(:,8).*STATES(:,12) -  STATES(:,6).*1.00000);
ALGEBRAIC(:,27) =   - 0.650000.*STATES(:,1);
ALGEBRAIC(:,28) =  0.350000.*STATES(:,1);
ALGEBRAIC(:,29) = piecewise({ALGEBRAIC(:,18)>CONSTANTS(:,48)||ALGEBRAIC(:,17)>CONSTANTS(:,48),  CONSTANTS(:,33).*(ALGEBRAIC(:,18)./(ALGEBRAIC(:,18)+ ALGEBRAIC(:,17).*exp((  - CONSTANTS(:,4).*ALGEBRAIC(:,28))./CONSTANTS(:,3))) - ALGEBRAIC(:,9)./(ALGEBRAIC(:,9)+ ALGEBRAIC(:,7).*exp((  - CONSTANTS(:,4).*ALGEBRAIC(:,27))./CONSTANTS(:,3)))).*(ALGEBRAIC(:,18)./(ALGEBRAIC(:,18)+CONSTANTS(:,38))) }, 0.00000);
ALGEBRAIC(:,30) = ( STATES(:,18).*CONSTANTS(:,61))./(CONSTANTS(:,61)+CONSTANTS(:,51));
ALGEBRAIC(:,32) = ( STATES(:,12).*ALGEBRAIC(:,10))./(ALGEBRAIC(:,10)+CONSTANTS(:,51));
ALGEBRAIC(:,34) = ( CONSTANTS(:,34).*( CONSTANTS(:,61).*ALGEBRAIC(:,30) -  ALGEBRAIC(:,10).*ALGEBRAIC(:,32)))./(ALGEBRAIC(:,30)+CONSTANTS(:,26));
ALGEBRAIC(:,35) =  CONSTANTS(:,47).*CONSTANTS(:,45).*(STATES(:,20) - STATES(:,13));
ALGEBRAIC(:,37) =  CONSTANTS(:,39).*( CONSTANTS(:,11).*STATES(:,15).*STATES(:,15) -  STATES(:,17).*STATES(:,13));
ALGEBRAIC(:,33) =  CONSTANTS(:,47).*CONSTANTS(:,45).*(STATES(:,21) - STATES(:,15));
ALGEBRAIC(:,31) =  CONSTANTS(:,47).*CONSTANTS(:,45).*(STATES(:,22) - STATES(:,17));
ALGEBRAIC(:,38) =  CONSTANTS(:,47).*CONSTANTS(:,46).*(STATES(:,25) - STATES(:,18));
ALGEBRAIC(:,39) =  CONSTANTS(:,39).*1.00000.*( CONSTANTS(:,11).*STATES(:,21).*STATES(:,21) -  STATES(:,22).*STATES(:,20));
ALGEBRAIC(:,40) =  CONSTANTS(:,35).*( CONSTANTS(:,56).*ALGEBRAIC(:,10) -  STATES(:,10).*CONSTANTS(:,61));
ALGEBRAIC(:,36) = piecewise({abs(STATES(:,1))>CONSTANTS(:,49), ( CONSTANTS(:,36).*STATES(:,1).*( CONSTANTS(:,61).*exp(( CONSTANTS(:,4).*STATES(:,1))./CONSTANTS(:,3)) - ALGEBRAIC(:,10)))./(exp(( CONSTANTS(:,4).*STATES(:,1))./CONSTANTS(:,3)) - 1.00000) }, ( CONSTANTS(:,36).*CONSTANTS(:,3).*(CONSTANTS(:,61) - ALGEBRAIC(:,10)))./CONSTANTS(:,4));
ALGEBRAIC(:,19) = CONSTANTS(:,17) - STATES(:,27);
ALGEBRAIC(:,41) =  CONSTANTS(:,40).*1.00000.*( CONSTANTS(:,12).*STATES(:,21).*STATES(:,27).*CONSTANTS(:,54) -  STATES(:,20).*ALGEBRAIC(:,19));
ALGEBRAIC(:,42) = piecewise({abs(STATES(:,1))>CONSTANTS(:,50), ( CONSTANTS(:,37).*STATES(:,1).*( CONSTANTS(:,56).*exp(( CONSTANTS(:,4).*STATES(:,1))./CONSTANTS(:,3)) - STATES(:,10)))./(exp(( CONSTANTS(:,4).*STATES(:,1))./CONSTANTS(:,3)) - 1.00000) }, ( CONSTANTS(:,37).*CONSTANTS(:,3).*(CONSTANTS(:,56) - STATES(:,10)))./CONSTANTS(:,4));
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 Wu, Jeneson, Beard, 2006 at changeset 9588cf24ac8e.
Collaboration
To begin collaborating on this work, please use your git client and issue this command:
Downloads
Tools
License

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