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 =29;
end
% There are a total of 15 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 (minute)');
    LEGEND_CONSTANTS(:,1) = strpad('k1 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,2) = strpad('kn1 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,3) = strpad('k2 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,4) = strpad('kn2 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,5) = strpad('k2_ in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,6) = strpad('k3_ in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,7) = strpad('kn3_ in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,8) = strpad('k4 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,9) = strpad('k5 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,10) = strpad('k6 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,11) = strpad('k7 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,12) = strpad('kn7 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,13) = strpad('k8 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,14) = strpad('kn8 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,15) = strpad('k8_ in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,16) = strpad('k9 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,17) = strpad('kn9 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,18) = strpad('k9_ in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,19) = strpad('k10 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,20) = strpad('k11 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,21) = strpad('k12 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,22) = strpad('k13 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,23) = strpad('k14 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,24) = strpad('k14_ in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,25) = strpad('k15 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,26) = strpad('k16 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,27) = strpad('k17 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,28) = strpad('k18 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,29) = strpad('kn18 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,30) = strpad('k20 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,31) = strpad('k21 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,32) = strpad('k22 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,33) = strpad('k23 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,34) = strpad('kn23 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,35) = strpad('kPlk1 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,36) = strpad('kPlk1_ in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,37) = strpad('kctak1 in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,38) = strpad('kctak1_ in component rate_constants (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,39) = strpad('kex in component rate_constants (first_order_rate_constant)');
    LEGEND_STATES(:,1) = strpad('Chk1P in component Chk1P (dimensionless)');
    LEGEND_ALGEBRAIC(:,12) = strpad('V_n1 in component V_n1 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,8) = strpad('V_1 in component V_1 (first_order_rate_constant)');
    LEGEND_STATES(:,2) = strpad('Rad3 in component Rad3 (dimensionless)');
    LEGEND_CONSTANTS(:,42) = strpad('V_4 in component V_4 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,2) = strpad('V_5 in component V_5 (first_order_rate_constant)');
    LEGEND_STATES(:,3) = strpad('p53 in component p53 (dimensionless)');
    LEGEND_CONSTANTS(:,43) = strpad('V_10 in component V_10 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,3) = strpad('V_11 in component V_11 (first_order_rate_constant)');
    LEGEND_STATES(:,4) = strpad('preMPF in component preMPF (dimensionless)');
    LEGEND_ALGEBRAIC(:,13) = strpad('V_14 in component V_14 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,9) = strpad('V_n9 in component V_n9 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,4) = strpad('V_9 in component V_9 (first_order_rate_constant)');
    LEGEND_STATES(:,5) = strpad('MPF in component MPF (dimensionless)');
    LEGEND_ALGEBRAIC(:,27) = strpad('V_n23 in component V_n23 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,22) = strpad('V_23 in component V_23 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,14) = strpad('V_15 in component V_15 (first_order_rate_constant)');
    LEGEND_STATES(:,6) = strpad('p21 in component p21 (dimensionless)');
    LEGEND_CONSTANTS(:,44) = strpad('V_21 in component V_21 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,17) = strpad('V_20 in component V_20 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,19) = strpad('V_22 in component V_22 (first_order_rate_constant)');
    LEGEND_STATES(:,7) = strpad('p21_MPF in component p21_MPF (dimensionless)');
    LEGEND_STATES(:,8) = strpad('iCdc25 in component iCdc25 (dimensionless)');
    LEGEND_ALGEBRAIC(:,28) = strpad('V_n7 in component V_n7 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,20) = strpad('V_n3_ in component V_n3_ (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,23) = strpad('V_7 in component V_7 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,15) = strpad('V_2_ in component V_2_ (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,40) = strpad('V_in in component V_in (first_order_rate_constant)');
    LEGEND_STATES(:,9) = strpad('iCdc25Ps216 in component iCdc25Ps216 (dimensionless)');
    LEGEND_ALGEBRAIC(:,24) = strpad('V_n18 in component V_n18 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,21) = strpad('V_18 in component V_18 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,18) = strpad('V_3_ in component V_3_ (first_order_rate_constant)');
    LEGEND_STATES(:,10) = strpad('iCdc25Ps216_protein1433 in component iCdc25Ps216_protein1433 (dimensionless)');
    LEGEND_ALGEBRAIC(:,25) = strpad('V_ex in component V_ex (first_order_rate_constant)');
    LEGEND_STATES(:,11) = strpad('aCdc25 in component aCdc25 (dimensionless)');
    LEGEND_ALGEBRAIC(:,10) = strpad('V_n2 in component V_n2 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,5) = strpad('V_2 in component V_2 (first_order_rate_constant)');
    LEGEND_STATES(:,12) = strpad('aCdc25Ps216 in component aCdc25Ps216 (dimensionless)');
    LEGEND_STATES(:,13) = strpad('protein1433 in component protein1433 (dimensionless)');
    LEGEND_ALGEBRAIC(:,26) = strpad('V_6 in component V_6 (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,45) = strpad('V_13 in component V_13 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,29) = strpad('V_12 in component V_12 (first_order_rate_constant)');
    LEGEND_STATES(:,14) = strpad('Wee1 in component Wee1 (dimensionless)');
    LEGEND_CONSTANTS(:,46) = strpad('V_16 in component V_16 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,11) = strpad('V_n8 in component V_n8 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,6) = strpad('V_8 in component V_8 (first_order_rate_constant)');
    LEGEND_STATES(:,15) = strpad('Wee1P in component Wee1P (dimensionless)');
    LEGEND_ALGEBRAIC(:,16) = strpad('V_17 in component V_17 (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,7) = strpad('aCdc25_T in component aCdc25_T (dimensionless)');
    LEGEND_ALGEBRAIC(:,1) = strpad('Chk1 in component V_1 (dimensionless)');
    LEGEND_CONSTANTS(:,41) = strpad('Chk1_T in component V_1 (dimensionless)');
    LEGEND_RATES(:,1) = strpad('d/dt Chk1P in component Chk1P (dimensionless)');
    LEGEND_RATES(:,2) = strpad('d/dt Rad3 in component Rad3 (dimensionless)');
    LEGEND_RATES(:,3) = strpad('d/dt p53 in component p53 (dimensionless)');
    LEGEND_RATES(:,4) = strpad('d/dt preMPF in component preMPF (dimensionless)');
    LEGEND_RATES(:,5) = strpad('d/dt MPF in component MPF (dimensionless)');
    LEGEND_RATES(:,6) = strpad('d/dt p21 in component p21 (dimensionless)');
    LEGEND_RATES(:,7) = strpad('d/dt p21_MPF in component p21_MPF (dimensionless)');
    LEGEND_RATES(:,8) = strpad('d/dt iCdc25 in component iCdc25 (dimensionless)');
    LEGEND_RATES(:,9) = strpad('d/dt iCdc25Ps216 in component iCdc25Ps216 (dimensionless)');
    LEGEND_RATES(:,10) = strpad('d/dt iCdc25Ps216_protein1433 in component iCdc25Ps216_protein1433 (dimensionless)');
    LEGEND_RATES(:,11) = strpad('d/dt aCdc25 in component aCdc25 (dimensionless)');
    LEGEND_RATES(:,12) = strpad('d/dt aCdc25Ps216 in component aCdc25Ps216 (dimensionless)');
    LEGEND_RATES(:,13) = strpad('d/dt protein1433 in component protein1433 (dimensionless)');
    LEGEND_RATES(:,14) = strpad('d/dt Wee1 in component Wee1 (dimensionless)');
    LEGEND_RATES(:,15) = strpad('d/dt Wee1P in component Wee1P (dimensionless)');
    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;
    CONSTANTS(:,2) = 10;
    CONSTANTS(:,3) = 0.1;
    CONSTANTS(:,4) = 0.01;
    CONSTANTS(:,5) = 0.1;
    CONSTANTS(:,6) = 100;
    CONSTANTS(:,7) = 0;
    CONSTANTS(:,8) = 0;
    CONSTANTS(:,9) = 1;
    CONSTANTS(:,10) = 0.01;
    CONSTANTS(:,11) = 1;
    CONSTANTS(:,12) = 0.01;
    CONSTANTS(:,13) = 0.1;
    CONSTANTS(:,14) = 0.01;
    CONSTANTS(:,15) = 0;
    CONSTANTS(:,16) = 1;
    CONSTANTS(:,17) = 1;
    CONSTANTS(:,18) = 0;
    CONSTANTS(:,19) = 0;
    CONSTANTS(:,20) = 1;
    CONSTANTS(:,21) = 0.1;
    CONSTANTS(:,22) = 1;
    CONSTANTS(:,23) = 0.0005;
    CONSTANTS(:,24) = 1;
    CONSTANTS(:,25) = 0.01;
    CONSTANTS(:,26) = 0.0002;
    CONSTANTS(:,27) = 0.1;
    CONSTANTS(:,28) = 1;
    CONSTANTS(:,29) = 0.01;
    CONSTANTS(:,30) = 0.1;
    CONSTANTS(:,31) = 0.01;
    CONSTANTS(:,32) = 0.1;
    CONSTANTS(:,33) = 0.1;
    CONSTANTS(:,34) = 1;
    CONSTANTS(:,35) = 0;
    CONSTANTS(:,36) = 0;
    CONSTANTS(:,37) = 0;
    CONSTANTS(:,38) = 0;
    CONSTANTS(:,39) = 1;
    STATES(:,1) = 0.000001;
    STATES(:,2) = 0;
    STATES(:,3) = 0;
    STATES(:,4) = 0.000001;
    STATES(:,5) = 0.00000001;
    STATES(:,6) = 0;
    STATES(:,7) = 0;
    STATES(:,8) = 0.000001;
    CONSTANTS(:,40) = 0.00001;
    STATES(:,9) = 0.00002;
    STATES(:,10) = 0.03;
    STATES(:,11) = 0.000001;
    STATES(:,12) = 0;
    STATES(:,13) = 2;
    STATES(:,14) = 0.001;
    STATES(:,15) = 0;
    CONSTANTS(:,41) = 1;
    CONSTANTS(:,42) = CONSTANTS(:,8);
    CONSTANTS(:,43) = CONSTANTS(:,19);
    CONSTANTS(:,44) = CONSTANTS(:,31);
    CONSTANTS(:,45) = CONSTANTS(:,22);
    CONSTANTS(:,46) = CONSTANTS(:,26);
    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) =  CONSTANTS(:,9).*STATES(:,2);
    RATES(:,2) = CONSTANTS(:,42) - ALGEBRAIC(:,2);
    ALGEBRAIC(:,3) =  CONSTANTS(:,20).*STATES(:,3);
    RATES(:,3) = CONSTANTS(:,43) - ALGEBRAIC(:,3);
    ALGEBRAIC(:,11) =  CONSTANTS(:,14).*STATES(:,15);
    ALGEBRAIC(:,6) =  CONSTANTS(:,13).*STATES(:,5).*STATES(:,14)+ CONSTANTS(:,15).*STATES(:,14);
    RATES(:,14) = (CONSTANTS(:,46)+ALGEBRAIC(:,11)) - ALGEBRAIC(:,6);
    ALGEBRAIC(:,12) =  CONSTANTS(:,2).*STATES(:,1);
    ALGEBRAIC(:,1) = CONSTANTS(:,41) - STATES(:,1);
    ALGEBRAIC(:,8) =  CONSTANTS(:,1).*ALGEBRAIC(:,1).*STATES(:,2);
    RATES(:,1) = ALGEBRAIC(:,8) - ALGEBRAIC(:,12);
    ALGEBRAIC(:,13) =  (CONSTANTS(:,23)./(1.00000+ CONSTANTS(:,24).*STATES(:,3))).*1.00000;
    ALGEBRAIC(:,9) =  CONSTANTS(:,17).*STATES(:,5).*STATES(:,14);
    ALGEBRAIC(:,4) =  CONSTANTS(:,16).*(STATES(:,11)+STATES(:,12)).*STATES(:,4)+ CONSTANTS(:,18).*STATES(:,4);
    RATES(:,4) = (ALGEBRAIC(:,13)+ALGEBRAIC(:,9)) - ALGEBRAIC(:,4);
    ALGEBRAIC(:,16) =  CONSTANTS(:,27).*STATES(:,15);
    RATES(:,15) = ALGEBRAIC(:,6) - (ALGEBRAIC(:,11)+ALGEBRAIC(:,16));
    ALGEBRAIC(:,15) =  CONSTANTS(:,5).*STATES(:,1).*STATES(:,8)+ CONSTANTS(:,38).*STATES(:,8);
    ALGEBRAIC(:,24) =  CONSTANTS(:,29).*STATES(:,12);
    ALGEBRAIC(:,21) =  CONSTANTS(:,28).*STATES(:,5).*STATES(:,9)+ CONSTANTS(:,36).*STATES(:,9);
    ALGEBRAIC(:,18) =  CONSTANTS(:,6).*STATES(:,9).*STATES(:,13);
    RATES(:,9) = (ALGEBRAIC(:,15)+ALGEBRAIC(:,24)) - (ALGEBRAIC(:,21)+ALGEBRAIC(:,18));
    ALGEBRAIC(:,20) =  CONSTANTS(:,7).*STATES(:,10);
    ALGEBRAIC(:,25) =  CONSTANTS(:,39).*STATES(:,10);
    RATES(:,10) = ALGEBRAIC(:,18) - (ALGEBRAIC(:,20)+ALGEBRAIC(:,25));
    ALGEBRAIC(:,10) =  CONSTANTS(:,4).*STATES(:,12);
    ALGEBRAIC(:,5) =  CONSTANTS(:,3).*STATES(:,1).*STATES(:,11)+ CONSTANTS(:,37).*STATES(:,11);
    RATES(:,12) = (ALGEBRAIC(:,5)+ALGEBRAIC(:,21)) - (ALGEBRAIC(:,10)+ALGEBRAIC(:,24));
    ALGEBRAIC(:,27) =  CONSTANTS(:,34).*STATES(:,7);
    ALGEBRAIC(:,22) =  CONSTANTS(:,33).*STATES(:,5).*STATES(:,6);
    ALGEBRAIC(:,14) =  CONSTANTS(:,25).*power(STATES(:,5), 2.00000);
    RATES(:,5) = (ALGEBRAIC(:,4)+ALGEBRAIC(:,27)) - (ALGEBRAIC(:,9)+ALGEBRAIC(:,22)+ALGEBRAIC(:,14));
    ALGEBRAIC(:,17) =  CONSTANTS(:,30).*STATES(:,3);
    ALGEBRAIC(:,19) =  CONSTANTS(:,32).*STATES(:,6);
    RATES(:,6) = (ALGEBRAIC(:,17)+CONSTANTS(:,44)+ALGEBRAIC(:,27)) - (ALGEBRAIC(:,19)+ALGEBRAIC(:,22));
    RATES(:,7) = ALGEBRAIC(:,22) - ALGEBRAIC(:,27);
    ALGEBRAIC(:,28) =  CONSTANTS(:,12).*STATES(:,11);
    ALGEBRAIC(:,23) =  CONSTANTS(:,11).*STATES(:,5).*STATES(:,8)+ CONSTANTS(:,35).*STATES(:,8);
    RATES(:,8) = (ALGEBRAIC(:,28)+ALGEBRAIC(:,20)+CONSTANTS(:,40)) - (ALGEBRAIC(:,23)+ALGEBRAIC(:,15));
    RATES(:,11) = (ALGEBRAIC(:,23)+ALGEBRAIC(:,10)) - (ALGEBRAIC(:,28)+ALGEBRAIC(:,5));
    ALGEBRAIC(:,26) =  CONSTANTS(:,10).*STATES(:,3);
    ALGEBRAIC(:,29) =  CONSTANTS(:,21).*STATES(:,13);
    RATES(:,13) = (ALGEBRAIC(:,26)+CONSTANTS(:,45)+ALGEBRAIC(:,20)) - (ALGEBRAIC(:,18)+ALGEBRAIC(:,29));
   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(:,9).*STATES(:,2);
    ALGEBRAIC(:,3) =  CONSTANTS(:,20).*STATES(:,3);
    ALGEBRAIC(:,11) =  CONSTANTS(:,14).*STATES(:,15);
    ALGEBRAIC(:,6) =  CONSTANTS(:,13).*STATES(:,5).*STATES(:,14)+ CONSTANTS(:,15).*STATES(:,14);
    ALGEBRAIC(:,12) =  CONSTANTS(:,2).*STATES(:,1);
    ALGEBRAIC(:,1) = CONSTANTS(:,41) - STATES(:,1);
    ALGEBRAIC(:,8) =  CONSTANTS(:,1).*ALGEBRAIC(:,1).*STATES(:,2);
    ALGEBRAIC(:,13) =  (CONSTANTS(:,23)./(1.00000+ CONSTANTS(:,24).*STATES(:,3))).*1.00000;
    ALGEBRAIC(:,9) =  CONSTANTS(:,17).*STATES(:,5).*STATES(:,14);
    ALGEBRAIC(:,4) =  CONSTANTS(:,16).*(STATES(:,11)+STATES(:,12)).*STATES(:,4)+ CONSTANTS(:,18).*STATES(:,4);
    ALGEBRAIC(:,16) =  CONSTANTS(:,27).*STATES(:,15);
    ALGEBRAIC(:,15) =  CONSTANTS(:,5).*STATES(:,1).*STATES(:,8)+ CONSTANTS(:,38).*STATES(:,8);
    ALGEBRAIC(:,24) =  CONSTANTS(:,29).*STATES(:,12);
    ALGEBRAIC(:,21) =  CONSTANTS(:,28).*STATES(:,5).*STATES(:,9)+ CONSTANTS(:,36).*STATES(:,9);
    ALGEBRAIC(:,18) =  CONSTANTS(:,6).*STATES(:,9).*STATES(:,13);
    ALGEBRAIC(:,20) =  CONSTANTS(:,7).*STATES(:,10);
    ALGEBRAIC(:,25) =  CONSTANTS(:,39).*STATES(:,10);
    ALGEBRAIC(:,10) =  CONSTANTS(:,4).*STATES(:,12);
    ALGEBRAIC(:,5) =  CONSTANTS(:,3).*STATES(:,1).*STATES(:,11)+ CONSTANTS(:,37).*STATES(:,11);
    ALGEBRAIC(:,27) =  CONSTANTS(:,34).*STATES(:,7);
    ALGEBRAIC(:,22) =  CONSTANTS(:,33).*STATES(:,5).*STATES(:,6);
    ALGEBRAIC(:,14) =  CONSTANTS(:,25).*power(STATES(:,5), 2.00000);
    ALGEBRAIC(:,17) =  CONSTANTS(:,30).*STATES(:,3);
    ALGEBRAIC(:,19) =  CONSTANTS(:,32).*STATES(:,6);
    ALGEBRAIC(:,28) =  CONSTANTS(:,12).*STATES(:,11);
    ALGEBRAIC(:,23) =  CONSTANTS(:,11).*STATES(:,5).*STATES(:,8)+ CONSTANTS(:,35).*STATES(:,8);
    ALGEBRAIC(:,26) =  CONSTANTS(:,10).*STATES(:,3);
    ALGEBRAIC(:,29) =  CONSTANTS(:,21).*STATES(:,13);
    ALGEBRAIC(:,7) = STATES(:,11)+STATES(:,12);
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