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 =19;
end
% There are a total of 11 entries in each of the rate and state variable arrays.
% There are a total of 72 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 (minute)');
    LEGEND_CONSTANTS(:,1) = strpad('G_o in component G_o (millimolar)');
    LEGEND_STATES(:,1) = strpad('G in component G (millimolar)');
    LEGEND_ALGEBRAIC(:,4) = strpad('V_IN in component V_IN (flux)');
    LEGEND_ALGEBRAIC(:,5) = strpad('V_HK in component V_HK (flux)');
    LEGEND_STATES(:,2) = strpad('G6P in component G6P (millimolar)');
    LEGEND_ALGEBRAIC(:,6) = strpad('V_PFK in component V_PFK (flux)');
    LEGEND_ALGEBRAIC(:,9) = strpad('V_G6PDH in component V_G6PDH (flux)');
    LEGEND_STATES(:,3) = strpad('FDP in component FDP (millimolar)');
    LEGEND_ALGEBRAIC(:,8) = strpad('V_ALD in component V_ALD (flux)');
    LEGEND_STATES(:,4) = strpad('G3P in component G3P (millimolar)');
    LEGEND_ALGEBRAIC(:,10) = strpad('V_GAPDH in component V_GAPDH (flux)');
    LEGEND_STATES(:,5) = strpad('DPG in component DPG (millimolar)');
    LEGEND_ALGEBRAIC(:,11) = strpad('V_PGK in component V_PGK (flux)');
    LEGEND_STATES(:,6) = strpad('PEP in component PEP (millimolar)');
    LEGEND_ALGEBRAIC(:,16) = strpad('V_PK in component V_PK (flux)');
    LEGEND_STATES(:,7) = strpad('Py in component Py (millimolar)');
    LEGEND_ALGEBRAIC(:,17) = strpad('V_TCA in component V_TCA (flux)');
    LEGEND_ALGEBRAIC(:,18) = strpad('V_ADH in component V_ADH (flux)');
    LEGEND_STATES(:,8) = strpad('ATP in component ATP (millimolar)');
    LEGEND_CONSTANTS(:,2) = strpad('PO in component ATP (dimensionless)');
    LEGEND_ALGEBRAIC(:,19) = strpad('V_ATPase in component V_ATPase (flux)');
    LEGEND_ALGEBRAIC(:,1) = strpad('ADP in component ADP (millimolar)');
    LEGEND_CONSTANTS(:,3) = strpad('Cn in component ADP (millimolar)');
    LEGEND_CONSTANTS(:,4) = strpad('AMP in component AMP (millimolar)');
    LEGEND_CONSTANTS(:,5) = strpad('GTP in component GTP (millimolar)');
    LEGEND_CONSTANTS(:,6) = strpad('GDP in component GDP (millimolar)');
    LEGEND_CONSTANTS(:,7) = strpad('H in component H (millimolar)');
    LEGEND_CONSTANTS(:,8) = strpad('NADP in component NADP (millimolar)');
    LEGEND_CONSTANTS(:,9) = strpad('NADH in component NADH (millimolar)');
    LEGEND_CONSTANTS(:,10) = strpad('NAD in component NAD (millimolar)');
    LEGEND_ALGEBRAIC(:,3) = strpad('CD in component CD (millimolar)');
    LEGEND_CONSTANTS(:,11) = strpad('CMTP in component CD (millimolar)');
    LEGEND_STATES(:,9) = strpad('CT in component CT (millimolar)');
    LEGEND_STATES(:,10) = strpad('CP in component CP (millimolar)');
    LEGEND_CONSTANTS(:,12) = strpad('kpol in component CT (third_order_rate_constant)');
    LEGEND_CONSTANTS(:,13) = strpad('kf in component CT (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,14) = strpad('kb in component CT (second_order_rate_constant)');
    LEGEND_CONSTANTS(:,15) = strpad('kdp in component CP (first_order_rate_constant)');
    LEGEND_STATES(:,11) = strpad('PKp in component PKp (millimolar)');
    LEGEND_CONSTANTS(:,16) = strpad('kp2 in component PKp (second_order_rate_constant)');
    LEGEND_CONSTANTS(:,17) = strpad('kp3 in component PKp (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,18) = strpad('k4 in component PKp (second_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,2) = strpad('PKt in component PKt (millimolar)');
    LEGEND_CONSTANTS(:,19) = strpad('C_PK in component PKt (millimolar)');
    LEGEND_CONSTANTS(:,20) = strpad('Ke_in in component V_IN (millimolar)');
    LEGEND_CONSTANTS(:,21) = strpad('KG_in in component V_IN (millimolar)');
    LEGEND_CONSTANTS(:,22) = strpad('V_IN_max in component V_IN (flux)');
    LEGEND_CONSTANTS(:,23) = strpad('KG_m in component V_HK (millimolar)');
    LEGEND_CONSTANTS(:,24) = strpad('KG_s in component V_HK (millimolar)');
    LEGEND_CONSTANTS(:,25) = strpad('KATP_m in component V_HK (millimolar)');
    LEGEND_CONSTANTS(:,26) = strpad('V_HK_max in component V_HK (flux)');
    LEGEND_CONSTANTS(:,27) = strpad('KG6P_r in component V_PFK (millimolar)');
    LEGEND_CONSTANTS(:,28) = strpad('KATP_r in component V_PFK (millimolar)');
    LEGEND_CONSTANTS(:,29) = strpad('KAMP_r in component V_PFK (millimolar)');
    LEGEND_CONSTANTS(:,30) = strpad('cATP in component V_PFK (dimensionless)');
    LEGEND_CONSTANTS(:,31) = strpad('cAMP in component V_PFK (dimensionless)');
    LEGEND_CONSTANTS(:,32) = strpad('cG6P in component V_PFK (dimensionless)');
    LEGEND_CONSTANTS(:,33) = strpad('Lo in component V_PFK (dimensionless)');
    LEGEND_CONSTANTS(:,34) = strpad('gr in component V_PFK (dimensionless)');
    LEGEND_CONSTANTS(:,35) = strpad('n1 in component V_PFK (dimensionless)');
    LEGEND_CONSTANTS(:,36) = strpad('V_PFK_max in component V_PFK (flux)');
    LEGEND_ALGEBRAIC(:,7) = strpad('TUB in component V_G6PDH (millimolar)');
    LEGEND_CONSTANTS(:,37) = strpad('KG6P in component V_G6PDH (millimolar)');
    LEGEND_CONSTANTS(:,38) = strpad('KNADP in component V_G6PDH (millimolar)');
    LEGEND_CONSTANTS(:,39) = strpad('KNADP_ in component V_G6PDH (millimolar)');
    LEGEND_CONSTANTS(:,40) = strpad('KTUB in component V_G6PDH (millimolar)');
    LEGEND_CONSTANTS(:,41) = strpad('V_G6PDH_max in component V_G6PDH (flux)');
    LEGEND_CONSTANTS(:,42) = strpad('V_G6PDH_max_II in component V_G6PDH (flux)');
    LEGEND_CONSTANTS(:,43) = strpad('KG3P_m in component V_ALD (millimolar)');
    LEGEND_CONSTANTS(:,44) = strpad('KFDP_m in component V_ALD (millimolar)');
    LEGEND_CONSTANTS(:,45) = strpad('V_ALD_max in component V_ALD (flux)');
    LEGEND_CONSTANTS(:,46) = strpad('V_ALD_max_r in component V_ALD (flux)');
    LEGEND_CONSTANTS(:,47) = strpad('K1 in component V_GAPDH (millimolar)');
    LEGEND_CONSTANTS(:,48) = strpad('K2 in component V_GAPDH (millimolar)');
    LEGEND_CONSTANTS(:,49) = strpad('K3 in component V_GAPDH (millimolar)');
    LEGEND_CONSTANTS(:,50) = strpad('KG3P in component V_GAPDH (millimolar)');
    LEGEND_CONSTANTS(:,51) = strpad('KNAD in component V_GAPDH (millimolar)');
    LEGEND_CONSTANTS(:,52) = strpad('KNADH_i in component V_GAPDH (millimolar)');
    LEGEND_CONSTANTS(:,53) = strpad('V_GAPDH_max in component V_GAPDH (flux)');
    LEGEND_CONSTANTS(:,54) = strpad('KDPG_m in component V_PGK (millimolar)');
    LEGEND_CONSTANTS(:,55) = strpad('V_PGK_max in component V_PGK (flux)');
    LEGEND_ALGEBRAIC(:,12) = strpad('R in component V_PK (dimensionless)');
    LEGEND_ALGEBRAIC(:,13) = strpad('T in component V_PK (dimensionless)');
    LEGEND_CONSTANTS(:,56) = strpad('KpH in component V_PK (millimolar)');
    LEGEND_CONSTANTS(:,57) = strpad('KPEP_r in component V_PK (millimolar)');
    LEGEND_CONSTANTS(:,58) = strpad('KADP_r in component V_PK (millimolar)');
    LEGEND_CONSTANTS(:,59) = strpad('KFDP_r in component V_PK (millimolar)');
    LEGEND_CONSTANTS(:,60) = strpad('cADP in component V_PK (dimensionless)');
    LEGEND_CONSTANTS(:,61) = strpad('cFDP in component V_PK (dimensionless)');
    LEGEND_CONSTANTS(:,62) = strpad('cPEP in component V_PK (dimensionless)');
    LEGEND_CONSTANTS(:,63) = strpad('Lo_PK in component V_PK (dimensionless)');
    LEGEND_CONSTANTS(:,64) = strpad('gr_PK in component V_PK (dimensionless)');
    LEGEND_CONSTANTS(:,65) = strpad('gt_PK in component V_PK (dimensionless)');
    LEGEND_ALGEBRAIC(:,15) = strpad('n in component V_PK (dimensionless)');
    LEGEND_ALGEBRAIC(:,14) = strpad('V_PK_max in component V_PK (flux)');
    LEGEND_CONSTANTS(:,66) = strpad('V_PKt_max in component V_PK (flux)');
    LEGEND_CONSTANTS(:,67) = strpad('V_PKp_max in component V_PK (flux)');
    LEGEND_CONSTANTS(:,68) = strpad('KPy_m in component V_TCA (millimolar)');
    LEGEND_CONSTANTS(:,69) = strpad('V_TCA_max in component V_TCA (flux)');
    LEGEND_CONSTANTS(:,70) = strpad('KPy__m in component V_ADH (millimolar)');
    LEGEND_CONSTANTS(:,71) = strpad('V_ADH_max in component V_ADH (flux)');
    LEGEND_CONSTANTS(:,72) = strpad('KATP in component V_ATPase (first_order_rate_constant)');
    LEGEND_RATES(:,1) = strpad('d/dt G in component G (millimolar)');
    LEGEND_RATES(:,2) = strpad('d/dt G6P in component G6P (millimolar)');
    LEGEND_RATES(:,3) = strpad('d/dt FDP in component FDP (millimolar)');
    LEGEND_RATES(:,4) = strpad('d/dt G3P in component G3P (millimolar)');
    LEGEND_RATES(:,5) = strpad('d/dt DPG in component DPG (millimolar)');
    LEGEND_RATES(:,6) = strpad('d/dt PEP in component PEP (millimolar)');
    LEGEND_RATES(:,7) = strpad('d/dt Py in component Py (millimolar)');
    LEGEND_RATES(:,8) = strpad('d/dt ATP in component ATP (millimolar)');
    LEGEND_RATES(:,9) = strpad('d/dt CT in component CT (millimolar)');
    LEGEND_RATES(:,10) = strpad('d/dt CP in component CP (millimolar)');
    LEGEND_RATES(:,11) = strpad('d/dt PKp in component PKp (millimolar)');
    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) = 1;
    STATES(:,1) = 0.01;
    STATES(:,2) = 0.01;
    STATES(:,3) = 0.01;
    STATES(:,4) = 0.01;
    STATES(:,5) = 0.01;
    STATES(:,6) = 0.01;
    STATES(:,7) = 0.01;
    STATES(:,8) = 1.4;
    CONSTANTS(:,2) = 4;
    CONSTANTS(:,3) = 9;
    CONSTANTS(:,4) = 0.5;
    CONSTANTS(:,5) = 0.95;
    CONSTANTS(:,6) = 0.05;
    CONSTANTS(:,7) = 3.2e-8;
    CONSTANTS(:,8) = 1;
    CONSTANTS(:,9) = 0.01;
    CONSTANTS(:,10) = 1;
    CONSTANTS(:,11) = 0.9;
    STATES(:,9) = 0.2;
    STATES(:,10) = 1.2;
    CONSTANTS(:,12) = 10;
    CONSTANTS(:,13) = 3;
    CONSTANTS(:,14) = 2.5;
    CONSTANTS(:,15) = 0.0025;
    STATES(:,11) = 0.005;
    CONSTANTS(:,16) = 10;
    CONSTANTS(:,17) = 0.05;
    CONSTANTS(:,18) = 0.02;
    CONSTANTS(:,19) = 0.01;
    CONSTANTS(:,20) = 12;
    CONSTANTS(:,21) = 0.001;
    CONSTANTS(:,22) = 10;
    CONSTANTS(:,23) = 0.11;
    CONSTANTS(:,24) = 0.0062;
    CONSTANTS(:,25) = 0.1;
    CONSTANTS(:,26) = 13;
    CONSTANTS(:,27) = 1;
    CONSTANTS(:,28) = 0.06;
    CONSTANTS(:,29) = 0.025;
    CONSTANTS(:,30) = 1;
    CONSTANTS(:,31) = 0.019;
    CONSTANTS(:,32) = 0.0005;
    CONSTANTS(:,33) = 25000;
    CONSTANTS(:,34) = 10;
    CONSTANTS(:,35) = 2;
    CONSTANTS(:,36) = 30;
    CONSTANTS(:,37) = 0.05;
    CONSTANTS(:,38) = 0.05;
    CONSTANTS(:,39) = 0.05;
    CONSTANTS(:,40) = 0.4;
    CONSTANTS(:,41) = 1.6;
    CONSTANTS(:,42) = 1;
    CONSTANTS(:,43) = 20;
    CONSTANTS(:,44) = 0.5;
    CONSTANTS(:,45) = 2.5;
    CONSTANTS(:,46) = 1;
    CONSTANTS(:,47) = 1.1;
    CONSTANTS(:,48) = 1.5;
    CONSTANTS(:,49) = 2.5;
    CONSTANTS(:,50) = 0.0025;
    CONSTANTS(:,51) = 0.18;
    CONSTANTS(:,52) = 0.0003;
    CONSTANTS(:,53) = 10;
    CONSTANTS(:,54) = 0.002;
    CONSTANTS(:,55) = 3;
    CONSTANTS(:,56) = 9.5e-9;
    CONSTANTS(:,57) = 1;
    CONSTANTS(:,58) = 0.06;
    CONSTANTS(:,59) = 0.025;
    CONSTANTS(:,60) = 1;
    CONSTANTS(:,61) = 0.01;
    CONSTANTS(:,62) = 0.02;
    CONSTANTS(:,63) = 1000;
    CONSTANTS(:,64) = 0.1;
    CONSTANTS(:,65) = 1;
    CONSTANTS(:,66) = 25;
    CONSTANTS(:,67) = 50;
    CONSTANTS(:,68) = 0.329;
    CONSTANTS(:,69) = 10;
    CONSTANTS(:,70) = 0.169;
    CONSTANTS(:,71) = 0.5;
    CONSTANTS(:,72) = 5;
    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(:,10) =  CONSTANTS(:,12).*STATES(:,9).*power(STATES(:,10), 2.00000) -  CONSTANTS(:,15).*STATES(:,10);
    ALGEBRAIC(:,2) = CONSTANTS(:,19) - STATES(:,11);
    RATES(:,11) =  0.100000.*CONSTANTS(:,16).*ALGEBRAIC(:,2).*STATES(:,10) - ( CONSTANTS(:,17).*STATES(:,11)+ CONSTANTS(:,18).*STATES(:,11).*CONSTANTS(:,5));
    ALGEBRAIC(:,3) = CONSTANTS(:,11) - (STATES(:,9)+STATES(:,10));
    RATES(:,9) =  - ( CONSTANTS(:,12).*STATES(:,9).*power(STATES(:,10), 2.00000)+ CONSTANTS(:,13).*ALGEBRAIC(:,3)+ CONSTANTS(:,14).*STATES(:,9).*CONSTANTS(:,6));
    ALGEBRAIC(:,4) =  CONSTANTS(:,22).*(CONSTANTS(:,1)./( (CONSTANTS(:,21)+CONSTANTS(:,1)).*(1.00000+STATES(:,2)./CONSTANTS(:,20))) - STATES(:,1)./( (CONSTANTS(:,21)+STATES(:,1)).*(1.00000+STATES(:,2)./CONSTANTS(:,20))));
    ALGEBRAIC(:,5) = ( CONSTANTS(:,26).*1.00000)./(1.00000+( CONSTANTS(:,24).*CONSTANTS(:,25))./( STATES(:,1).*STATES(:,8))+CONSTANTS(:,23)./STATES(:,1)+CONSTANTS(:,25)./STATES(:,8));
    RATES(:,1) = ALGEBRAIC(:,4) - ALGEBRAIC(:,5);
    ALGEBRAIC(:,6) = ( (( (( CONSTANTS(:,36).*CONSTANTS(:,34).*STATES(:,2))./CONSTANTS(:,27)).*STATES(:,8))./CONSTANTS(:,28)).*power(1.00000+STATES(:,2)./CONSTANTS(:,27)+STATES(:,8)./CONSTANTS(:,28)+( (( CONSTANTS(:,34).*STATES(:,2))./CONSTANTS(:,27)).*STATES(:,8))./CONSTANTS(:,28), CONSTANTS(:,35) - 1.00000))./(power(1.00000+STATES(:,2)./CONSTANTS(:,27)+STATES(:,8)./CONSTANTS(:,28)+( (( CONSTANTS(:,34).*STATES(:,2))./CONSTANTS(:,27)).*STATES(:,8))./CONSTANTS(:,28), CONSTANTS(:,35))+ CONSTANTS(:,33).*power((1.00000+( CONSTANTS(:,31).*CONSTANTS(:,4))./CONSTANTS(:,29))./(1.00000+CONSTANTS(:,4)./CONSTANTS(:,29)), CONSTANTS(:,35)).*power(1.00000+( CONSTANTS(:,32).*STATES(:,2))./CONSTANTS(:,27)+( CONSTANTS(:,30).*STATES(:,8))./CONSTANTS(:,28)+( (( CONSTANTS(:,34).*CONSTANTS(:,32).*STATES(:,2))./CONSTANTS(:,27)).*CONSTANTS(:,30).*STATES(:,8))./CONSTANTS(:,28), CONSTANTS(:,35)));
    ALGEBRAIC(:,8) = (( CONSTANTS(:,45).*STATES(:,3))./CONSTANTS(:,44) - ( CONSTANTS(:,46).*STATES(:,4))./CONSTANTS(:,43))./(1.00000+STATES(:,3)./CONSTANTS(:,44)+STATES(:,4)./CONSTANTS(:,43));
    RATES(:,3) = ALGEBRAIC(:,6) - ALGEBRAIC(:,8);
    ALGEBRAIC(:,7) = STATES(:,9)+ALGEBRAIC(:,3);
    ALGEBRAIC(:,9) = CONSTANTS(:,41)./(( CONSTANTS(:,37).*CONSTANTS(:,38))./( STATES(:,2).*CONSTANTS(:,8))+CONSTANTS(:,37)./STATES(:,2)+CONSTANTS(:,38)./CONSTANTS(:,8)+1.00000)+CONSTANTS(:,42)./(( CONSTANTS(:,37).*CONSTANTS(:,39).*CONSTANTS(:,40))./( STATES(:,2).*CONSTANTS(:,8).*ALGEBRAIC(:,7))+( CONSTANTS(:,37).*CONSTANTS(:,39))./( STATES(:,2).*CONSTANTS(:,8))+( CONSTANTS(:,39).*CONSTANTS(:,40))./( CONSTANTS(:,8).*ALGEBRAIC(:,7))+( CONSTANTS(:,37).*CONSTANTS(:,40))./( STATES(:,2).*ALGEBRAIC(:,7))+CONSTANTS(:,40)./ALGEBRAIC(:,7)+CONSTANTS(:,37)./STATES(:,2)+CONSTANTS(:,39)./CONSTANTS(:,8)+1.00000);
    RATES(:,2) = ALGEBRAIC(:,5) - (ALGEBRAIC(:,6)+ALGEBRAIC(:,9));
    ALGEBRAIC(:,1) = CONSTANTS(:,3) - (STATES(:,8)+CONSTANTS(:,4));
    ALGEBRAIC(:,10) = CONSTANTS(:,53)./(1.00000+CONSTANTS(:,50)./STATES(:,4)+ (CONSTANTS(:,51)./CONSTANTS(:,10)).*(1.00000+CONSTANTS(:,4)./CONSTANTS(:,47)+ALGEBRAIC(:,1)./CONSTANTS(:,48)+STATES(:,8)./CONSTANTS(:,49))+ (( CONSTANTS(:,50).*CONSTANTS(:,51))./( STATES(:,4).*CONSTANTS(:,10))).*(1.00000+CONSTANTS(:,9)./CONSTANTS(:,52))+1.00000+CONSTANTS(:,4)./CONSTANTS(:,47)+ALGEBRAIC(:,1)./CONSTANTS(:,48)+STATES(:,8)./CONSTANTS(:,49));
    RATES(:,4) =  2.00000.*ALGEBRAIC(:,8) - ALGEBRAIC(:,10);
    ALGEBRAIC(:,11) = ( CONSTANTS(:,55).*STATES(:,5))./(CONSTANTS(:,54)+STATES(:,5));
    RATES(:,5) = ALGEBRAIC(:,10) - ALGEBRAIC(:,11);
    ALGEBRAIC(:,12) = 1.00000+STATES(:,6)./CONSTANTS(:,57)+ALGEBRAIC(:,1)./CONSTANTS(:,58)+( (( CONSTANTS(:,64).*STATES(:,6))./CONSTANTS(:,57)).*ALGEBRAIC(:,1))./CONSTANTS(:,58);
    ALGEBRAIC(:,13) = 1.00000+( CONSTANTS(:,62).*STATES(:,6))./CONSTANTS(:,57)+( CONSTANTS(:,60).*ALGEBRAIC(:,1))./CONSTANTS(:,58)+( (( CONSTANTS(:,65).*CONSTANTS(:,62).*STATES(:,6))./CONSTANTS(:,57)).*CONSTANTS(:,60).*ALGEBRAIC(:,1))./CONSTANTS(:,58);
    ALGEBRAIC(:,15) = 4.00000+STATES(:,11)./CONSTANTS(:,19);
    ALGEBRAIC(:,14) = CONSTANTS(:,66)+( (CONSTANTS(:,67) - CONSTANTS(:,66)).*STATES(:,11))./CONSTANTS(:,19);
    ALGEBRAIC(:,16) = ( (ALGEBRAIC(:,14)./(1.00000+CONSTANTS(:,56)./CONSTANTS(:,7))).*( CONSTANTS(:,64).*(STATES(:,6)./CONSTANTS(:,57)).*(ALGEBRAIC(:,1)./CONSTANTS(:,58)).*power(ALGEBRAIC(:,12), ALGEBRAIC(:,15) - 1.00000)+ CONSTANTS(:,63).*power((1.00000+( CONSTANTS(:,61).*STATES(:,3))./CONSTANTS(:,59))./(1.00000+STATES(:,3)./CONSTANTS(:,59)), ALGEBRAIC(:,15)).*(STATES(:,3)./CONSTANTS(:,59)).*CONSTANTS(:,65).*(( CONSTANTS(:,62).*STATES(:,6))./CONSTANTS(:,57)).*(( CONSTANTS(:,60).*ALGEBRAIC(:,1))./CONSTANTS(:,58)).*power(ALGEBRAIC(:,13), ALGEBRAIC(:,15) - 1.00000)))./(power(ALGEBRAIC(:,12), ALGEBRAIC(:,15))+ CONSTANTS(:,63).*power((1.00000+( CONSTANTS(:,61).*STATES(:,3))./CONSTANTS(:,59))./(1.00000+STATES(:,3)./CONSTANTS(:,59)), ALGEBRAIC(:,15)).*power(ALGEBRAIC(:,13), ALGEBRAIC(:,15)));
    RATES(:,6) = ALGEBRAIC(:,11) - ALGEBRAIC(:,16);
    ALGEBRAIC(:,17) = ( CONSTANTS(:,69).*power(STATES(:,7), 2.00000))./(power(CONSTANTS(:,68), 2.00000)+power(STATES(:,7), 2.00000));
    ALGEBRAIC(:,18) = ( CONSTANTS(:,71).*STATES(:,7))./(CONSTANTS(:,70)+STATES(:,7));
    RATES(:,7) = ALGEBRAIC(:,16) - (ALGEBRAIC(:,17)+ALGEBRAIC(:,18));
    ALGEBRAIC(:,19) =  CONSTANTS(:,72).*STATES(:,8);
    RATES(:,8) = (ALGEBRAIC(:,11)+ALGEBRAIC(:,16)+ CONSTANTS(:,2).*ALGEBRAIC(:,17)) - (ALGEBRAIC(:,5)+ALGEBRAIC(:,6)+ALGEBRAIC(:,19));
   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) = CONSTANTS(:,19) - STATES(:,11);
    ALGEBRAIC(:,3) = CONSTANTS(:,11) - (STATES(:,9)+STATES(:,10));
    ALGEBRAIC(:,4) =  CONSTANTS(:,22).*(CONSTANTS(:,1)./( (CONSTANTS(:,21)+CONSTANTS(:,1)).*(1.00000+STATES(:,2)./CONSTANTS(:,20))) - STATES(:,1)./( (CONSTANTS(:,21)+STATES(:,1)).*(1.00000+STATES(:,2)./CONSTANTS(:,20))));
    ALGEBRAIC(:,5) = ( CONSTANTS(:,26).*1.00000)./(1.00000+( CONSTANTS(:,24).*CONSTANTS(:,25))./( STATES(:,1).*STATES(:,8))+CONSTANTS(:,23)./STATES(:,1)+CONSTANTS(:,25)./STATES(:,8));
    ALGEBRAIC(:,6) = ( (( (( CONSTANTS(:,36).*CONSTANTS(:,34).*STATES(:,2))./CONSTANTS(:,27)).*STATES(:,8))./CONSTANTS(:,28)).*power(1.00000+STATES(:,2)./CONSTANTS(:,27)+STATES(:,8)./CONSTANTS(:,28)+( (( CONSTANTS(:,34).*STATES(:,2))./CONSTANTS(:,27)).*STATES(:,8))./CONSTANTS(:,28), CONSTANTS(:,35) - 1.00000))./(power(1.00000+STATES(:,2)./CONSTANTS(:,27)+STATES(:,8)./CONSTANTS(:,28)+( (( CONSTANTS(:,34).*STATES(:,2))./CONSTANTS(:,27)).*STATES(:,8))./CONSTANTS(:,28), CONSTANTS(:,35))+ CONSTANTS(:,33).*power((1.00000+( CONSTANTS(:,31).*CONSTANTS(:,4))./CONSTANTS(:,29))./(1.00000+CONSTANTS(:,4)./CONSTANTS(:,29)), CONSTANTS(:,35)).*power(1.00000+( CONSTANTS(:,32).*STATES(:,2))./CONSTANTS(:,27)+( CONSTANTS(:,30).*STATES(:,8))./CONSTANTS(:,28)+( (( CONSTANTS(:,34).*CONSTANTS(:,32).*STATES(:,2))./CONSTANTS(:,27)).*CONSTANTS(:,30).*STATES(:,8))./CONSTANTS(:,28), CONSTANTS(:,35)));
    ALGEBRAIC(:,8) = (( CONSTANTS(:,45).*STATES(:,3))./CONSTANTS(:,44) - ( CONSTANTS(:,46).*STATES(:,4))./CONSTANTS(:,43))./(1.00000+STATES(:,3)./CONSTANTS(:,44)+STATES(:,4)./CONSTANTS(:,43));
    ALGEBRAIC(:,7) = STATES(:,9)+ALGEBRAIC(:,3);
    ALGEBRAIC(:,9) = CONSTANTS(:,41)./(( CONSTANTS(:,37).*CONSTANTS(:,38))./( STATES(:,2).*CONSTANTS(:,8))+CONSTANTS(:,37)./STATES(:,2)+CONSTANTS(:,38)./CONSTANTS(:,8)+1.00000)+CONSTANTS(:,42)./(( CONSTANTS(:,37).*CONSTANTS(:,39).*CONSTANTS(:,40))./( STATES(:,2).*CONSTANTS(:,8).*ALGEBRAIC(:,7))+( CONSTANTS(:,37).*CONSTANTS(:,39))./( STATES(:,2).*CONSTANTS(:,8))+( CONSTANTS(:,39).*CONSTANTS(:,40))./( CONSTANTS(:,8).*ALGEBRAIC(:,7))+( CONSTANTS(:,37).*CONSTANTS(:,40))./( STATES(:,2).*ALGEBRAIC(:,7))+CONSTANTS(:,40)./ALGEBRAIC(:,7)+CONSTANTS(:,37)./STATES(:,2)+CONSTANTS(:,39)./CONSTANTS(:,8)+1.00000);
    ALGEBRAIC(:,1) = CONSTANTS(:,3) - (STATES(:,8)+CONSTANTS(:,4));
    ALGEBRAIC(:,10) = CONSTANTS(:,53)./(1.00000+CONSTANTS(:,50)./STATES(:,4)+ (CONSTANTS(:,51)./CONSTANTS(:,10)).*(1.00000+CONSTANTS(:,4)./CONSTANTS(:,47)+ALGEBRAIC(:,1)./CONSTANTS(:,48)+STATES(:,8)./CONSTANTS(:,49))+ (( CONSTANTS(:,50).*CONSTANTS(:,51))./( STATES(:,4).*CONSTANTS(:,10))).*(1.00000+CONSTANTS(:,9)./CONSTANTS(:,52))+1.00000+CONSTANTS(:,4)./CONSTANTS(:,47)+ALGEBRAIC(:,1)./CONSTANTS(:,48)+STATES(:,8)./CONSTANTS(:,49));
    ALGEBRAIC(:,11) = ( CONSTANTS(:,55).*STATES(:,5))./(CONSTANTS(:,54)+STATES(:,5));
    ALGEBRAIC(:,12) = 1.00000+STATES(:,6)./CONSTANTS(:,57)+ALGEBRAIC(:,1)./CONSTANTS(:,58)+( (( CONSTANTS(:,64).*STATES(:,6))./CONSTANTS(:,57)).*ALGEBRAIC(:,1))./CONSTANTS(:,58);
    ALGEBRAIC(:,13) = 1.00000+( CONSTANTS(:,62).*STATES(:,6))./CONSTANTS(:,57)+( CONSTANTS(:,60).*ALGEBRAIC(:,1))./CONSTANTS(:,58)+( (( CONSTANTS(:,65).*CONSTANTS(:,62).*STATES(:,6))./CONSTANTS(:,57)).*CONSTANTS(:,60).*ALGEBRAIC(:,1))./CONSTANTS(:,58);
    ALGEBRAIC(:,15) = 4.00000+STATES(:,11)./CONSTANTS(:,19);
    ALGEBRAIC(:,14) = CONSTANTS(:,66)+( (CONSTANTS(:,67) - CONSTANTS(:,66)).*STATES(:,11))./CONSTANTS(:,19);
    ALGEBRAIC(:,16) = ( (ALGEBRAIC(:,14)./(1.00000+CONSTANTS(:,56)./CONSTANTS(:,7))).*( CONSTANTS(:,64).*(STATES(:,6)./CONSTANTS(:,57)).*(ALGEBRAIC(:,1)./CONSTANTS(:,58)).*power(ALGEBRAIC(:,12), ALGEBRAIC(:,15) - 1.00000)+ CONSTANTS(:,63).*power((1.00000+( CONSTANTS(:,61).*STATES(:,3))./CONSTANTS(:,59))./(1.00000+STATES(:,3)./CONSTANTS(:,59)), ALGEBRAIC(:,15)).*(STATES(:,3)./CONSTANTS(:,59)).*CONSTANTS(:,65).*(( CONSTANTS(:,62).*STATES(:,6))./CONSTANTS(:,57)).*(( CONSTANTS(:,60).*ALGEBRAIC(:,1))./CONSTANTS(:,58)).*power(ALGEBRAIC(:,13), ALGEBRAIC(:,15) - 1.00000)))./(power(ALGEBRAIC(:,12), ALGEBRAIC(:,15))+ CONSTANTS(:,63).*power((1.00000+( CONSTANTS(:,61).*STATES(:,3))./CONSTANTS(:,59))./(1.00000+STATES(:,3)./CONSTANTS(:,59)), ALGEBRAIC(:,15)).*power(ALGEBRAIC(:,13), ALGEBRAIC(:,15)));
    ALGEBRAIC(:,17) = ( CONSTANTS(:,69).*power(STATES(:,7), 2.00000))./(power(CONSTANTS(:,68), 2.00000)+power(STATES(:,7), 2.00000));
    ALGEBRAIC(:,18) = ( CONSTANTS(:,71).*STATES(:,7))./(CONSTANTS(:,70)+STATES(:,7));
    ALGEBRAIC(:,19) =  CONSTANTS(:,72).*STATES(:,8);
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