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 =93;
end
% There are a total of 38 entries in each of the rate and state variable arrays.
% There are a total of 21 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_STATES(:,1) = strpad('NatP in component NatP (molecules)');
    LEGEND_CONSTANTS(:,18) = strpad('v1 in component v1 (flux)');
    LEGEND_ALGEBRAIC(:,1) = strpad('v2 in component v2 (flux)');
    LEGEND_ALGEBRAIC(:,2) = strpad('v3 in component v3 (flux)');
    LEGEND_STATES(:,2) = strpad('MisP in component MisP (molecules)');
    LEGEND_ALGEBRAIC(:,4) = strpad('v5 in component v5 (flux)');
    LEGEND_ALGEBRAIC(:,22) = strpad('v23 in component v23 (flux)');
    LEGEND_ALGEBRAIC(:,3) = strpad('v4 in component v4 (flux)');
    LEGEND_ALGEBRAIC(:,38) = strpad('v39 in component v39 (flux)');
    LEGEND_ALGEBRAIC(:,39) = strpad('v40 in component v40 (flux)');
    LEGEND_ALGEBRAIC(:,48) = strpad('v49 in component v49 (flux)');
    LEGEND_ALGEBRAIC(:,49) = strpad('v50 in component v50 (flux)');
    LEGEND_ALGEBRAIC(:,50) = strpad('v51 in component v51 (flux)');
    LEGEND_ALGEBRAIC(:,51) = strpad('v52 in component v52 (flux)');
    LEGEND_ALGEBRAIC(:,52) = strpad('v53 in component v53 (flux)');
    LEGEND_ALGEBRAIC(:,53) = strpad('v54 in component v54 (flux)');
    LEGEND_ALGEBRAIC(:,54) = strpad('v55 in component v55 (flux)');
    LEGEND_ALGEBRAIC(:,55) = strpad('v56 in component v56 (flux)');
    LEGEND_STATES(:,3) = strpad('Ub in component Ub (molecules)');
    LEGEND_ALGEBRAIC(:,15) = strpad('v16 in component v16 (flux)');
    LEGEND_ALGEBRAIC(:,16) = strpad('v17 in component v17 (flux)');
    LEGEND_ALGEBRAIC(:,17) = strpad('v18 in component v18 (flux)');
    LEGEND_ALGEBRAIC(:,18) = strpad('v19 in component v19 (flux)');
    LEGEND_ALGEBRAIC(:,19) = strpad('v20 in component v20 (flux)');
    LEGEND_ALGEBRAIC(:,20) = strpad('v21 in component v21 (flux)');
    LEGEND_ALGEBRAIC(:,21) = strpad('v22 in component v22 (flux)');
    LEGEND_ALGEBRAIC(:,28) = strpad('v29 in component v29 (flux)');
    LEGEND_ALGEBRAIC(:,29) = strpad('v30 in component v30 (flux)');
    LEGEND_ALGEBRAIC(:,30) = strpad('v31 in component v31 (flux)');
    LEGEND_ALGEBRAIC(:,31) = strpad('v32 in component v32 (flux)');
    LEGEND_ALGEBRAIC(:,32) = strpad('v33 in component v33 (flux)');
    LEGEND_ALGEBRAIC(:,33) = strpad('v34 in component v34 (flux)');
    LEGEND_ALGEBRAIC(:,34) = strpad('v35 in component v35 (flux)');
    LEGEND_ALGEBRAIC(:,35) = strpad('v36 in component v36 (flux)');
    LEGEND_ALGEBRAIC(:,36) = strpad('v37 in component v37 (flux)');
    LEGEND_ALGEBRAIC(:,37) = strpad('v38 in component v38 (flux)');
    LEGEND_ALGEBRAIC(:,5) = strpad('v6 in component v6 (flux)');
    LEGEND_STATES(:,4) = strpad('E1 in component E1 (molecules)');
    LEGEND_ALGEBRAIC(:,6) = strpad('v7 in component v7 (flux)');
    LEGEND_STATES(:,5) = strpad('E2 in component E2 (molecules)');
    LEGEND_ALGEBRAIC(:,7) = strpad('v8 in component v8 (flux)');
    LEGEND_ALGEBRAIC(:,8) = strpad('v9 in component v9 (flux)');
    LEGEND_ALGEBRAIC(:,9) = strpad('v10 in component v10 (flux)');
    LEGEND_ALGEBRAIC(:,10) = strpad('v11 in component v11 (flux)');
    LEGEND_ALGEBRAIC(:,11) = strpad('v12 in component v12 (flux)');
    LEGEND_ALGEBRAIC(:,12) = strpad('v13 in component v13 (flux)');
    LEGEND_ALGEBRAIC(:,13) = strpad('v14 in component v14 (flux)');
    LEGEND_ALGEBRAIC(:,14) = strpad('v15 in component v15 (flux)');
    LEGEND_STATES(:,6) = strpad('E3 in component E3 (molecules)');
    LEGEND_STATES(:,7) = strpad('DUB in component DUB (molecules)');
    LEGEND_STATES(:,8) = strpad('Proteasome in component Proteasome (molecules)');
    LEGEND_ALGEBRAIC(:,23) = strpad('v24 in component v24 (flux)');
    LEGEND_ALGEBRAIC(:,24) = strpad('v25 in component v25 (flux)');
    LEGEND_ALGEBRAIC(:,25) = strpad('v26 in component v26 (flux)');
    LEGEND_ALGEBRAIC(:,26) = strpad('v27 in component v27 (flux)');
    LEGEND_ALGEBRAIC(:,27) = strpad('v28 in component v28 (flux)');
    LEGEND_ALGEBRAIC(:,93) = strpad('v94 in component v94 (flux)');
    LEGEND_STATES(:,9) = strpad('ROS in component ROS (molecules)');
    LEGEND_STATES(:,10) = strpad('E1_Ub in component E1_Ub (molecules)');
    LEGEND_STATES(:,11) = strpad('E2_Ub in component E2_Ub (molecules)');
    LEGEND_STATES(:,12) = strpad('E3_MisP in component E3_MisP (molecules)');
    LEGEND_STATES(:,13) = strpad('MisP_Ub in component MisP_Ub (molecules)');
    LEGEND_ALGEBRAIC(:,40) = strpad('v41 in component v41 (flux)');
    LEGEND_ALGEBRAIC(:,56) = strpad('v57 in component v57 (flux)');
    LEGEND_ALGEBRAIC(:,64) = strpad('v65 in component v65 (flux)');
    LEGEND_ALGEBRAIC(:,65) = strpad('v66 in component v66 (flux)');
    LEGEND_ALGEBRAIC(:,66) = strpad('v67 in component v67 (flux)');
    LEGEND_ALGEBRAIC(:,67) = strpad('v68 in component v68 (flux)');
    LEGEND_ALGEBRAIC(:,68) = strpad('v69 in component v69 (flux)');
    LEGEND_ALGEBRAIC(:,69) = strpad('v70 in component v70 (flux)');
    LEGEND_ALGEBRAIC(:,70) = strpad('v71 in component v71 (flux)');
    LEGEND_STATES(:,14) = strpad('MisP_Ub2 in component MisP_Ub2 (molecules)');
    LEGEND_ALGEBRAIC(:,41) = strpad('v42 in component v42 (flux)');
    LEGEND_ALGEBRAIC(:,57) = strpad('v58 in component v58 (flux)');
    LEGEND_ALGEBRAIC(:,71) = strpad('v72 in component v72 (flux)');
    LEGEND_ALGEBRAIC(:,72) = strpad('v73 in component v73 (flux)');
    LEGEND_ALGEBRAIC(:,73) = strpad('v74 in component v74 (flux)');
    LEGEND_ALGEBRAIC(:,74) = strpad('v75 in component v75 (flux)');
    LEGEND_ALGEBRAIC(:,75) = strpad('v76 in component v76 (flux)');
    LEGEND_ALGEBRAIC(:,76) = strpad('v77 in component v77 (flux)');
    LEGEND_STATES(:,15) = strpad('MisP_Ub3 in component MisP_Ub3 (molecules)');
    LEGEND_ALGEBRAIC(:,42) = strpad('v43 in component v43 (flux)');
    LEGEND_ALGEBRAIC(:,58) = strpad('v59 in component v59 (flux)');
    LEGEND_ALGEBRAIC(:,77) = strpad('v78 in component v78 (flux)');
    LEGEND_ALGEBRAIC(:,78) = strpad('v79 in component v79 (flux)');
    LEGEND_ALGEBRAIC(:,79) = strpad('v80 in component v80 (flux)');
    LEGEND_ALGEBRAIC(:,80) = strpad('v81 in component v81 (flux)');
    LEGEND_ALGEBRAIC(:,81) = strpad('v82 in component v82 (flux)');
    LEGEND_STATES(:,16) = strpad('MisP_Ub4 in component MisP_Ub4 (molecules)');
    LEGEND_ALGEBRAIC(:,43) = strpad('v44 in component v44 (flux)');
    LEGEND_ALGEBRAIC(:,59) = strpad('v60 in component v60 (flux)');
    LEGEND_ALGEBRAIC(:,82) = strpad('v83 in component v83 (flux)');
    LEGEND_ALGEBRAIC(:,83) = strpad('v84 in component v84 (flux)');
    LEGEND_ALGEBRAIC(:,84) = strpad('v85 in component v85 (flux)');
    LEGEND_ALGEBRAIC(:,85) = strpad('v86 in component v86 (flux)');
    LEGEND_STATES(:,17) = strpad('MisP_Ub5 in component MisP_Ub5 (molecules)');
    LEGEND_ALGEBRAIC(:,44) = strpad('v45 in component v45 (flux)');
    LEGEND_ALGEBRAIC(:,60) = strpad('v61 in component v61 (flux)');
    LEGEND_ALGEBRAIC(:,86) = strpad('v87 in component v87 (flux)');
    LEGEND_ALGEBRAIC(:,87) = strpad('v88 in component v88 (flux)');
    LEGEND_ALGEBRAIC(:,88) = strpad('v89 in component v89 (flux)');
    LEGEND_STATES(:,18) = strpad('MisP_Ub6 in component MisP_Ub6 (molecules)');
    LEGEND_ALGEBRAIC(:,45) = strpad('v46 in component v46 (flux)');
    LEGEND_ALGEBRAIC(:,61) = strpad('v62 in component v62 (flux)');
    LEGEND_ALGEBRAIC(:,89) = strpad('v90 in component v90 (flux)');
    LEGEND_ALGEBRAIC(:,90) = strpad('v91 in component v91 (flux)');
    LEGEND_STATES(:,19) = strpad('MisP_Ub7 in component MisP_Ub7 (molecules)');
    LEGEND_ALGEBRAIC(:,46) = strpad('v47 in component v47 (flux)');
    LEGEND_ALGEBRAIC(:,62) = strpad('v63 in component v63 (flux)');
    LEGEND_ALGEBRAIC(:,91) = strpad('v92 in component v92 (flux)');
    LEGEND_STATES(:,20) = strpad('MisP_Ub8 in component MisP_Ub8 (molecules)');
    LEGEND_ALGEBRAIC(:,47) = strpad('v48 in component v48 (flux)');
    LEGEND_ALGEBRAIC(:,63) = strpad('v64 in component v64 (flux)');
    LEGEND_STATES(:,21) = strpad('MisP_Ub4_Proteasome in component MisP_Ub4_Proteasome (molecules)');
    LEGEND_STATES(:,22) = strpad('MisP_Ub5_Proteasome in component MisP_Ub5_Proteasome (molecules)');
    LEGEND_STATES(:,23) = strpad('MisP_Ub6_Proteasome in component MisP_Ub6_Proteasome (molecules)');
    LEGEND_STATES(:,24) = strpad('MisP_Ub7_Proteasome in component MisP_Ub7_Proteasome (molecules)');
    LEGEND_STATES(:,25) = strpad('MisP_Ub8_Proteasome in component MisP_Ub8_Proteasome (molecules)');
    LEGEND_STATES(:,26) = strpad('ATP in component ATP (molecules)');
    LEGEND_STATES(:,27) = strpad('ADP in component ADP (molecules)');
    LEGEND_STATES(:,28) = strpad('AMP in component AMP (molecules)');
    LEGEND_STATES(:,29) = strpad('degUb4 in component degUb4 (molecules)');
    LEGEND_STATES(:,30) = strpad('degUb5 in component degUb5 (molecules)');
    LEGEND_STATES(:,31) = strpad('degUb6 in component degUb6 (molecules)');
    LEGEND_STATES(:,32) = strpad('degUb7 in component degUb7 (molecules)');
    LEGEND_STATES(:,33) = strpad('degUb8 in component degUb8 (molecules)');
    LEGEND_STATES(:,34) = strpad('MisP_total in component MisP_total (molecules)');
    LEGEND_STATES(:,35) = strpad('NatP_refolded in component NatP_refolded (molecules)');
    LEGEND_STATES(:,36) = strpad('AggP in component AggP (molecules)');
    LEGEND_ALGEBRAIC(:,92) = strpad('v93 in component v93 (flux)');
    LEGEND_STATES(:,37) = strpad('SeqAggP in component SeqAggP (molecules)');
    LEGEND_STATES(:,38) = strpad('AggP_Proteasome in component AggP_Proteasome (molecules)');
    LEGEND_CONSTANTS(:,1) = strpad('k1 in component kinetic_parameters (flux)');
    LEGEND_CONSTANTS(:,2) = strpad('k2 in component kinetic_parameters (second_order_rate_constant)');
    LEGEND_CONSTANTS(:,3) = strpad('k3 in component kinetic_parameters (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,4) = strpad('k61 in component kinetic_parameters (second_order_rate_constant)');
    LEGEND_CONSTANTS(:,5) = strpad('k61r in component kinetic_parameters (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,6) = strpad('k62 in component kinetic_parameters (second_order_rate_constant)');
    LEGEND_CONSTANTS(:,7) = strpad('k63 in component kinetic_parameters (second_order_rate_constant)');
    LEGEND_CONSTANTS(:,8) = strpad('k64 in component kinetic_parameters (second_order_rate_constant)');
    LEGEND_CONSTANTS(:,9) = strpad('k65 in component kinetic_parameters (second_order_rate_constant)');
    LEGEND_CONSTANTS(:,10) = strpad('k66 in component kinetic_parameters (second_order_rate_constant)');
    LEGEND_CONSTANTS(:,11) = strpad('k67 in component kinetic_parameters (second_order_rate_constant)');
    LEGEND_CONSTANTS(:,12) = strpad('k68 in component kinetic_parameters (second_order_rate_constant)');
    LEGEND_CONSTANTS(:,13) = strpad('k69 in component kinetic_parameters (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,14) = strpad('k71 in component kinetic_parameters (second_order_rate_constant)');
    LEGEND_CONSTANTS(:,15) = strpad('k72 in component kinetic_parameters (second_order_rate_constant)');
    LEGEND_CONSTANTS(:,16) = strpad('k73 in component kinetic_parameters (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,17) = strpad('k74 in component kinetic_parameters (second_order_rate_constant)');
    LEGEND_RATES(:,1) = strpad('d/dt NatP in component NatP (molecules)');
    LEGEND_RATES(:,2) = strpad('d/dt MisP in component MisP (molecules)');
    LEGEND_RATES(:,3) = strpad('d/dt Ub in component Ub (molecules)');
    LEGEND_RATES(:,4) = strpad('d/dt E1 in component E1 (molecules)');
    LEGEND_RATES(:,5) = strpad('d/dt E2 in component E2 (molecules)');
    LEGEND_RATES(:,6) = strpad('d/dt E3 in component E3 (molecules)');
    LEGEND_RATES(:,7) = strpad('d/dt DUB in component DUB (molecules)');
    LEGEND_RATES(:,8) = strpad('d/dt Proteasome in component Proteasome (molecules)');
    LEGEND_RATES(:,9) = strpad('d/dt ROS in component ROS (molecules)');
    LEGEND_RATES(:,10) = strpad('d/dt E1_Ub in component E1_Ub (molecules)');
    LEGEND_RATES(:,11) = strpad('d/dt E2_Ub in component E2_Ub (molecules)');
    LEGEND_RATES(:,12) = strpad('d/dt E3_MisP in component E3_MisP (molecules)');
    LEGEND_RATES(:,13) = strpad('d/dt MisP_Ub in component MisP_Ub (molecules)');
    LEGEND_RATES(:,14) = strpad('d/dt MisP_Ub2 in component MisP_Ub2 (molecules)');
    LEGEND_RATES(:,15) = strpad('d/dt MisP_Ub3 in component MisP_Ub3 (molecules)');
    LEGEND_RATES(:,16) = strpad('d/dt MisP_Ub4 in component MisP_Ub4 (molecules)');
    LEGEND_RATES(:,17) = strpad('d/dt MisP_Ub5 in component MisP_Ub5 (molecules)');
    LEGEND_RATES(:,18) = strpad('d/dt MisP_Ub6 in component MisP_Ub6 (molecules)');
    LEGEND_RATES(:,19) = strpad('d/dt MisP_Ub7 in component MisP_Ub7 (molecules)');
    LEGEND_RATES(:,20) = strpad('d/dt MisP_Ub8 in component MisP_Ub8 (molecules)');
    LEGEND_RATES(:,21) = strpad('d/dt MisP_Ub4_Proteasome in component MisP_Ub4_Proteasome (molecules)');
    LEGEND_RATES(:,22) = strpad('d/dt MisP_Ub5_Proteasome in component MisP_Ub5_Proteasome (molecules)');
    LEGEND_RATES(:,23) = strpad('d/dt MisP_Ub6_Proteasome in component MisP_Ub6_Proteasome (molecules)');
    LEGEND_RATES(:,24) = strpad('d/dt MisP_Ub7_Proteasome in component MisP_Ub7_Proteasome (molecules)');
    LEGEND_RATES(:,25) = strpad('d/dt MisP_Ub8_Proteasome in component MisP_Ub8_Proteasome (molecules)');
    LEGEND_RATES(:,26) = strpad('d/dt ATP in component ATP (molecules)');
    LEGEND_RATES(:,27) = strpad('d/dt ADP in component ADP (molecules)');
    LEGEND_RATES(:,28) = strpad('d/dt AMP in component AMP (molecules)');
    LEGEND_RATES(:,29) = strpad('d/dt degUb4 in component degUb4 (molecules)');
    LEGEND_RATES(:,30) = strpad('d/dt degUb5 in component degUb5 (molecules)');
    LEGEND_RATES(:,31) = strpad('d/dt degUb6 in component degUb6 (molecules)');
    LEGEND_RATES(:,32) = strpad('d/dt degUb7 in component degUb7 (molecules)');
    LEGEND_RATES(:,33) = strpad('d/dt degUb8 in component degUb8 (molecules)');
    LEGEND_RATES(:,34) = strpad('d/dt MisP_total in component MisP_total (molecules)');
    LEGEND_RATES(:,35) = strpad('d/dt NatP_refolded in component NatP_refolded (molecules)');
    LEGEND_RATES(:,36) = strpad('d/dt AggP in component AggP (molecules)');
    LEGEND_RATES(:,37) = strpad('d/dt SeqAggP in component SeqAggP (molecules)');
    LEGEND_RATES(:,38) = strpad('d/dt AggP_Proteasome in component AggP_Proteasome (molecules)');
    LEGEND_STATES  = LEGEND_STATES';
    LEGEND_ALGEBRAIC = LEGEND_ALGEBRAIC';
    LEGEND_RATES = LEGEND_RATES';
    LEGEND_CONSTANTS = LEGEND_CONSTANTS';
end

function [STATES, CONSTANTS] = initConsts()
    VOI = 0; CONSTANTS = []; STATES = []; ALGEBRAIC = [];
    STATES(:,1) = 500;
    STATES(:,2) = 0;
    STATES(:,3) = 500;
    STATES(:,4) = 100;
    STATES(:,5) = 100;
    STATES(:,6) = 100;
    STATES(:,7) = 200;
    STATES(:,8) = 100;
    STATES(:,9) = 10;
    STATES(:,10) = 0;
    STATES(:,11) = 0;
    STATES(:,12) = 0;
    STATES(:,13) = 0;
    STATES(:,14) = 0;
    STATES(:,15) = 0;
    STATES(:,16) = 0;
    STATES(:,17) = 0;
    STATES(:,18) = 0;
    STATES(:,19) = 0;
    STATES(:,20) = 0;
    STATES(:,21) = 0;
    STATES(:,22) = 0;
    STATES(:,23) = 0;
    STATES(:,24) = 0;
    STATES(:,25) = 0;
    STATES(:,26) = 10000;
    STATES(:,27) = 1000;
    STATES(:,28) = 1000;
    STATES(:,29) = 0;
    STATES(:,30) = 0;
    STATES(:,31) = 0;
    STATES(:,32) = 0;
    STATES(:,33) = 0;
    STATES(:,34) = 0;
    STATES(:,35) = 0;
    STATES(:,36) = 0;
    STATES(:,37) = 0;
    STATES(:,38) = 0;
    CONSTANTS(:,1) = 0.01;
    CONSTANTS(:,2) = 2e-6;
    CONSTANTS(:,3) = 4e-6;
    CONSTANTS(:,4) = 1.7e-5;
    CONSTANTS(:,5) = 2e-4;
    CONSTANTS(:,6) = 2e-4;
    CONSTANTS(:,7) = 1e-3;
    CONSTANTS(:,8) = 1e-3;
    CONSTANTS(:,9) = 1e-3;
    CONSTANTS(:,10) = 1e-5;
    CONSTANTS(:,11) = 1e-5;
    CONSTANTS(:,12) = 1e-5;
    CONSTANTS(:,13) = 0;
    CONSTANTS(:,14) = 1e-8;
    CONSTANTS(:,15) = 1e-8;
    CONSTANTS(:,16) = 1e-3;
    CONSTANTS(:,17) = 1e-5;
    CONSTANTS(:,18) = CONSTANTS(:,1);
    CONSTANTS(:,18) = 0.00000;
    CONSTANTS(:,19) = 0.00000;
    CONSTANTS(:,20) = 0.00000;
    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(:,26) = CONSTANTS(:,18);
    RATES(:,27) = CONSTANTS(:,19);
    RATES(:,28) = CONSTANTS(:,20);
    ALGEBRAIC(:,1) =  CONSTANTS(:,2).*STATES(:,1).*STATES(:,9);
    RATES(:,9) = ALGEBRAIC(:,1) - ALGEBRAIC(:,1);
    RATES(:,34) = ALGEBRAIC(:,1);
    ALGEBRAIC(:,2) =  CONSTANTS(:,3).*STATES(:,2);
    RATES(:,1) = (CONSTANTS(:,18)+ALGEBRAIC(:,2)) - ALGEBRAIC(:,1);
    RATES(:,35) = ALGEBRAIC(:,2);
    ALGEBRAIC(:,5) = ( CONSTANTS(:,6).*STATES(:,4).*STATES(:,3).*STATES(:,26))./(5000.00+STATES(:,26));
    ALGEBRAIC(:,6) =  CONSTANTS(:,7).*STATES(:,5).*STATES(:,10);
    RATES(:,4) = ALGEBRAIC(:,6) - ALGEBRAIC(:,5);
    RATES(:,10) = ALGEBRAIC(:,5) - ALGEBRAIC(:,6);
    ALGEBRAIC(:,4) =  CONSTANTS(:,5).*STATES(:,12);
    ALGEBRAIC(:,3) =  CONSTANTS(:,4).*STATES(:,6).*STATES(:,2);
    ALGEBRAIC(:,7) =  CONSTANTS(:,8).*STATES(:,11).*STATES(:,12);
    RATES(:,6) = (ALGEBRAIC(:,4)+ALGEBRAIC(:,7)) - ALGEBRAIC(:,3);
    RATES(:,12) = (ALGEBRAIC(:,3) - ALGEBRAIC(:,4)) - ALGEBRAIC(:,7);
    ALGEBRAIC(:,8) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,13);
    ALGEBRAIC(:,9) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,14);
    ALGEBRAIC(:,10) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,15);
    ALGEBRAIC(:,11) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,16);
    ALGEBRAIC(:,12) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,17);
    ALGEBRAIC(:,13) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,18);
    ALGEBRAIC(:,14) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,19);
    RATES(:,5) = (ALGEBRAIC(:,7)+ALGEBRAIC(:,8)+ALGEBRAIC(:,9)+ALGEBRAIC(:,10)+ALGEBRAIC(:,11)+ALGEBRAIC(:,12)+ALGEBRAIC(:,13)+ALGEBRAIC(:,14)) - ALGEBRAIC(:,6);
    RATES(:,11) = (((((((ALGEBRAIC(:,6) - ALGEBRAIC(:,7)) - ALGEBRAIC(:,8)) - ALGEBRAIC(:,9)) - ALGEBRAIC(:,10)) - ALGEBRAIC(:,11)) - ALGEBRAIC(:,12)) - ALGEBRAIC(:,13)) - ALGEBRAIC(:,14);
    ALGEBRAIC(:,22) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,13);
    ALGEBRAIC(:,15) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,20);
    ALGEBRAIC(:,16) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,19);
    ALGEBRAIC(:,17) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,18);
    ALGEBRAIC(:,18) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,17);
    ALGEBRAIC(:,19) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,16);
    ALGEBRAIC(:,20) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,15);
    ALGEBRAIC(:,21) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,14);
    ALGEBRAIC(:,28) =  CONSTANTS(:,12).*STATES(:,7).*STATES(:,21);
    ALGEBRAIC(:,29) =  CONSTANTS(:,12).*STATES(:,7).*STATES(:,22);
    ALGEBRAIC(:,30) =  CONSTANTS(:,12).*STATES(:,7).*STATES(:,23);
    ALGEBRAIC(:,31) =  CONSTANTS(:,12).*STATES(:,7).*STATES(:,24);
    ALGEBRAIC(:,32) =  CONSTANTS(:,12).*STATES(:,7).*STATES(:,25);
    RATES(:,7) = (ALGEBRAIC(:,15)+ALGEBRAIC(:,16)+ALGEBRAIC(:,17)+ALGEBRAIC(:,18)+ALGEBRAIC(:,19)+ALGEBRAIC(:,20)+ALGEBRAIC(:,21)+ALGEBRAIC(:,22)+ALGEBRAIC(:,28)+ALGEBRAIC(:,29)+ALGEBRAIC(:,30)+ALGEBRAIC(:,31)+ALGEBRAIC(:,32)) - (ALGEBRAIC(:,15)+ALGEBRAIC(:,16)+ALGEBRAIC(:,17)+ALGEBRAIC(:,18)+ALGEBRAIC(:,19)+ALGEBRAIC(:,20)+ALGEBRAIC(:,21)+ALGEBRAIC(:,22)+ALGEBRAIC(:,28)+ALGEBRAIC(:,29)+ALGEBRAIC(:,30)+ALGEBRAIC(:,31)+ALGEBRAIC(:,32));
    ALGEBRAIC(:,33) = ( CONSTANTS(:,13).*STATES(:,21).*STATES(:,26))./(5000.00+STATES(:,26));
    ALGEBRAIC(:,23) =  CONSTANTS(:,11).*STATES(:,16).*STATES(:,8);
    RATES(:,21) = (ALGEBRAIC(:,23)+ALGEBRAIC(:,29)) - (ALGEBRAIC(:,28)+ALGEBRAIC(:,33));
    RATES(:,29) = ALGEBRAIC(:,33);
    ALGEBRAIC(:,34) = ( CONSTANTS(:,13).*STATES(:,22).*STATES(:,26))./(5000.00+STATES(:,26));
    ALGEBRAIC(:,24) =  CONSTANTS(:,11).*STATES(:,17).*STATES(:,8);
    RATES(:,22) = (ALGEBRAIC(:,24)+ALGEBRAIC(:,30)) - (ALGEBRAIC(:,29)+ALGEBRAIC(:,34));
    RATES(:,30) = ALGEBRAIC(:,34);
    ALGEBRAIC(:,35) = ( CONSTANTS(:,13).*STATES(:,23).*STATES(:,26))./(5000.00+STATES(:,26));
    ALGEBRAIC(:,25) =  CONSTANTS(:,11).*STATES(:,18).*STATES(:,8);
    RATES(:,23) = (ALGEBRAIC(:,25)+ALGEBRAIC(:,31)) - (ALGEBRAIC(:,30)+ALGEBRAIC(:,35));
    RATES(:,31) = ALGEBRAIC(:,35);
    ALGEBRAIC(:,36) = ( CONSTANTS(:,13).*STATES(:,24).*STATES(:,26))./(5000.00+STATES(:,26));
    ALGEBRAIC(:,26) =  CONSTANTS(:,11).*STATES(:,19).*STATES(:,8);
    RATES(:,24) = (ALGEBRAIC(:,26)+ALGEBRAIC(:,32)) - (ALGEBRAIC(:,31)+ALGEBRAIC(:,36));
    RATES(:,32) = ALGEBRAIC(:,36);
    ALGEBRAIC(:,37) = ( CONSTANTS(:,13).*STATES(:,25).*STATES(:,26))./(5000.00+STATES(:,26));
    RATES(:,3) = (ALGEBRAIC(:,15)+ALGEBRAIC(:,16)+ALGEBRAIC(:,17)+ALGEBRAIC(:,18)+ALGEBRAIC(:,19)+ALGEBRAIC(:,20)+ALGEBRAIC(:,21)+ALGEBRAIC(:,22)+ALGEBRAIC(:,28)+ALGEBRAIC(:,29)+ALGEBRAIC(:,30)+ALGEBRAIC(:,31)+ALGEBRAIC(:,32)+ 4.00000.*ALGEBRAIC(:,33)+ 5.00000.*ALGEBRAIC(:,34)+ 6.00000.*ALGEBRAIC(:,35)+ 7.00000.*ALGEBRAIC(:,36)+ 8.00000.*ALGEBRAIC(:,37)) - ALGEBRAIC(:,5);
    ALGEBRAIC(:,27) =  CONSTANTS(:,11).*STATES(:,20).*STATES(:,8);
    RATES(:,25) = ALGEBRAIC(:,27) - (ALGEBRAIC(:,32)+ALGEBRAIC(:,37));
    RATES(:,33) = ALGEBRAIC(:,37);
    ALGEBRAIC(:,38) = ( CONSTANTS(:,14).*STATES(:,2).*(STATES(:,2) - 1.00000))./2.00000;
    ALGEBRAIC(:,39) =  CONSTANTS(:,14).*STATES(:,2).*STATES(:,36);
    ALGEBRAIC(:,48) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,13);
    ALGEBRAIC(:,49) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,14);
    ALGEBRAIC(:,50) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,15);
    ALGEBRAIC(:,51) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,16);
    ALGEBRAIC(:,52) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,17);
    ALGEBRAIC(:,53) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,18);
    ALGEBRAIC(:,54) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,19);
    ALGEBRAIC(:,55) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,20);
    RATES(:,2) = (ALGEBRAIC(:,1)+ALGEBRAIC(:,4)+ALGEBRAIC(:,22)) - (ALGEBRAIC(:,2)+ALGEBRAIC(:,3)+ 2.00000.*ALGEBRAIC(:,38)+ALGEBRAIC(:,39)+ALGEBRAIC(:,48)+ALGEBRAIC(:,49)+ALGEBRAIC(:,50)+ALGEBRAIC(:,51)+ALGEBRAIC(:,52)+ALGEBRAIC(:,53)+ALGEBRAIC(:,54)+ALGEBRAIC(:,55));
    ALGEBRAIC(:,40) = ( CONSTANTS(:,15).*STATES(:,13).*(STATES(:,13) - 1.00000))./2.00000;
    ALGEBRAIC(:,56) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,13);
    ALGEBRAIC(:,64) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,14);
    ALGEBRAIC(:,65) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,15);
    ALGEBRAIC(:,66) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,16);
    ALGEBRAIC(:,67) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,17);
    ALGEBRAIC(:,68) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,18);
    ALGEBRAIC(:,69) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,19);
    ALGEBRAIC(:,70) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,20);
    RATES(:,13) = (ALGEBRAIC(:,7)+ALGEBRAIC(:,21)) - (ALGEBRAIC(:,8)+ALGEBRAIC(:,22)+ 2.00000.*ALGEBRAIC(:,40)+ALGEBRAIC(:,48)+ALGEBRAIC(:,56)+ALGEBRAIC(:,64)+ALGEBRAIC(:,65)+ALGEBRAIC(:,66)+ALGEBRAIC(:,67)+ALGEBRAIC(:,68)+ALGEBRAIC(:,69)+ALGEBRAIC(:,70));
    ALGEBRAIC(:,41) = ( CONSTANTS(:,15).*STATES(:,14).*(STATES(:,14) - 1.00000))./2.00000;
    ALGEBRAIC(:,57) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,14);
    ALGEBRAIC(:,71) =  CONSTANTS(:,15).*STATES(:,14).*STATES(:,15);
    ALGEBRAIC(:,72) =  CONSTANTS(:,15).*STATES(:,14).*STATES(:,16);
    ALGEBRAIC(:,73) =  CONSTANTS(:,15).*STATES(:,14).*STATES(:,17);
    ALGEBRAIC(:,74) =  CONSTANTS(:,15).*STATES(:,14).*STATES(:,18);
    ALGEBRAIC(:,75) =  CONSTANTS(:,15).*STATES(:,14).*STATES(:,19);
    ALGEBRAIC(:,76) =  CONSTANTS(:,15).*STATES(:,14).*STATES(:,20);
    RATES(:,14) = (ALGEBRAIC(:,8)+ALGEBRAIC(:,20)) - (ALGEBRAIC(:,9)+ALGEBRAIC(:,21)+ 2.00000.*ALGEBRAIC(:,41)+ALGEBRAIC(:,49)+ALGEBRAIC(:,57)+ALGEBRAIC(:,64)+ALGEBRAIC(:,71)+ALGEBRAIC(:,72)+ALGEBRAIC(:,73)+ALGEBRAIC(:,74)+ALGEBRAIC(:,75)+ALGEBRAIC(:,76));
    ALGEBRAIC(:,42) = ( CONSTANTS(:,15).*STATES(:,15).*(STATES(:,15) - 1.00000))./2.00000;
    ALGEBRAIC(:,58) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,15);
    ALGEBRAIC(:,77) =  CONSTANTS(:,15).*STATES(:,15).*STATES(:,16);
    ALGEBRAIC(:,78) =  CONSTANTS(:,15).*STATES(:,15).*STATES(:,17);
    ALGEBRAIC(:,79) =  CONSTANTS(:,15).*STATES(:,15).*STATES(:,18);
    ALGEBRAIC(:,80) =  CONSTANTS(:,15).*STATES(:,15).*STATES(:,19);
    ALGEBRAIC(:,81) =  CONSTANTS(:,15).*STATES(:,15).*STATES(:,20);
    RATES(:,15) = (ALGEBRAIC(:,9)+ALGEBRAIC(:,19)+ALGEBRAIC(:,28)) - (ALGEBRAIC(:,10)+ALGEBRAIC(:,20)+ 2.00000.*ALGEBRAIC(:,42)+ALGEBRAIC(:,50)+ALGEBRAIC(:,58)+ALGEBRAIC(:,65)+ALGEBRAIC(:,71)+ALGEBRAIC(:,77)+ALGEBRAIC(:,78)+ALGEBRAIC(:,79)+ALGEBRAIC(:,80)+ALGEBRAIC(:,81));
    ALGEBRAIC(:,43) = ( CONSTANTS(:,15).*STATES(:,16).*(STATES(:,16) - 1.00000))./2.00000;
    ALGEBRAIC(:,59) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,16);
    ALGEBRAIC(:,82) =  CONSTANTS(:,15).*STATES(:,16).*STATES(:,17);
    ALGEBRAIC(:,83) =  CONSTANTS(:,15).*STATES(:,16).*STATES(:,18);
    ALGEBRAIC(:,84) =  CONSTANTS(:,15).*STATES(:,16).*STATES(:,19);
    ALGEBRAIC(:,85) =  CONSTANTS(:,15).*STATES(:,16).*STATES(:,20);
    RATES(:,16) = (ALGEBRAIC(:,10)+ALGEBRAIC(:,18)) - (ALGEBRAIC(:,11)+ALGEBRAIC(:,19)+ALGEBRAIC(:,23)+ 2.00000.*ALGEBRAIC(:,43)+ALGEBRAIC(:,51)+ALGEBRAIC(:,59)+ALGEBRAIC(:,66)+ALGEBRAIC(:,72)+ALGEBRAIC(:,77)+ALGEBRAIC(:,82)+ALGEBRAIC(:,83)+ALGEBRAIC(:,84)+ALGEBRAIC(:,85));
    ALGEBRAIC(:,44) = ( CONSTANTS(:,15).*STATES(:,17).*(STATES(:,17) - 1.00000))./2.00000;
    ALGEBRAIC(:,60) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,17);
    ALGEBRAIC(:,86) =  CONSTANTS(:,15).*STATES(:,17).*STATES(:,18);
    ALGEBRAIC(:,87) =  CONSTANTS(:,15).*STATES(:,17).*STATES(:,19);
    ALGEBRAIC(:,88) =  CONSTANTS(:,15).*STATES(:,17).*STATES(:,20);
    RATES(:,17) = (ALGEBRAIC(:,11)+ALGEBRAIC(:,17)) - (ALGEBRAIC(:,12)+ALGEBRAIC(:,18)+ALGEBRAIC(:,24)+ 2.00000.*ALGEBRAIC(:,44)+ALGEBRAIC(:,52)+ALGEBRAIC(:,60)+ALGEBRAIC(:,67)+ALGEBRAIC(:,73)+ALGEBRAIC(:,78)+ALGEBRAIC(:,82)+ALGEBRAIC(:,86)+ALGEBRAIC(:,87)+ALGEBRAIC(:,88));
    ALGEBRAIC(:,45) = ( CONSTANTS(:,15).*STATES(:,18).*(STATES(:,18) - 1.00000))./2.00000;
    ALGEBRAIC(:,61) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,18);
    ALGEBRAIC(:,89) =  CONSTANTS(:,15).*STATES(:,18).*STATES(:,19);
    ALGEBRAIC(:,90) =  CONSTANTS(:,15).*STATES(:,18).*STATES(:,20);
    RATES(:,18) = (ALGEBRAIC(:,12)+ALGEBRAIC(:,16)) - (ALGEBRAIC(:,13)+ALGEBRAIC(:,17)+ALGEBRAIC(:,25)+ 2.00000.*ALGEBRAIC(:,45)+ALGEBRAIC(:,53)+ALGEBRAIC(:,61)+ALGEBRAIC(:,68)+ALGEBRAIC(:,74)+ALGEBRAIC(:,79)+ALGEBRAIC(:,83)+ALGEBRAIC(:,86)+ALGEBRAIC(:,89)+ALGEBRAIC(:,90));
    ALGEBRAIC(:,46) = ( CONSTANTS(:,15).*STATES(:,19).*(STATES(:,19) - 1.00000))./2.00000;
    ALGEBRAIC(:,62) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,19);
    ALGEBRAIC(:,91) =  CONSTANTS(:,15).*STATES(:,19).*STATES(:,20);
    RATES(:,19) = (ALGEBRAIC(:,13)+ALGEBRAIC(:,15)) - (ALGEBRAIC(:,14)+ALGEBRAIC(:,16)+ALGEBRAIC(:,26)+ 2.00000.*ALGEBRAIC(:,46)+ALGEBRAIC(:,54)+ALGEBRAIC(:,62)+ALGEBRAIC(:,69)+ALGEBRAIC(:,75)+ALGEBRAIC(:,80)+ALGEBRAIC(:,84)+ALGEBRAIC(:,87)+ALGEBRAIC(:,89)+ALGEBRAIC(:,91));
    ALGEBRAIC(:,47) = ( CONSTANTS(:,15).*STATES(:,20).*(STATES(:,20) - 1.00000))./2.00000;
    ALGEBRAIC(:,63) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,20);
    RATES(:,20) = ALGEBRAIC(:,14) - (ALGEBRAIC(:,15)+ALGEBRAIC(:,27)+ 2.00000.*ALGEBRAIC(:,47)+ALGEBRAIC(:,55)+ALGEBRAIC(:,63)+ALGEBRAIC(:,70)+ALGEBRAIC(:,76)+ALGEBRAIC(:,81)+ALGEBRAIC(:,85)+ALGEBRAIC(:,88)+ALGEBRAIC(:,90)+ALGEBRAIC(:,91));
    ALGEBRAIC(:,92) =  CONSTANTS(:,16).*STATES(:,36);
    RATES(:,37) = ALGEBRAIC(:,92);
    ALGEBRAIC(:,93) =  CONSTANTS(:,17).*STATES(:,36).*STATES(:,8);
    RATES(:,8) = (ALGEBRAIC(:,28)+ALGEBRAIC(:,33)+ALGEBRAIC(:,34)+ALGEBRAIC(:,35)+ALGEBRAIC(:,36)+ALGEBRAIC(:,37)) - (ALGEBRAIC(:,23)+ALGEBRAIC(:,24)+ALGEBRAIC(:,25)+ALGEBRAIC(:,26)+ALGEBRAIC(:,27)+ALGEBRAIC(:,93));
    RATES(:,36) = (ALGEBRAIC(:,38)+ 2.00000.*ALGEBRAIC(:,39)+ALGEBRAIC(:,40)+ALGEBRAIC(:,41)+ALGEBRAIC(:,42)+ALGEBRAIC(:,43)+ALGEBRAIC(:,44)+ALGEBRAIC(:,45)+ALGEBRAIC(:,46)+ALGEBRAIC(:,47)+ALGEBRAIC(:,48)+ALGEBRAIC(:,49)+ALGEBRAIC(:,50)+ALGEBRAIC(:,51)+ALGEBRAIC(:,52)+ALGEBRAIC(:,53)+ALGEBRAIC(:,54)+ALGEBRAIC(:,55)+ 2.00000.*ALGEBRAIC(:,56)+ 2.00000.*ALGEBRAIC(:,57)+ 2.00000.*ALGEBRAIC(:,58)+ 2.00000.*ALGEBRAIC(:,59)+ 2.00000.*ALGEBRAIC(:,60)+ 2.00000.*ALGEBRAIC(:,61)+ 2.00000.*ALGEBRAIC(:,62)+ 2.00000.*ALGEBRAIC(:,63)+ALGEBRAIC(:,64)+ALGEBRAIC(:,65)+ALGEBRAIC(:,66)+ALGEBRAIC(:,67)+ALGEBRAIC(:,68)+ALGEBRAIC(:,69)+ALGEBRAIC(:,70)+ALGEBRAIC(:,71)+ALGEBRAIC(:,72)+ALGEBRAIC(:,73)+ALGEBRAIC(:,74)+ALGEBRAIC(:,75)+ALGEBRAIC(:,76)+ALGEBRAIC(:,77)+ALGEBRAIC(:,78)+ALGEBRAIC(:,79)+ALGEBRAIC(:,80)+ALGEBRAIC(:,81)+ALGEBRAIC(:,82)+ALGEBRAIC(:,83)+ALGEBRAIC(:,84)+ALGEBRAIC(:,85)+ALGEBRAIC(:,86)+ALGEBRAIC(:,87)+ALGEBRAIC(:,88)+ALGEBRAIC(:,89)+ALGEBRAIC(:,90)+ALGEBRAIC(:,91)) - (ALGEBRAIC(:,39)+ALGEBRAIC(:,56)+ALGEBRAIC(:,57)+ALGEBRAIC(:,58)+ALGEBRAIC(:,59)+ALGEBRAIC(:,60)+ALGEBRAIC(:,61)+ALGEBRAIC(:,62)+ALGEBRAIC(:,63)+ALGEBRAIC(:,92)+ALGEBRAIC(:,93));
    RATES(:,38) = ALGEBRAIC(:,93);
   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) =  CONSTANTS(:,2).*STATES(:,1).*STATES(:,9);
    ALGEBRAIC(:,2) =  CONSTANTS(:,3).*STATES(:,2);
    ALGEBRAIC(:,5) = ( CONSTANTS(:,6).*STATES(:,4).*STATES(:,3).*STATES(:,26))./(5000.00+STATES(:,26));
    ALGEBRAIC(:,6) =  CONSTANTS(:,7).*STATES(:,5).*STATES(:,10);
    ALGEBRAIC(:,4) =  CONSTANTS(:,5).*STATES(:,12);
    ALGEBRAIC(:,3) =  CONSTANTS(:,4).*STATES(:,6).*STATES(:,2);
    ALGEBRAIC(:,7) =  CONSTANTS(:,8).*STATES(:,11).*STATES(:,12);
    ALGEBRAIC(:,8) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,13);
    ALGEBRAIC(:,9) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,14);
    ALGEBRAIC(:,10) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,15);
    ALGEBRAIC(:,11) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,16);
    ALGEBRAIC(:,12) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,17);
    ALGEBRAIC(:,13) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,18);
    ALGEBRAIC(:,14) =  CONSTANTS(:,9).*STATES(:,11).*STATES(:,19);
    ALGEBRAIC(:,22) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,13);
    ALGEBRAIC(:,15) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,20);
    ALGEBRAIC(:,16) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,19);
    ALGEBRAIC(:,17) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,18);
    ALGEBRAIC(:,18) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,17);
    ALGEBRAIC(:,19) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,16);
    ALGEBRAIC(:,20) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,15);
    ALGEBRAIC(:,21) =  CONSTANTS(:,10).*STATES(:,7).*STATES(:,14);
    ALGEBRAIC(:,28) =  CONSTANTS(:,12).*STATES(:,7).*STATES(:,21);
    ALGEBRAIC(:,29) =  CONSTANTS(:,12).*STATES(:,7).*STATES(:,22);
    ALGEBRAIC(:,30) =  CONSTANTS(:,12).*STATES(:,7).*STATES(:,23);
    ALGEBRAIC(:,31) =  CONSTANTS(:,12).*STATES(:,7).*STATES(:,24);
    ALGEBRAIC(:,32) =  CONSTANTS(:,12).*STATES(:,7).*STATES(:,25);
    ALGEBRAIC(:,33) = ( CONSTANTS(:,13).*STATES(:,21).*STATES(:,26))./(5000.00+STATES(:,26));
    ALGEBRAIC(:,23) =  CONSTANTS(:,11).*STATES(:,16).*STATES(:,8);
    ALGEBRAIC(:,34) = ( CONSTANTS(:,13).*STATES(:,22).*STATES(:,26))./(5000.00+STATES(:,26));
    ALGEBRAIC(:,24) =  CONSTANTS(:,11).*STATES(:,17).*STATES(:,8);
    ALGEBRAIC(:,35) = ( CONSTANTS(:,13).*STATES(:,23).*STATES(:,26))./(5000.00+STATES(:,26));
    ALGEBRAIC(:,25) =  CONSTANTS(:,11).*STATES(:,18).*STATES(:,8);
    ALGEBRAIC(:,36) = ( CONSTANTS(:,13).*STATES(:,24).*STATES(:,26))./(5000.00+STATES(:,26));
    ALGEBRAIC(:,26) =  CONSTANTS(:,11).*STATES(:,19).*STATES(:,8);
    ALGEBRAIC(:,37) = ( CONSTANTS(:,13).*STATES(:,25).*STATES(:,26))./(5000.00+STATES(:,26));
    ALGEBRAIC(:,27) =  CONSTANTS(:,11).*STATES(:,20).*STATES(:,8);
    ALGEBRAIC(:,38) = ( CONSTANTS(:,14).*STATES(:,2).*(STATES(:,2) - 1.00000))./2.00000;
    ALGEBRAIC(:,39) =  CONSTANTS(:,14).*STATES(:,2).*STATES(:,36);
    ALGEBRAIC(:,48) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,13);
    ALGEBRAIC(:,49) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,14);
    ALGEBRAIC(:,50) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,15);
    ALGEBRAIC(:,51) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,16);
    ALGEBRAIC(:,52) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,17);
    ALGEBRAIC(:,53) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,18);
    ALGEBRAIC(:,54) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,19);
    ALGEBRAIC(:,55) =  CONSTANTS(:,15).*STATES(:,2).*STATES(:,20);
    ALGEBRAIC(:,40) = ( CONSTANTS(:,15).*STATES(:,13).*(STATES(:,13) - 1.00000))./2.00000;
    ALGEBRAIC(:,56) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,13);
    ALGEBRAIC(:,64) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,14);
    ALGEBRAIC(:,65) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,15);
    ALGEBRAIC(:,66) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,16);
    ALGEBRAIC(:,67) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,17);
    ALGEBRAIC(:,68) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,18);
    ALGEBRAIC(:,69) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,19);
    ALGEBRAIC(:,70) =  CONSTANTS(:,15).*STATES(:,13).*STATES(:,20);
    ALGEBRAIC(:,41) = ( CONSTANTS(:,15).*STATES(:,14).*(STATES(:,14) - 1.00000))./2.00000;
    ALGEBRAIC(:,57) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,14);
    ALGEBRAIC(:,71) =  CONSTANTS(:,15).*STATES(:,14).*STATES(:,15);
    ALGEBRAIC(:,72) =  CONSTANTS(:,15).*STATES(:,14).*STATES(:,16);
    ALGEBRAIC(:,73) =  CONSTANTS(:,15).*STATES(:,14).*STATES(:,17);
    ALGEBRAIC(:,74) =  CONSTANTS(:,15).*STATES(:,14).*STATES(:,18);
    ALGEBRAIC(:,75) =  CONSTANTS(:,15).*STATES(:,14).*STATES(:,19);
    ALGEBRAIC(:,76) =  CONSTANTS(:,15).*STATES(:,14).*STATES(:,20);
    ALGEBRAIC(:,42) = ( CONSTANTS(:,15).*STATES(:,15).*(STATES(:,15) - 1.00000))./2.00000;
    ALGEBRAIC(:,58) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,15);
    ALGEBRAIC(:,77) =  CONSTANTS(:,15).*STATES(:,15).*STATES(:,16);
    ALGEBRAIC(:,78) =  CONSTANTS(:,15).*STATES(:,15).*STATES(:,17);
    ALGEBRAIC(:,79) =  CONSTANTS(:,15).*STATES(:,15).*STATES(:,18);
    ALGEBRAIC(:,80) =  CONSTANTS(:,15).*STATES(:,15).*STATES(:,19);
    ALGEBRAIC(:,81) =  CONSTANTS(:,15).*STATES(:,15).*STATES(:,20);
    ALGEBRAIC(:,43) = ( CONSTANTS(:,15).*STATES(:,16).*(STATES(:,16) - 1.00000))./2.00000;
    ALGEBRAIC(:,59) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,16);
    ALGEBRAIC(:,82) =  CONSTANTS(:,15).*STATES(:,16).*STATES(:,17);
    ALGEBRAIC(:,83) =  CONSTANTS(:,15).*STATES(:,16).*STATES(:,18);
    ALGEBRAIC(:,84) =  CONSTANTS(:,15).*STATES(:,16).*STATES(:,19);
    ALGEBRAIC(:,85) =  CONSTANTS(:,15).*STATES(:,16).*STATES(:,20);
    ALGEBRAIC(:,44) = ( CONSTANTS(:,15).*STATES(:,17).*(STATES(:,17) - 1.00000))./2.00000;
    ALGEBRAIC(:,60) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,17);
    ALGEBRAIC(:,86) =  CONSTANTS(:,15).*STATES(:,17).*STATES(:,18);
    ALGEBRAIC(:,87) =  CONSTANTS(:,15).*STATES(:,17).*STATES(:,19);
    ALGEBRAIC(:,88) =  CONSTANTS(:,15).*STATES(:,17).*STATES(:,20);
    ALGEBRAIC(:,45) = ( CONSTANTS(:,15).*STATES(:,18).*(STATES(:,18) - 1.00000))./2.00000;
    ALGEBRAIC(:,61) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,18);
    ALGEBRAIC(:,89) =  CONSTANTS(:,15).*STATES(:,18).*STATES(:,19);
    ALGEBRAIC(:,90) =  CONSTANTS(:,15).*STATES(:,18).*STATES(:,20);
    ALGEBRAIC(:,46) = ( CONSTANTS(:,15).*STATES(:,19).*(STATES(:,19) - 1.00000))./2.00000;
    ALGEBRAIC(:,62) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,19);
    ALGEBRAIC(:,91) =  CONSTANTS(:,15).*STATES(:,19).*STATES(:,20);
    ALGEBRAIC(:,47) = ( CONSTANTS(:,15).*STATES(:,20).*(STATES(:,20) - 1.00000))./2.00000;
    ALGEBRAIC(:,63) =  CONSTANTS(:,15).*STATES(:,36).*STATES(:,20);
    ALGEBRAIC(:,92) =  CONSTANTS(:,16).*STATES(:,36);
    ALGEBRAIC(:,93) =  CONSTANTS(:,17).*STATES(:,36).*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