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 =0;
end
% There are a total of 77 entries in each of the rate and state variable arrays.
% There are a total of 200 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('t in component environment (s)');
    LEGEND_CONSTANTS(:,1) = strpad('Ca in component Calcium (um)');
    LEGEND_CONSTANTS(:,2) = strpad('GTP in component undefinedvariables (um)');
    LEGEND_CONSTANTS(:,3) = strpad('PKA in component undefinedvariables (um)');
    LEGEND_STATES(:,1) = strpad('PKC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,2) = strpad('GAP in component B_Model_Modules (um)');
    LEGEND_STATES(:,3) = strpad('Raf in component B_Model_Modules (um)');
    LEGEND_STATES(:,4) = strpad('GEF_star in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,5) = strpad('CaM_GEF in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,6) = strpad('Gbg_GEF in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,7) = strpad('CaGqPLC in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,8) = strpad('CaPLC in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,9) = strpad('NgCaM in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,10) = strpad('GEF in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,11) = strpad('Ng in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,12) = strpad('Gbg in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,13) = strpad('Ga_GDP in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,14) = strpad('mGluR in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,15) = strpad('PLC in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,16) = strpad('Ca2CaM in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,17) = strpad('Ca3CaM in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,18) = strpad('Ng_star in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,19) = strpad('Gabg in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,20) = strpad('R in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,21) = strpad('Gabg_R in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,22) = strpad('Glu_synapse in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,23) = strpad('Gabg_GluR in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,24) = strpad('Glu in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,25) = strpad('Ga_GTP in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,26) = strpad('GqPLC in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,27) = strpad('GEF_inact in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,28) = strpad('Ca4CAM in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,29) = strpad('CaM in component DGBM_Model_Modules (um)');
    LEGEND_CONSTANTS(:,4) = strpad('one in component DGBM_Model_Modules (dimensionless)');
    LEGEND_CONSTANTS(:,5) = strpad('kfD1 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,6) = strpad('kbD1 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,7) = strpad('kfD2 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,8) = strpad('kbD2 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,9) = strpad('kfD3 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,10) = strpad('kbD3 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,11) = strpad('kfD4 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,12) = strpad('kbD4 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,13) = strpad('kfD5 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,14) = strpad('kbD5 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,15) = strpad('kfD6 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,16) = strpad('kfD7 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,17) = strpad('kfD8 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,18) = strpad('kfD9 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,19) = strpad('kfG1 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,20) = strpad('kbG1 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,21) = strpad('kfG2 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,22) = strpad('kbG2 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,23) = strpad('kfG3 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,24) = strpad('kbG3 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,25) = strpad('kfG4 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,26) = strpad('kbG4 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,27) = strpad('kfG5 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,28) = strpad('kfB2 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,29) = strpad('kbB2 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,30) = strpad('kmB3 in component DGBM_Model_Modules (um)');
    LEGEND_CONSTANTS(:,31) = strpad('kfB5 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,32) = strpad('kbB5 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,33) = strpad('kfB7 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,34) = strpad('kbB7 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,35) = strpad('kfB8 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,36) = strpad('kbB8 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,37) = strpad('kmB1 in component DGBM_Model_Modules (um)');
    LEGEND_CONSTANTS(:,38) = strpad('VmaxB1 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,39) = strpad('kmB6 in component DGBM_Model_Modules (um)');
    LEGEND_CONSTANTS(:,40) = strpad('VmaxB6 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,41) = strpad('kfM1 in component DGBM_Model_Modules (per_um2_s)');
    LEGEND_CONSTANTS(:,42) = strpad('kbM1 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,43) = strpad('kfM2 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,44) = strpad('kbM2 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,45) = strpad('kfM3 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,46) = strpad('kbM3 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,47) = strpad('kfM4 in component DGBM_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,48) = strpad('kbM4 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,49) = strpad('kfM6 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,50) = strpad('kmM5 in component DGBM_Model_Modules (um)');
    LEGEND_CONSTANTS(:,51) = strpad('VmaxM5 in component DGBM_Model_Modules (um_per_s)');
    LEGEND_CONSTANTS(:,52) = strpad('kmM7 in component DGBM_Model_Modules (um)');
    LEGEND_CONSTANTS(:,53) = strpad('VmaxM7 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,54) = strpad('kmM8 in component DGBM_Model_Modules (um)');
    LEGEND_CONSTANTS(:,55) = strpad('VmaxM8 in component DGBM_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,56) = strpad('kmH1 in component DGBM_Model_Modules (um)');
    LEGEND_STATES(:,30) = strpad('SHCstar_SOS_GRB2 in component A_Model_Module_SHC (um)');
    LEGEND_STATES(:,31) = strpad('MAPK_star in component H_Model_Module_MAPK (um)');
    LEGEND_STATES(:,32) = strpad('SOS in component A_Model_Module_SHC (um)');
    LEGEND_STATES(:,33) = strpad('MAPKK_star_star in component H_Model_Module_MAPKK (um)');
    LEGEND_STATES(:,34) = strpad('MAPKK_star in component H_Model_Module_MAPKK (um)');
    LEGEND_STATES(:,35) = strpad('Raf_star in component B_Model_Modules (um)');
    LEGEND_STATES(:,36) = strpad('GTPRasRaf_star in component B_Model_Modules (um)');
    LEGEND_STATES(:,37) = strpad('Raf_star_star in component B_Model_Modules (um)');
    LEGEND_STATES(:,38) = strpad('GTP_RAS in component B_Model_Modules (um)');
    LEGEND_STATES(:,39) = strpad('GDP_RAS in component B_Model_Modules (um)');
    LEGEND_STATES(:,40) = strpad('GAPstar in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,57) = strpad('PP2A in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,58) = strpad('one in component B_Model_Modules (dimensionless)');
    LEGEND_CONSTANTS(:,59) = strpad('kfB12 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,60) = strpad('kbB12 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,61) = strpad('kmB9 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,62) = strpad('VmaxB9 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,63) = strpad('kmB10 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,64) = strpad('VmaxB10 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,65) = strpad('kmB11 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,66) = strpad('VmaxB11 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,67) = strpad('kmB13 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,68) = strpad('VmaxB13 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,69) = strpad('kfB4 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,70) = strpad('kbB4 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,71) = strpad('kmB3 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,72) = strpad('VmaxB3 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,73) = strpad('kmA7 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,74) = strpad('VmaxA7 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,75) = strpad('kfH5 in component B_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,76) = strpad('kbH5 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,77) = strpad('kmH1 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,78) = strpad('kmH2 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,79) = strpad('kmH3 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,80) = strpad('kmH4 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,81) = strpad('VmaxH1 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,82) = strpad('VmaxH2 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,83) = strpad('VmaxH3 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,84) = strpad('VmaxH4 in component B_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,85) = strpad('kmM8 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,86) = strpad('kmB6 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,87) = strpad('kmM7 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,88) = strpad('kmA9 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,89) = strpad('kmH8 in component B_Model_Modules (um)');
    LEGEND_CONSTANTS(:,90) = strpad('kmH9 in component B_Model_Modules (um)');
    LEGEND_STATES(:,41) = strpad('MAPKK in component H_Model_Module_MAPKK (um)');
    LEGEND_CONSTANTS(:,91) = strpad('PP2A in component H_Model_Module_MAPKK (um)');
    LEGEND_CONSTANTS(:,92) = strpad('one in component H_Model_Module_MAPKK (dimensionless)');
    LEGEND_CONSTANTS(:,93) = strpad('kmH6 in component H_Model_Module_MAPKK (um)');
    LEGEND_CONSTANTS(:,94) = strpad('kmH7 in component H_Model_Module_MAPKK (um)');
    LEGEND_CONSTANTS(:,95) = strpad('kmH8 in component H_Model_Module_MAPKK (um)');
    LEGEND_CONSTANTS(:,96) = strpad('kmH9 in component H_Model_Module_MAPKK (um)');
    LEGEND_CONSTANTS(:,97) = strpad('VmaxH6 in component H_Model_Module_MAPKK (per_s)');
    LEGEND_CONSTANTS(:,98) = strpad('VmaxH7 in component H_Model_Module_MAPKK (per_s)');
    LEGEND_CONSTANTS(:,99) = strpad('VmaxH8 in component H_Model_Module_MAPKK (per_s)');
    LEGEND_CONSTANTS(:,100) = strpad('VmaxH9 in component H_Model_Module_MAPKK (per_s)');
    LEGEND_CONSTANTS(:,101) = strpad('kmH3 in component H_Model_Module_MAPKK (um)');
    LEGEND_CONSTANTS(:,102) = strpad('kmH4 in component H_Model_Module_MAPKK (um)');
    LEGEND_STATES(:,42) = strpad('MAPK in component H_Model_Module_MAPK (um)');
    LEGEND_STATES(:,43) = strpad('MAPK_tyr in component H_Model_Module_MAPK (um)');
    LEGEND_CONSTANTS(:,103) = strpad('MKP1 in component H_Model_Module_MAPK (um)');
    LEGEND_CONSTANTS(:,104) = strpad('one in component H_Model_Module_MAPK (dimensionless)');
    LEGEND_CONSTANTS(:,105) = strpad('kmH10 in component H_Model_Module_MAPK (um)');
    LEGEND_CONSTANTS(:,106) = strpad('kmH11 in component H_Model_Module_MAPK (um)');
    LEGEND_CONSTANTS(:,107) = strpad('kmH12 in component H_Model_Module_MAPK (um)');
    LEGEND_CONSTANTS(:,108) = strpad('kmH13 in component H_Model_Module_MAPK (um)');
    LEGEND_CONSTANTS(:,109) = strpad('VmaxH10 in component H_Model_Module_MAPK (per_s)');
    LEGEND_CONSTANTS(:,110) = strpad('VmaxH11 in component H_Model_Module_MAPK (per_s)');
    LEGEND_CONSTANTS(:,111) = strpad('VmaxH12 in component H_Model_Module_MAPK (per_s)');
    LEGEND_CONSTANTS(:,112) = strpad('VmaxH13 in component H_Model_Module_MAPK (per_s)');
    LEGEND_STATES(:,44) = strpad('EGF_EGFR in component A_Model_Module_EGFR (um)');
    LEGEND_STATES(:,45) = strpad('CaPLCg in component F_Model_Module_PLC (um)');
    LEGEND_STATES(:,46) = strpad('SHC in component A_Model_Module_SHC (um)');
    LEGEND_STATES(:,47) = strpad('SHCstar in component A_Model_Module_SHC (um)');
    LEGEND_STATES(:,48) = strpad('SOSstar_GRB2 in component A_Model_Module_SHC (um)');
    LEGEND_STATES(:,49) = strpad('SOS_GRB2 in component A_Model_Module_SHC (um)');
    LEGEND_STATES(:,50) = strpad('GRB2 in component A_Model_Module_SHC (um)');
    LEGEND_STATES(:,51) = strpad('SOSstar in component A_Model_Module_SHC (um)');
    LEGEND_CONSTANTS(:,113) = strpad('one in component A_Model_Module_SHC (dimensionless)');
    LEGEND_CONSTANTS(:,114) = strpad('kmA3 in component A_Model_Module_SHC (um)');
    LEGEND_CONSTANTS(:,115) = strpad('kfA4 in component A_Model_Module_SHC (per_s)');
    LEGEND_CONSTANTS(:,116) = strpad('kbA4 in component A_Model_Module_SHC (per_s)');
    LEGEND_CONSTANTS(:,117) = strpad('kfA5 in component A_Model_Module_SHC (per_um_s)');
    LEGEND_CONSTANTS(:,118) = strpad('kbA5 in component A_Model_Module_SHC (per_s)');
    LEGEND_CONSTANTS(:,119) = strpad('kfA6 in component A_Model_Module_SHC (per_um_s)');
    LEGEND_CONSTANTS(:,120) = strpad('kbA6 in component A_Model_Module_SHC (per_s)');
    LEGEND_CONSTANTS(:,121) = strpad('kfA8 in component A_Model_Module_SHC (per_s)');
    LEGEND_CONSTANTS(:,122) = strpad('kbA8 in component A_Model_Module_SHC (per_s)');
    LEGEND_CONSTANTS(:,123) = strpad('kfA10 in component A_Model_Module_SHC (per_um_s)');
    LEGEND_CONSTANTS(:,124) = strpad('kbA10 in component A_Model_Module_SHC (per_s)');
    LEGEND_CONSTANTS(:,125) = strpad('kmA7 in component A_Model_Module_SHC (um)');
    LEGEND_CONSTANTS(:,126) = strpad('kmA9 in component A_Model_Module_SHC (um)');
    LEGEND_CONSTANTS(:,127) = strpad('VmaxA7 in component A_Model_Module_SHC (per_s)');
    LEGEND_CONSTANTS(:,128) = strpad('VmaxA3 in component A_Model_Module_SHC (per_s)');
    LEGEND_CONSTANTS(:,129) = strpad('VmaxA9 in component A_Model_Module_SHC (per_s)');
    LEGEND_CONSTANTS(:,130) = strpad('kmH2 in component A_Model_Module_SHC (um)');
    LEGEND_CONSTANTS(:,131) = strpad('kmF4 in component A_Model_Module_SHC (um)');
    LEGEND_STATES(:,52) = strpad('EGF_EGFR_INTERNAL in component A_Model_Module_EGFR (um)');
    LEGEND_STATES(:,53) = strpad('EGF in component A_Model_Module_EGFR (um)');
    LEGEND_STATES(:,54) = strpad('EGFR in component A_Model_Module_EGFR (um)');
    LEGEND_CONSTANTS(:,132) = strpad('kfA1 in component A_Model_Module_EGFR (per_um_s)');
    LEGEND_CONSTANTS(:,133) = strpad('kbA1 in component A_Model_Module_EGFR (per_s)');
    LEGEND_CONSTANTS(:,134) = strpad('kfA2 in component A_Model_Module_EGFR (per_s)');
    LEGEND_CONSTANTS(:,135) = strpad('kbA2 in component A_Model_Module_EGFR (per_s)');
    LEGEND_STATES(:,55) = strpad('CaPLCg_star in component F_Model_Module_PLC (um)');
    LEGEND_STATES(:,56) = strpad('PLCg in component F_Model_Module_PLC (um)');
    LEGEND_STATES(:,57) = strpad('PLCg_star in component F_Model_Module_PLC (um)');
    LEGEND_CONSTANTS(:,136) = strpad('kfF1 in component F_Model_Module_PLC (per_um_s)');
    LEGEND_CONSTANTS(:,137) = strpad('kbF1 in component F_Model_Module_PLC (per_s)');
    LEGEND_CONSTANTS(:,138) = strpad('kfF3 in component F_Model_Module_PLC (per_s)');
    LEGEND_CONSTANTS(:,139) = strpad('kfF5 in component F_Model_Module_PLC (per_um_s)');
    LEGEND_CONSTANTS(:,140) = strpad('kbF5 in component F_Model_Module_PLC (per_s)');
    LEGEND_CONSTANTS(:,141) = strpad('kmF4 in component F_Model_Module_PLC (um)');
    LEGEND_CONSTANTS(:,142) = strpad('VmaxF4 in component F_Model_Module_PLC (per_s)');
    LEGEND_CONSTANTS(:,143) = strpad('kmA3 in component F_Model_Module_PLC (um)');
    LEGEND_CONSTANTS(:,144) = strpad('one in component F_Model_Module_PLC (dimensionless)');
    LEGEND_STATES(:,58) = strpad('PKC_i in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,59) = strpad('DAGPKC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,60) = strpad('AADAGPKC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,61) = strpad('DAGCaPKC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,62) = strpad('CaPKC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,63) = strpad('AA in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,64) = strpad('APC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,65) = strpad('PIP2_star in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,66) = strpad('PLA2_cyt in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,67) = strpad('PLA2_star in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,68) = strpad('CaPLA2 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,69) = strpad('PIP2CaPLA2 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,70) = strpad('PIP2PLA2 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,71) = strpad('DAGCaPLA2 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,72) = strpad('CaPLA2_star in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,73) = strpad('PIP2 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,74) = strpad('DAG in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,75) = strpad('IP3 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,76) = strpad('Inositol in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_STATES(:,77) = strpad('PC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_CONSTANTS(:,145) = strpad('kfK1 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,146) = strpad('kbK1 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,147) = strpad('kfK2 in component KEL_DAGIP3_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,148) = strpad('kbK2 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,149) = strpad('kfK3 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,150) = strpad('kbK3 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,151) = strpad('kfK4 in component KEL_DAGIP3_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,152) = strpad('kbK4 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,153) = strpad('kfK5 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,154) = strpad('kbK5 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,155) = strpad('kfK6 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,156) = strpad('kbK6 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,157) = strpad('kfK7 in component KEL_DAGIP3_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,158) = strpad('kbK7 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,159) = strpad('kfK8 in component KEL_DAGIP3_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,160) = strpad('kbK8 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,161) = strpad('kfK9 in component KEL_DAGIP3_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,162) = strpad('kbK9 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,163) = strpad('kfK10 in component KEL_DAGIP3_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,164) = strpad('kbK10 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,165) = strpad('kfE1 in component KEL_DAGIP3_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,166) = strpad('kbE1 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,167) = strpad('kfE3 in component KEL_DAGIP3_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,168) = strpad('kbE3 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,169) = strpad('kfE5 in component KEL_DAGIP3_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,170) = strpad('kbE5 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,171) = strpad('kfE7 in component KEL_DAGIP3_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,172) = strpad('kbE7 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,173) = strpad('kfE10 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,174) = strpad('kbE10 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,175) = strpad('kfE11 in component KEL_DAGIP3_Model_Modules (per_um_s)');
    LEGEND_CONSTANTS(:,176) = strpad('kbE11 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,177) = strpad('kmE9 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_CONSTANTS(:,178) = strpad('VmaxE9 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,179) = strpad('kfE13 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,180) = strpad('kbE13 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,181) = strpad('kmE2 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_CONSTANTS(:,182) = strpad('kmE4 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_CONSTANTS(:,183) = strpad('kmE6 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_CONSTANTS(:,184) = strpad('kmE8 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_CONSTANTS(:,185) = strpad('kmE12 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_CONSTANTS(:,186) = strpad('VmaxE2 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,187) = strpad('VmaxE4 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,188) = strpad('VmaxE6 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,189) = strpad('VmaxE8 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,190) = strpad('VmaxE12 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,191) = strpad('kmF2 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_CONSTANTS(:,192) = strpad('kmF6 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_CONSTANTS(:,193) = strpad('VmaxF2 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,194) = strpad('VmaxF6 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,195) = strpad('kfG8 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,196) = strpad('kfG9 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,197) = strpad('kmG6 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_CONSTANTS(:,198) = strpad('VmaxG6 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_CONSTANTS(:,199) = strpad('kmG7 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_CONSTANTS(:,200) = strpad('VmaxG7 in component KEL_DAGIP3_Model_Modules (per_s)');
    LEGEND_RATES(:,13) = strpad('d/dt Ga_GDP in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,14) = strpad('d/dt mGluR in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,19) = strpad('d/dt Gabg in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,20) = strpad('d/dt R in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,12) = strpad('d/dt Gbg in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,21) = strpad('d/dt Gabg_R in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,22) = strpad('d/dt Glu_synapse in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,23) = strpad('d/dt Gabg_GluR in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,24) = strpad('d/dt Glu in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,25) = strpad('d/dt Ga_GTP in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,15) = strpad('d/dt PLC in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,26) = strpad('d/dt GqPLC in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,8) = strpad('d/dt CaPLC in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,7) = strpad('d/dt CaGqPLC in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,27) = strpad('d/dt GEF_inact in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,10) = strpad('d/dt GEF in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,5) = strpad('d/dt CaM_GEF in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,28) = strpad('d/dt Ca4CAM in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,6) = strpad('d/dt Gbg_GEF in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,4) = strpad('d/dt GEF_star in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,29) = strpad('d/dt CaM in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,9) = strpad('d/dt NgCaM in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,16) = strpad('d/dt Ca2CaM in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,17) = strpad('d/dt Ca3CaM in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,18) = strpad('d/dt Ng_star in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,11) = strpad('d/dt Ng in component DGBM_Model_Modules (um)');
    LEGEND_RATES(:,38) = strpad('d/dt GTP_RAS in component B_Model_Modules (um)');
    LEGEND_RATES(:,39) = strpad('d/dt GDP_RAS in component B_Model_Modules (um)');
    LEGEND_RATES(:,2) = strpad('d/dt GAP in component B_Model_Modules (um)');
    LEGEND_RATES(:,40) = strpad('d/dt GAPstar in component B_Model_Modules (um)');
    LEGEND_RATES(:,36) = strpad('d/dt GTPRasRaf_star in component B_Model_Modules (um)');
    LEGEND_RATES(:,3) = strpad('d/dt Raf in component B_Model_Modules (um)');
    LEGEND_RATES(:,35) = strpad('d/dt Raf_star in component B_Model_Modules (um)');
    LEGEND_RATES(:,37) = strpad('d/dt Raf_star_star in component B_Model_Modules (um)');
    LEGEND_RATES(:,41) = strpad('d/dt MAPKK in component H_Model_Module_MAPKK (um)');
    LEGEND_RATES(:,34) = strpad('d/dt MAPKK_star in component H_Model_Module_MAPKK (um)');
    LEGEND_RATES(:,33) = strpad('d/dt MAPKK_star_star in component H_Model_Module_MAPKK (um)');
    LEGEND_RATES(:,42) = strpad('d/dt MAPK in component H_Model_Module_MAPK (um)');
    LEGEND_RATES(:,43) = strpad('d/dt MAPK_tyr in component H_Model_Module_MAPK (um)');
    LEGEND_RATES(:,31) = strpad('d/dt MAPK_star in component H_Model_Module_MAPK (um)');
    LEGEND_RATES(:,47) = strpad('d/dt SHCstar in component A_Model_Module_SHC (um)');
    LEGEND_RATES(:,46) = strpad('d/dt SHC in component A_Model_Module_SHC (um)');
    LEGEND_RATES(:,30) = strpad('d/dt SHCstar_SOS_GRB2 in component A_Model_Module_SHC (um)');
    LEGEND_RATES(:,49) = strpad('d/dt SOS_GRB2 in component A_Model_Module_SHC (um)');
    LEGEND_RATES(:,32) = strpad('d/dt SOS in component A_Model_Module_SHC (um)');
    LEGEND_RATES(:,51) = strpad('d/dt SOSstar in component A_Model_Module_SHC (um)');
    LEGEND_RATES(:,48) = strpad('d/dt SOSstar_GRB2 in component A_Model_Module_SHC (um)');
    LEGEND_RATES(:,50) = strpad('d/dt GRB2 in component A_Model_Module_SHC (um)');
    LEGEND_RATES(:,53) = strpad('d/dt EGF in component A_Model_Module_EGFR (um)');
    LEGEND_RATES(:,54) = strpad('d/dt EGFR in component A_Model_Module_EGFR (um)');
    LEGEND_RATES(:,44) = strpad('d/dt EGF_EGFR in component A_Model_Module_EGFR (um)');
    LEGEND_RATES(:,52) = strpad('d/dt EGF_EGFR_INTERNAL in component A_Model_Module_EGFR (um)');
    LEGEND_RATES(:,56) = strpad('d/dt PLCg in component F_Model_Module_PLC (um)');
    LEGEND_RATES(:,45) = strpad('d/dt CaPLCg in component F_Model_Module_PLC (um)');
    LEGEND_RATES(:,55) = strpad('d/dt CaPLCg_star in component F_Model_Module_PLC (um)');
    LEGEND_RATES(:,57) = strpad('d/dt PLCg_star in component F_Model_Module_PLC (um)');
    LEGEND_RATES(:,58) = strpad('d/dt PKC_i in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,59) = strpad('d/dt DAGPKC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,60) = strpad('d/dt AADAGPKC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,62) = strpad('d/dt CaPKC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,61) = strpad('d/dt DAGCaPKC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,1) = strpad('d/dt PKC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,63) = strpad('d/dt AA in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,66) = strpad('d/dt PLA2_cyt in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,70) = strpad('d/dt PIP2PLA2 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,65) = strpad('d/dt PIP2_star in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,67) = strpad('d/dt PLA2_star in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,72) = strpad('d/dt CaPLA2_star in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,68) = strpad('d/dt CaPLA2 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,69) = strpad('d/dt PIP2CaPLA2 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,71) = strpad('d/dt DAGCaPLA2 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,64) = strpad('d/dt APC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,73) = strpad('d/dt PIP2 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,74) = strpad('d/dt DAG in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,75) = strpad('d/dt IP3 in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,77) = strpad('d/dt PC in component KEL_DAGIP3_Model_Modules (um)');
    LEGEND_RATES(:,76) = strpad('d/dt Inositol in component KEL_DAGIP3_Model_Modules (um)');
    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) = 0.5;
    CONSTANTS(:,3) = 0.1;
    STATES(:,1) = 0;
    STATES(:,2) = 0.002;
    STATES(:,3) = 0.2;
    STATES(:,4) = 0;
    STATES(:,5) = 0;
    STATES(:,6) = 0;
    STATES(:,7) = 0;
    STATES(:,8) = 0;
    STATES(:,9) = 0;
    STATES(:,10) = 0;
    STATES(:,11) = 10;
    STATES(:,12) = 0.1;
    STATES(:,13) = 1;
    STATES(:,14) = 0.3;
    STATES(:,15) = 0.8;
    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) = 0;
    STATES(:,27) = 0.1;
    STATES(:,28) = 0;
    STATES(:,29) = 20;
    CONSTANTS(:,4) = 1;
    CONSTANTS(:,5) = 500;
    CONSTANTS(:,6) = 1000;
    CONSTANTS(:,7) = 0.000028;
    CONSTANTS(:,8) = 0.1;
    CONSTANTS(:,9) = 0.000028;
    CONSTANTS(:,10) = 10;
    CONSTANTS(:,11) = 0.000001;
    CONSTANTS(:,12) = 1;
    CONSTANTS(:,13) = 0.00000001;
    CONSTANTS(:,14) = 0.0001;
    CONSTANTS(:,15) = 0.01;
    CONSTANTS(:,16) = 0.0133;
    CONSTANTS(:,17) = 0.00001;
    CONSTANTS(:,18) = 0.0001;
    CONSTANTS(:,19) = 0.000005;
    CONSTANTS(:,20) = 1;
    CONSTANTS(:,21) = 0.0000042;
    CONSTANTS(:,22) = 1;
    CONSTANTS(:,23) = 0.00005;
    CONSTANTS(:,24) = 1;
    CONSTANTS(:,25) = 0.0000042;
    CONSTANTS(:,26) = 1;
    CONSTANTS(:,27) = 0.0133;
    CONSTANTS(:,28) = 1;
    CONSTANTS(:,29) = 0;
    CONSTANTS(:,30) = 3.333333333333;
    CONSTANTS(:,31) = 0.0001;
    CONSTANTS(:,32) = 1;
    CONSTANTS(:,33) = 1;
    CONSTANTS(:,34) = 0;
    CONSTANTS(:,35) = 0.00001;
    CONSTANTS(:,36) = 1;
    CONSTANTS(:,37) = 7.5;
    CONSTANTS(:,38) = 9;
    CONSTANTS(:,39) = 3.33333333333;
    CONSTANTS(:,40) = 4;
    CONSTANTS(:,41) = 0.0000000002;
    CONSTANTS(:,42) = 72;
    CONSTANTS(:,43) = 0.000006;
    CONSTANTS(:,44) = 10;
    CONSTANTS(:,45) = 0.000000775;
    CONSTANTS(:,46) = 10;
    CONSTANTS(:,47) = 0.0000005;
    CONSTANTS(:,48) = 1;
    CONSTANTS(:,49) = 0.005;
    CONSTANTS(:,50) = 10.012;
    CONSTANTS(:,51) = 0.67;
    CONSTANTS(:,52) = 28.626667;
    CONSTANTS(:,53) = 0.58;
    CONSTANTS(:,54) = 28.595;
    CONSTANTS(:,55) = 0.35;
    CONSTANTS(:,56) = 66.666666667;
    STATES(:,30) = 0;
    STATES(:,31) = 0;
    STATES(:,32) = 0.1;
    STATES(:,33) = 0;
    STATES(:,34) = 0;
    STATES(:,35) = 0;
    STATES(:,36) = 0;
    STATES(:,37) = 0;
    STATES(:,38) = 0;
    STATES(:,39) = 0.2;
    STATES(:,40) = 0;
    CONSTANTS(:,57) = 0.224;
    CONSTANTS(:,58) = 1;
    CONSTANTS(:,59) = 0.0001;
    CONSTANTS(:,60) = 0;
    CONSTANTS(:,61) = 0.50505;
    CONSTANTS(:,62) = 0.02;
    CONSTANTS(:,63) = 0.50505;
    CONSTANTS(:,64) = 0.02;
    CONSTANTS(:,65) = 0.50505;
    CONSTANTS(:,66) = 0.02;
    CONSTANTS(:,67) = 1.0104;
    CONSTANTS(:,68) = 10;
    CONSTANTS(:,69) = 0.1;
    CONSTANTS(:,70) = 0;
    CONSTANTS(:,71) = 3.33333333333;
    CONSTANTS(:,72) = 4;
    CONSTANTS(:,73) = 0.50505;
    CONSTANTS(:,74) = 0.02;
    CONSTANTS(:,75) = 0.00004;
    CONSTANTS(:,76) = 0.5;
    CONSTANTS(:,77) = 66.666666667;
    CONSTANTS(:,78) = 25.64166667;
    CONSTANTS(:,79) = 15.6565;
    CONSTANTS(:,80) = 15.6565;
    CONSTANTS(:,81) = 4;
    CONSTANTS(:,82) = 10;
    CONSTANTS(:,83) = 6;
    CONSTANTS(:,84) = 6;
    CONSTANTS(:,85) = 28.595;
    CONSTANTS(:,86) = 3.33333333333;
    CONSTANTS(:,87) = 28.626667;
    CONSTANTS(:,88) = 2.564166667;
    CONSTANTS(:,89) = 15.6565;
    CONSTANTS(:,90) = 15.6565;
    STATES(:,41) = 0.18;
    CONSTANTS(:,91) = 0.224;
    CONSTANTS(:,92) = 1;
    CONSTANTS(:,93) = 0.159091667;
    CONSTANTS(:,94) = 0.159091667;
    CONSTANTS(:,95) = 15.6565;
    CONSTANTS(:,96) = 15.6565;
    CONSTANTS(:,97) = 0.105;
    CONSTANTS(:,98) = 0.105;
    CONSTANTS(:,99) = 6;
    CONSTANTS(:,100) = 6;
    CONSTANTS(:,101) = 15.6565;
    CONSTANTS(:,102) = 15.6565;
    STATES(:,42) = 0.36;
    STATES(:,43) = 0;
    CONSTANTS(:,103) = 0.032;
    CONSTANTS(:,104) = 1;
    CONSTANTS(:,105) = 0.046296667;
    CONSTANTS(:,106) = 0.046296667;
    CONSTANTS(:,107) = 0.066666667;
    CONSTANTS(:,108) = 0.066666667;
    CONSTANTS(:,109) = 0.15;
    CONSTANTS(:,110) = 0.15;
    CONSTANTS(:,111) = 1;
    CONSTANTS(:,112) = 1;
    STATES(:,44) = 0;
    STATES(:,45) = 0;
    STATES(:,46) = 0.5;
    STATES(:,47) = 0;
    STATES(:,48) = 0;
    STATES(:,49) = 0;
    STATES(:,50) = 1;
    STATES(:,51) = 0;
    CONSTANTS(:,113) = 1;
    CONSTANTS(:,114) = 0.83333333333;
    CONSTANTS(:,115) = 0.0016667;
    CONSTANTS(:,116) = 0;
    CONSTANTS(:,117) = 0.000000041667;
    CONSTANTS(:,118) = 0.0168;
    CONSTANTS(:,119) = 0.0000008333;
    CONSTANTS(:,120) = 0.1;
    CONSTANTS(:,121) = 0.001;
    CONSTANTS(:,122) = 0;
    CONSTANTS(:,123) = 0.000000041667;
    CONSTANTS(:,124) = 0.0168;
    CONSTANTS(:,125) = 0.40404;
    CONSTANTS(:,126) = 2.564166667;
    CONSTANTS(:,127) = 0.02;
    CONSTANTS(:,128) = 0.2;
    CONSTANTS(:,129) = 10;
    CONSTANTS(:,130) = 25.64166667;
    CONSTANTS(:,131) = 0.33333333333;
    STATES(:,52) = 0;
    STATES(:,53) = 166.67;
    STATES(:,54) = 0.16667;
    CONSTANTS(:,132) = 0.000007;
    CONSTANTS(:,133) = 0.25;
    CONSTANTS(:,134) = 0.002;
    CONSTANTS(:,135) = 0.00033;
    STATES(:,55) = 0;
    STATES(:,56) = 0.82;
    STATES(:,57) = 0;
    CONSTANTS(:,136) = 0.0003;
    CONSTANTS(:,137) = 10;
    CONSTANTS(:,138) = 0.05;
    CONSTANTS(:,139) = 0.00002;
    CONSTANTS(:,140) = 10;
    CONSTANTS(:,141) = 0.33333333333;
    CONSTANTS(:,142) = 0.2;
    CONSTANTS(:,143) = 0.83333333333;
    CONSTANTS(:,144) = 1;
    STATES(:,58) = 1;
    STATES(:,59) = 0;
    STATES(:,60) = 0;
    STATES(:,61) = 0;
    STATES(:,62) = 0;
    STATES(:,63) = 0;
    STATES(:,64) = 30;
    STATES(:,65) = 2.5;
    STATES(:,66) = 0.4;
    STATES(:,67) = 0;
    STATES(:,68) = 0;
    STATES(:,69) = 0;
    STATES(:,70) = 0;
    STATES(:,71) = 0;
    STATES(:,72) = 0;
    STATES(:,73) = 10;
    STATES(:,74) = 0;
    STATES(:,75) = 0;
    STATES(:,76) = 0;
    STATES(:,77) = 0;
    CONSTANTS(:,145) = 1;
    CONSTANTS(:,146) = 50;
    CONSTANTS(:,147) = 0.0000000002;
    CONSTANTS(:,148) = 0.1;
    CONSTANTS(:,149) = 1.2705;
    CONSTANTS(:,150) = 3.5026;
    CONSTANTS(:,151) = 0.000000002;
    CONSTANTS(:,152) = 0.1;
    CONSTANTS(:,153) = 1;
    CONSTANTS(:,154) = 0.1;
    CONSTANTS(:,155) = 2;
    CONSTANTS(:,156) = 0.2;
    CONSTANTS(:,157) = 0.000001;
    CONSTANTS(:,158) = 0.5;
    CONSTANTS(:,159) = 0.000000013333;
    CONSTANTS(:,160) = 8.6348;
    CONSTANTS(:,161) = 0.000000001;
    CONSTANTS(:,162) = 0.1;
    CONSTANTS(:,163) = 0.00000003;
    CONSTANTS(:,164) = 2;
    CONSTANTS(:,165) = 0.000000002;
    CONSTANTS(:,166) = 0.5;
    CONSTANTS(:,167) = 0.00000016667;
    CONSTANTS(:,168) = 0.1;
    CONSTANTS(:,169) = 0.00000002;
    CONSTANTS(:,170) = 0.1;
    CONSTANTS(:,171) = 0.000000005;
    CONSTANTS(:,172) = 4;
    CONSTANTS(:,173) = 0.17;
    CONSTANTS(:,174) = 0;
    CONSTANTS(:,175) = 0.00001;
    CONSTANTS(:,176) = 0.1;
    CONSTANTS(:,177) = 25.64166667;
    CONSTANTS(:,178) = 20;
    CONSTANTS(:,179) = 0.4;
    CONSTANTS(:,180) = 0;
    CONSTANTS(:,181) = 20;
    CONSTANTS(:,182) = 20;
    CONSTANTS(:,183) = 20;
    CONSTANTS(:,184) = 20;
    CONSTANTS(:,185) = 20;
    CONSTANTS(:,186) = 11.04;
    CONSTANTS(:,187) = 5.4;
    CONSTANTS(:,188) = 36;
    CONSTANTS(:,189) = 60;
    CONSTANTS(:,190) = 120;
    CONSTANTS(:,191) = 97;
    CONSTANTS(:,192) = 19.79166667;
    CONSTANTS(:,193) = 14;
    CONSTANTS(:,194) = 57;
    CONSTANTS(:,195) = 0.15;
    CONSTANTS(:,196) = 2.5;
    CONSTANTS(:,197) = 5;
    CONSTANTS(:,198) = 48;
    CONSTANTS(:,199) = 19.84166667;
    CONSTANTS(:,200) = 10;
    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(:,13) = ( STATES(:,25).*CONSTANTS(:,16) -  STATES(:,13).*CONSTANTS(:,17).*STATES(:,12))+ STATES(:,7).*CONSTANTS(:,27);
    RATES(:,14) = (( CONSTANTS(:,13).*STATES(:,23) -  CONSTANTS(:,14).*STATES(:,19).*STATES(:,14)) - ( CONSTANTS(:,9).*STATES(:,14) -  CONSTANTS(:,10).*STATES(:,24).*STATES(:,20)))+ CONSTANTS(:,15).*STATES(:,23);
    RATES(:,19) = ((( STATES(:,13).*STATES(:,12).*CONSTANTS(:,17) - ( STATES(:,19).*STATES(:,20).*CONSTANTS(:,11) -  STATES(:,21).*CONSTANTS(:,12)))+ CONSTANTS(:,13).*STATES(:,23)) -  CONSTANTS(:,14).*STATES(:,19).*STATES(:,14)) -  CONSTANTS(:,18).*STATES(:,19).*CONSTANTS(:,2);
    RATES(:,20) = ( CONSTANTS(:,9).*STATES(:,14) -  CONSTANTS(:,10).*STATES(:,24).*STATES(:,20)) - ( STATES(:,19).*STATES(:,20).*CONSTANTS(:,11) -  STATES(:,21).*CONSTANTS(:,12));
    RATES(:,12) = (  - STATES(:,13).*STATES(:,12).*CONSTANTS(:,17)+ CONSTANTS(:,15).*STATES(:,23)+ CONSTANTS(:,18).*STATES(:,19).*CONSTANTS(:,2)) - ( CONSTANTS(:,35).*STATES(:,10).*STATES(:,12) -  CONSTANTS(:,36).*STATES(:,6));
    RATES(:,21) = (( STATES(:,19).*STATES(:,20).*CONSTANTS(:,11) -  STATES(:,21).*CONSTANTS(:,12))+ CONSTANTS(:,7).*STATES(:,23)) -  STATES(:,21).*STATES(:,24).*CONSTANTS(:,8);
    RATES(:,22) =  - ( CONSTANTS(:,5).*STATES(:,22) -  CONSTANTS(:,6).*STATES(:,24));
    RATES(:,23) = ( - ( CONSTANTS(:,7).*STATES(:,23) -  STATES(:,21).*STATES(:,24).*CONSTANTS(:,8)) - ( CONSTANTS(:,13).*STATES(:,23) -  CONSTANTS(:,14).*STATES(:,19).*STATES(:,14))) -  CONSTANTS(:,15).*STATES(:,23);
    RATES(:,24) = (((( CONSTANTS(:,5).*STATES(:,22) -  CONSTANTS(:,6).*STATES(:,24))+ CONSTANTS(:,7).*STATES(:,23)) -  STATES(:,21).*STATES(:,24).*CONSTANTS(:,8))+ CONSTANTS(:,9).*STATES(:,14)) -  CONSTANTS(:,10).*STATES(:,24).*STATES(:,20);
    RATES(:,25) = (( CONSTANTS(:,18).*STATES(:,19).*CONSTANTS(:,2) -  STATES(:,25).*CONSTANTS(:,16)) - ( STATES(:,15).*STATES(:,25).*CONSTANTS(:,21) -  STATES(:,26).*CONSTANTS(:,22))) - ( STATES(:,7).*CONSTANTS(:,26)+ STATES(:,8).*STATES(:,25).*CONSTANTS(:,25));
    RATES(:,15) =  - ( STATES(:,15).*CONSTANTS(:,1).*CONSTANTS(:,19) -  STATES(:,8).*CONSTANTS(:,20)) - ( STATES(:,15).*STATES(:,25).*CONSTANTS(:,21) -  STATES(:,26).*CONSTANTS(:,22));
    RATES(:,26) = ( STATES(:,15).*STATES(:,25).*CONSTANTS(:,21) -  STATES(:,26).*CONSTANTS(:,22)) - ( CONSTANTS(:,1).*STATES(:,26).*CONSTANTS(:,23) -  STATES(:,7).*CONSTANTS(:,24));
    RATES(:,8) = (( STATES(:,15).*CONSTANTS(:,1).*CONSTANTS(:,19) -  STATES(:,8).*CONSTANTS(:,20))+ STATES(:,7).*CONSTANTS(:,27)) - (  - STATES(:,7).*CONSTANTS(:,26)+ STATES(:,8).*STATES(:,25).*CONSTANTS(:,25));
    RATES(:,7) = ((( STATES(:,26).*CONSTANTS(:,1).*CONSTANTS(:,23) -  STATES(:,7).*CONSTANTS(:,24))+ STATES(:,8).*STATES(:,25).*CONSTANTS(:,25)) -  STATES(:,7).*CONSTANTS(:,26)) -  STATES(:,7).*CONSTANTS(:,27);
    RATES(:,27) = ( CONSTANTS(:,3).*CONSTANTS(:,38).*STATES(:,10))./(CONSTANTS(:,37)+STATES(:,10)) -  CONSTANTS(:,28).*STATES(:,27);
    RATES(:,10) = ((( - (((( CONSTANTS(:,3).*CONSTANTS(:,38).*STATES(:,10))./(CONSTANTS(:,37)+STATES(:,10))+( STATES(:,1).*CONSTANTS(:,40).*STATES(:,10))./( CONSTANTS(:,39).*(CONSTANTS(:,4)+STATES(:,2)./CONSTANTS(:,30)+STATES(:,11)./CONSTANTS(:,52)+STATES(:,3)./CONSTANTS(:,56)+STATES(:,9)./CONSTANTS(:,54))+STATES(:,10))) -  CONSTANTS(:,28).*STATES(:,27)) -  CONSTANTS(:,33).*STATES(:,4)) -  CONSTANTS(:,31).*STATES(:,28).*STATES(:,10))+ CONSTANTS(:,32).*STATES(:,5)) -  CONSTANTS(:,35).*STATES(:,10).*STATES(:,12))+ CONSTANTS(:,36).*STATES(:,6);
    RATES(:,5) =   - CONSTANTS(:,32).*STATES(:,5)+ CONSTANTS(:,31).*STATES(:,10).*STATES(:,28);
    RATES(:,28) = ( - (  - CONSTANTS(:,32).*STATES(:,5)+ CONSTANTS(:,31).*STATES(:,10).*STATES(:,28))+ CONSTANTS(:,1).*STATES(:,17).*CONSTANTS(:,45)) -  CONSTANTS(:,46).*STATES(:,28);
    RATES(:,6) =  - (  - CONSTANTS(:,35).*STATES(:,10).*STATES(:,12)+ CONSTANTS(:,36).*STATES(:,6));
    RATES(:,4) = ( STATES(:,1).*CONSTANTS(:,40).*STATES(:,10))./( CONSTANTS(:,39).*(CONSTANTS(:,4)+STATES(:,2)./CONSTANTS(:,30)+STATES(:,11)./CONSTANTS(:,52)+STATES(:,3)./CONSTANTS(:,56)+STATES(:,9)./CONSTANTS(:,54))+STATES(:,10)) -  CONSTANTS(:,33).*STATES(:,4);
    RATES(:,29) = ( - ( CONSTANTS(:,41).*CONSTANTS(:,1).*CONSTANTS(:,1).*STATES(:,29) -  CONSTANTS(:,42).*STATES(:,16)) - ( CONSTANTS(:,47).*STATES(:,11).*STATES(:,29) -  CONSTANTS(:,48).*STATES(:,9)))+( STATES(:,9).*STATES(:,1).*CONSTANTS(:,55))./(STATES(:,9)+CONSTANTS(:,54));
    RATES(:,9) = ( CONSTANTS(:,47).*STATES(:,11).*STATES(:,29) -  CONSTANTS(:,48).*STATES(:,9)) - ( STATES(:,9).*STATES(:,1).*CONSTANTS(:,55))./(STATES(:,9)+ CONSTANTS(:,54).*(CONSTANTS(:,4)+STATES(:,2)./CONSTANTS(:,30)+STATES(:,10)./CONSTANTS(:,39)+STATES(:,3)./CONSTANTS(:,56)+STATES(:,11)./CONSTANTS(:,52)));
    RATES(:,16) = ( CONSTANTS(:,41).*CONSTANTS(:,1).*CONSTANTS(:,1).*STATES(:,29) -  CONSTANTS(:,42).*STATES(:,16)) - ( CONSTANTS(:,1).*STATES(:,16).*CONSTANTS(:,43) -  CONSTANTS(:,44).*STATES(:,17));
    RATES(:,17) = ( CONSTANTS(:,1).*STATES(:,16).*CONSTANTS(:,43) -  CONSTANTS(:,44).*STATES(:,17)) - ( CONSTANTS(:,1).*STATES(:,17).*CONSTANTS(:,45) -  CONSTANTS(:,46).*STATES(:,28));
    RATES(:,18) = ((( STATES(:,9).*STATES(:,1).*CONSTANTS(:,55))./(STATES(:,9)+ CONSTANTS(:,54).*(CONSTANTS(:,4)+STATES(:,2)./CONSTANTS(:,30)+STATES(:,10)./CONSTANTS(:,39)+STATES(:,3)./CONSTANTS(:,56)+STATES(:,11)./CONSTANTS(:,52))) -  CONSTANTS(:,49).*STATES(:,18)) - ( CONSTANTS(:,51).*STATES(:,18))./(STATES(:,18)+CONSTANTS(:,50)))+( STATES(:,11).*STATES(:,1).*CONSTANTS(:,53))./(STATES(:,11)+ CONSTANTS(:,52).*(CONSTANTS(:,4)+STATES(:,2)./CONSTANTS(:,30)+STATES(:,10)./CONSTANTS(:,39)+STATES(:,3)./CONSTANTS(:,56)+STATES(:,9)./CONSTANTS(:,54)));
    RATES(:,11) = ( CONSTANTS(:,49).*STATES(:,18)+( CONSTANTS(:,51).*STATES(:,18))./(STATES(:,18)+CONSTANTS(:,50))) - ( STATES(:,11).*STATES(:,1).*CONSTANTS(:,53))./(STATES(:,11)+ CONSTANTS(:,52).*(CONSTANTS(:,4)+STATES(:,2)./CONSTANTS(:,30)+STATES(:,10)./CONSTANTS(:,39)+STATES(:,3)./CONSTANTS(:,56)+STATES(:,9)./CONSTANTS(:,54)));
    RATES(:,38) = ((((  - STATES(:,2).*CONSTANTS(:,68).*STATES(:,38))./(CONSTANTS(:,67)+STATES(:,38)) -  CONSTANTS(:,59).*STATES(:,38))+( STATES(:,4).*CONSTANTS(:,64).*STATES(:,39))./(CONSTANTS(:,63)+STATES(:,39))+( STATES(:,6).*CONSTANTS(:,66).*STATES(:,39))./(CONSTANTS(:,65)+STATES(:,39))+( STATES(:,5).*CONSTANTS(:,62).*STATES(:,39))./(CONSTANTS(:,61)+STATES(:,39))+( STATES(:,30).*CONSTANTS(:,74).*STATES(:,39))./(CONSTANTS(:,73)+STATES(:,39))) -  STATES(:,38).*STATES(:,35).*CONSTANTS(:,75))+ STATES(:,36).*CONSTANTS(:,76);
    RATES(:,39) =  - (((  - STATES(:,2).*CONSTANTS(:,68).*STATES(:,38))./(CONSTANTS(:,67)+STATES(:,38)) -  CONSTANTS(:,59).*STATES(:,38))+( STATES(:,4).*CONSTANTS(:,64).*STATES(:,39))./(CONSTANTS(:,63)+STATES(:,39))+( STATES(:,6).*CONSTANTS(:,66).*STATES(:,39))./(CONSTANTS(:,65)+STATES(:,39))+( STATES(:,5).*CONSTANTS(:,62).*STATES(:,39))./(CONSTANTS(:,61)+STATES(:,39))) - ( STATES(:,30).*CONSTANTS(:,74).*STATES(:,39))./(CONSTANTS(:,73)+STATES(:,39));
    RATES(:,2) = (  - STATES(:,1).*CONSTANTS(:,72).*STATES(:,2))./( CONSTANTS(:,71).*(CONSTANTS(:,58)+STATES(:,3)./CONSTANTS(:,77)+STATES(:,10)./CONSTANTS(:,86)+STATES(:,11)./CONSTANTS(:,87)+STATES(:,9)./CONSTANTS(:,85))+STATES(:,2))+ CONSTANTS(:,69).*STATES(:,40);
    RATES(:,40) = ( STATES(:,1).*CONSTANTS(:,72).*STATES(:,2))./( CONSTANTS(:,71).*(CONSTANTS(:,58)+STATES(:,3)./CONSTANTS(:,77)+STATES(:,10)./CONSTANTS(:,86)+STATES(:,11)./CONSTANTS(:,87)+STATES(:,9)./CONSTANTS(:,85))+STATES(:,2)) -  CONSTANTS(:,69).*STATES(:,40);
    RATES(:,36) =  STATES(:,38).*STATES(:,35).*CONSTANTS(:,75) -  STATES(:,36).*CONSTANTS(:,76);
    RATES(:,3) = (  - STATES(:,1).*STATES(:,3).*CONSTANTS(:,81))./( CONSTANTS(:,77).*(CONSTANTS(:,58)+STATES(:,2)./CONSTANTS(:,71)+STATES(:,10)./CONSTANTS(:,86)+STATES(:,11)./CONSTANTS(:,87)+STATES(:,9)./CONSTANTS(:,85))+STATES(:,3))+( STATES(:,35).*CONSTANTS(:,57).*CONSTANTS(:,83))./( CONSTANTS(:,79).*(CONSTANTS(:,58)+STATES(:,37)./CONSTANTS(:,80)+STATES(:,33)./CONSTANTS(:,90)+STATES(:,34)./CONSTANTS(:,89))+STATES(:,35));
    RATES(:,35) = ((( STATES(:,1).*STATES(:,3).*CONSTANTS(:,81))./( CONSTANTS(:,77).*(CONSTANTS(:,58)+STATES(:,2)./CONSTANTS(:,71)+STATES(:,10)./CONSTANTS(:,86)+STATES(:,11)./CONSTANTS(:,87)+STATES(:,9)./CONSTANTS(:,85))+STATES(:,3)) - ( STATES(:,35).*CONSTANTS(:,57).*CONSTANTS(:,83))./( CONSTANTS(:,79).*(CONSTANTS(:,58)+STATES(:,37)./CONSTANTS(:,80)+STATES(:,33)./CONSTANTS(:,90)+STATES(:,34)./CONSTANTS(:,89))+STATES(:,35))) - ( STATES(:,35).*STATES(:,31).*CONSTANTS(:,82))./( CONSTANTS(:,78).*(CONSTANTS(:,58)+STATES(:,32)./CONSTANTS(:,88))+STATES(:,35)))+( STATES(:,37).*CONSTANTS(:,57).*CONSTANTS(:,84))./( CONSTANTS(:,80).*(CONSTANTS(:,58)+STATES(:,35)./CONSTANTS(:,79)+STATES(:,33)./CONSTANTS(:,90)+STATES(:,34)./CONSTANTS(:,89))+STATES(:,37));
    RATES(:,37) = ( STATES(:,35).*STATES(:,31).*CONSTANTS(:,82))./( CONSTANTS(:,78).*(CONSTANTS(:,58)+STATES(:,32)./CONSTANTS(:,88))+STATES(:,35)) - ( STATES(:,37).*CONSTANTS(:,57).*CONSTANTS(:,84))./( CONSTANTS(:,80).*(CONSTANTS(:,58)+STATES(:,35)./CONSTANTS(:,79)+STATES(:,33)./CONSTANTS(:,90)+STATES(:,34)./CONSTANTS(:,89))+STATES(:,37));
    RATES(:,41) = (  - STATES(:,41).*CONSTANTS(:,97).*STATES(:,36))./( CONSTANTS(:,93).*(CONSTANTS(:,92)+STATES(:,34)./CONSTANTS(:,94))+STATES(:,41))+( STATES(:,34).*CONSTANTS(:,99).*CONSTANTS(:,91))./( CONSTANTS(:,95).*(CONSTANTS(:,92)+STATES(:,35)./CONSTANTS(:,101)+STATES(:,37)./CONSTANTS(:,102)+STATES(:,33)./CONSTANTS(:,96))+STATES(:,34));
    RATES(:,34) = ((( STATES(:,41).*CONSTANTS(:,97).*STATES(:,36))./( CONSTANTS(:,93).*(CONSTANTS(:,92)+STATES(:,34)./CONSTANTS(:,94))+STATES(:,41)) - ( STATES(:,34).*CONSTANTS(:,99).*CONSTANTS(:,91))./( CONSTANTS(:,95).*(CONSTANTS(:,92)+STATES(:,35)./CONSTANTS(:,101)+STATES(:,37)./CONSTANTS(:,102)+STATES(:,33)./CONSTANTS(:,96))+STATES(:,34))) - ( STATES(:,34).*CONSTANTS(:,98).*STATES(:,36))./( CONSTANTS(:,94).*(CONSTANTS(:,92)+STATES(:,41)./CONSTANTS(:,93))+STATES(:,34)))+( STATES(:,33).*CONSTANTS(:,100).*CONSTANTS(:,91))./( CONSTANTS(:,96).*(CONSTANTS(:,92)+STATES(:,35)./CONSTANTS(:,101)+STATES(:,37)./CONSTANTS(:,102)+STATES(:,34)./CONSTANTS(:,95))+STATES(:,33));
    RATES(:,33) = ( STATES(:,34).*CONSTANTS(:,98).*STATES(:,36))./( CONSTANTS(:,94).*(CONSTANTS(:,92)+STATES(:,41)./CONSTANTS(:,93))+STATES(:,34)) - ( STATES(:,33).*CONSTANTS(:,100).*CONSTANTS(:,91))./( CONSTANTS(:,96).*(CONSTANTS(:,92)+STATES(:,35)./CONSTANTS(:,101)+STATES(:,37)./CONSTANTS(:,102)+STATES(:,34)./CONSTANTS(:,95))+STATES(:,33));
    RATES(:,42) = (  - STATES(:,42).*CONSTANTS(:,109).*STATES(:,33))./( CONSTANTS(:,105).*(CONSTANTS(:,104)+STATES(:,43)./CONSTANTS(:,106))+STATES(:,42))+( STATES(:,43).*CONSTANTS(:,111).*CONSTANTS(:,103))./( CONSTANTS(:,107).*(CONSTANTS(:,104)+STATES(:,31)./CONSTANTS(:,108))+STATES(:,43));
    RATES(:,43) = ((( STATES(:,42).*CONSTANTS(:,109).*STATES(:,33))./(( CONSTANTS(:,105).*STATES(:,43))./CONSTANTS(:,106)+STATES(:,42)) - ( STATES(:,43).*CONSTANTS(:,111).*CONSTANTS(:,103))./( CONSTANTS(:,107).*(CONSTANTS(:,104)+STATES(:,31)./CONSTANTS(:,108))+STATES(:,43))) - ( STATES(:,43).*CONSTANTS(:,110).*STATES(:,33))./( CONSTANTS(:,106).*(CONSTANTS(:,104)+STATES(:,43)./CONSTANTS(:,107))+STATES(:,43)))+( STATES(:,31).*CONSTANTS(:,112).*CONSTANTS(:,103))./( CONSTANTS(:,108).*(CONSTANTS(:,104)+STATES(:,43)./CONSTANTS(:,107))+STATES(:,31));
    RATES(:,31) = ( STATES(:,43).*CONSTANTS(:,110).*STATES(:,33))./( CONSTANTS(:,106).*(CONSTANTS(:,104)+STATES(:,42)./CONSTANTS(:,105))+STATES(:,43)) - ( STATES(:,31).*CONSTANTS(:,112).*CONSTANTS(:,103))./( CONSTANTS(:,108).*(CONSTANTS(:,104)+STATES(:,43)./CONSTANTS(:,107))+STATES(:,31));
    RATES(:,47) = ((( STATES(:,44).*CONSTANTS(:,128).*STATES(:,46))./( CONSTANTS(:,114).*(CONSTANTS(:,113)+STATES(:,45)./CONSTANTS(:,131))+STATES(:,46)) -  CONSTANTS(:,119).*STATES(:,47).*STATES(:,49))+ CONSTANTS(:,120).*STATES(:,30)) -  CONSTANTS(:,115).*STATES(:,47);
    RATES(:,46) = ( CONSTANTS(:,115).*STATES(:,47) -  CONSTANTS(:,116).*STATES(:,46)) - ( STATES(:,44).*CONSTANTS(:,128).*STATES(:,46))./( CONSTANTS(:,114).*(CONSTANTS(:,113)+STATES(:,45)./CONSTANTS(:,131))+STATES(:,46));
    RATES(:,30) =  CONSTANTS(:,119).*STATES(:,47).*STATES(:,49) -  CONSTANTS(:,120).*STATES(:,30);
    RATES(:,49) = ((  - CONSTANTS(:,119).*STATES(:,47).*STATES(:,49)+ CONSTANTS(:,120).*STATES(:,30)) -  CONSTANTS(:,118).*STATES(:,49))+ CONSTANTS(:,117).*STATES(:,32).*STATES(:,50);
    RATES(:,32) = ((( CONSTANTS(:,121).*STATES(:,51) -  CONSTANTS(:,122).*STATES(:,32)) - ( STATES(:,31).*CONSTANTS(:,129).*STATES(:,32))./( CONSTANTS(:,126).*(CONSTANTS(:,113)+STATES(:,35)./CONSTANTS(:,130))+STATES(:,32)))+ CONSTANTS(:,118).*STATES(:,49)) -  CONSTANTS(:,117).*STATES(:,32).*STATES(:,50);
    RATES(:,51) = ((  - CONSTANTS(:,121).*STATES(:,51)+ CONSTANTS(:,122).*STATES(:,32)+( STATES(:,31).*CONSTANTS(:,129).*STATES(:,32))./( CONSTANTS(:,126).*(CONSTANTS(:,113)+STATES(:,35)./CONSTANTS(:,130))+STATES(:,32))) -  CONSTANTS(:,123).*STATES(:,51).*STATES(:,50))+ CONSTANTS(:,124).*STATES(:,48);
    RATES(:,48) =  CONSTANTS(:,123).*STATES(:,51).*STATES(:,50) -  CONSTANTS(:,124).*STATES(:,48);
    RATES(:,50) = (( CONSTANTS(:,118).*STATES(:,49) -  CONSTANTS(:,117).*STATES(:,32).*STATES(:,50)) -  CONSTANTS(:,123).*STATES(:,51).*STATES(:,50))+ CONSTANTS(:,124).*STATES(:,48);
    RATES(:,53) =   - CONSTANTS(:,132).*STATES(:,53).*STATES(:,54)+ CONSTANTS(:,133).*STATES(:,44);
    RATES(:,54) =   - CONSTANTS(:,132).*STATES(:,53).*STATES(:,54)+ CONSTANTS(:,133).*STATES(:,44);
    RATES(:,44) = (( CONSTANTS(:,132).*STATES(:,53).*STATES(:,54) -  CONSTANTS(:,133).*STATES(:,44)) -  CONSTANTS(:,134).*STATES(:,44))+ CONSTANTS(:,135).*STATES(:,52);
    RATES(:,52) =  CONSTANTS(:,134).*STATES(:,44) -  CONSTANTS(:,135).*STATES(:,52);
    RATES(:,56) =   - CONSTANTS(:,1).*STATES(:,56).*CONSTANTS(:,136)+ STATES(:,45).*CONSTANTS(:,137);
    RATES(:,45) = ( - (  - CONSTANTS(:,1).*STATES(:,56).*CONSTANTS(:,136)+ STATES(:,45).*CONSTANTS(:,137))+ CONSTANTS(:,138).*STATES(:,55)) - ( CONSTANTS(:,142).*STATES(:,44).*STATES(:,45))./( CONSTANTS(:,141).*(CONSTANTS(:,144)+STATES(:,46)./CONSTANTS(:,143))+STATES(:,45));
    RATES(:,55) = ( - ( CONSTANTS(:,138).*STATES(:,55) - ( CONSTANTS(:,142).*STATES(:,44).*STATES(:,45))./(CONSTANTS(:,141)+STATES(:,45)))+ CONSTANTS(:,1).*STATES(:,57).*CONSTANTS(:,139)) -  CONSTANTS(:,140).*STATES(:,55);
    RATES(:,57) =   - CONSTANTS(:,1).*STATES(:,57).*CONSTANTS(:,139)+ CONSTANTS(:,140).*STATES(:,55);
    RATES(:,58) = ((((((  - STATES(:,58).*CONSTANTS(:,145)+ STATES(:,1).*CONSTANTS(:,146)) -  STATES(:,58).*STATES(:,63).*CONSTANTS(:,147))+ STATES(:,1).*CONSTANTS(:,148)) -  STATES(:,58).*STATES(:,74).*CONSTANTS(:,161))+ STATES(:,59).*CONSTANTS(:,162)) -  STATES(:,58).*CONSTANTS(:,1).*CONSTANTS(:,157))+ STATES(:,62).*CONSTANTS(:,158);
    RATES(:,59) = (( STATES(:,58).*STATES(:,74).*CONSTANTS(:,161) -  STATES(:,59).*CONSTANTS(:,162)) -  STATES(:,59).*STATES(:,63).*CONSTANTS(:,163))+ STATES(:,60).*CONSTANTS(:,164);
    RATES(:,60) = (( STATES(:,59).*STATES(:,63).*CONSTANTS(:,163) -  STATES(:,60).*CONSTANTS(:,164)) -  STATES(:,60).*CONSTANTS(:,155))+ STATES(:,1).*CONSTANTS(:,156);
    RATES(:,62) = (((((( STATES(:,58).*CONSTANTS(:,1).*CONSTANTS(:,157) -  STATES(:,62).*CONSTANTS(:,158)) -  STATES(:,62).*CONSTANTS(:,149))+ STATES(:,1).*CONSTANTS(:,150)) -  STATES(:,62).*STATES(:,63).*CONSTANTS(:,151))+ STATES(:,1).*CONSTANTS(:,152)) -  STATES(:,74).*STATES(:,62).*CONSTANTS(:,159))+ STATES(:,61).*CONSTANTS(:,160);
    RATES(:,61) = (( STATES(:,74).*STATES(:,62).*CONSTANTS(:,159) -  STATES(:,61).*CONSTANTS(:,160)) -  STATES(:,61).*CONSTANTS(:,153))+ STATES(:,1).*CONSTANTS(:,154);
    RATES(:,1) = (((((((((( STATES(:,58).*CONSTANTS(:,145) -  STATES(:,1).*CONSTANTS(:,146))+ STATES(:,58).*STATES(:,63).*CONSTANTS(:,147)) -  STATES(:,1).*CONSTANTS(:,148))+ STATES(:,62).*CONSTANTS(:,149)) -  STATES(:,1).*CONSTANTS(:,150))+ STATES(:,62).*STATES(:,63).*CONSTANTS(:,151)) -  STATES(:,1).*CONSTANTS(:,152))+ STATES(:,61).*CONSTANTS(:,153)) -  STATES(:,1).*CONSTANTS(:,154))+ STATES(:,60).*CONSTANTS(:,155)) -  STATES(:,1).*CONSTANTS(:,156);
    RATES(:,63) = ((((((  - STATES(:,58).*STATES(:,63).*CONSTANTS(:,147)+ STATES(:,1).*CONSTANTS(:,148)) -  STATES(:,62).*STATES(:,63).*CONSTANTS(:,151))+ STATES(:,1).*CONSTANTS(:,152)) -  STATES(:,59).*STATES(:,63).*CONSTANTS(:,163))+ STATES(:,60).*CONSTANTS(:,164)) -  STATES(:,63).*CONSTANTS(:,179))+( STATES(:,72).*CONSTANTS(:,190).*STATES(:,64))./(CONSTANTS(:,185)+STATES(:,64))+( STATES(:,68).*CONSTANTS(:,187).*STATES(:,64))./(CONSTANTS(:,182)+STATES(:,64))+( STATES(:,71).*CONSTANTS(:,189).*STATES(:,64))./(CONSTANTS(:,184)+STATES(:,64))+( STATES(:,69).*CONSTANTS(:,188).*STATES(:,64))./(CONSTANTS(:,183)+STATES(:,64))+( STATES(:,70).*CONSTANTS(:,186).*STATES(:,64))./(CONSTANTS(:,181)+STATES(:,64));
    RATES(:,66) = (((( STATES(:,67).*CONSTANTS(:,173) -  STATES(:,65).*STATES(:,66).*CONSTANTS(:,165))+ STATES(:,70).*CONSTANTS(:,166)) -  CONSTANTS(:,1).*STATES(:,66).*CONSTANTS(:,167))+ STATES(:,68).*CONSTANTS(:,168)) - ( STATES(:,42).*CONSTANTS(:,178).*STATES(:,66))./(CONSTANTS(:,177)+STATES(:,66));
    RATES(:,70) =  STATES(:,65).*STATES(:,66).*CONSTANTS(:,165) -  STATES(:,70).*CONSTANTS(:,166);
    RATES(:,65) = ((  - STATES(:,65).*STATES(:,66).*CONSTANTS(:,165)+ STATES(:,70).*CONSTANTS(:,166)) -  STATES(:,65).*STATES(:,68).*CONSTANTS(:,169))+ STATES(:,69).*CONSTANTS(:,170);
    RATES(:,67) = ((  - STATES(:,67).*CONSTANTS(:,173)+( STATES(:,42).*CONSTANTS(:,178).*STATES(:,66))./(CONSTANTS(:,177)+STATES(:,66))) -  CONSTANTS(:,1).*STATES(:,67).*CONSTANTS(:,175))+ STATES(:,72).*CONSTANTS(:,176);
    RATES(:,72) =  CONSTANTS(:,1).*STATES(:,67).*CONSTANTS(:,175) -  STATES(:,72).*CONSTANTS(:,176);
    RATES(:,68) = (((( CONSTANTS(:,1).*STATES(:,66).*CONSTANTS(:,167) -  STATES(:,68).*CONSTANTS(:,168)) -  STATES(:,74).*STATES(:,68).*CONSTANTS(:,171))+ STATES(:,71).*CONSTANTS(:,172)) -  STATES(:,65).*STATES(:,68).*CONSTANTS(:,169))+ STATES(:,69).*CONSTANTS(:,170);
    RATES(:,69) =  STATES(:,65).*STATES(:,68).*CONSTANTS(:,169) -  STATES(:,69).*CONSTANTS(:,170);
    RATES(:,71) =  STATES(:,74).*STATES(:,68).*CONSTANTS(:,171) -  STATES(:,71).*CONSTANTS(:,172);
    RATES(:,64) =  STATES(:,63).*CONSTANTS(:,179) - (( STATES(:,72).*CONSTANTS(:,190).*STATES(:,64))./(CONSTANTS(:,185)+STATES(:,64))+( STATES(:,68).*CONSTANTS(:,187).*STATES(:,64))./(CONSTANTS(:,182)+STATES(:,64))+( STATES(:,71).*CONSTANTS(:,189).*STATES(:,64))./(CONSTANTS(:,184)+STATES(:,64))+( STATES(:,69).*CONSTANTS(:,188).*STATES(:,64))./(CONSTANTS(:,183)+STATES(:,64))+( STATES(:,70).*CONSTANTS(:,186).*STATES(:,64))./(CONSTANTS(:,181)+STATES(:,64)));
    RATES(:,73) = (((  - STATES(:,45).*CONSTANTS(:,193).*STATES(:,73))./(CONSTANTS(:,191)+STATES(:,73)) - ( STATES(:,55).*CONSTANTS(:,194).*STATES(:,73))./(CONSTANTS(:,192)+STATES(:,73))) - ( STATES(:,8).*CONSTANTS(:,200).*STATES(:,73))./(CONSTANTS(:,199)+STATES(:,73))) - ( STATES(:,7).*CONSTANTS(:,198).*STATES(:,73))./(CONSTANTS(:,197)+STATES(:,73));
    RATES(:,74) = ((((((((( STATES(:,45).*CONSTANTS(:,193).*STATES(:,73))./(CONSTANTS(:,191)+STATES(:,73))+( STATES(:,55).*CONSTANTS(:,194).*STATES(:,73))./(CONSTANTS(:,192)+STATES(:,73))+( STATES(:,8).*CONSTANTS(:,200).*STATES(:,73))./(CONSTANTS(:,199)+STATES(:,73))) -  CONSTANTS(:,195).*STATES(:,74))+( STATES(:,7).*CONSTANTS(:,198).*STATES(:,73))./(CONSTANTS(:,197)+STATES(:,73))) -  STATES(:,58).*STATES(:,74).*CONSTANTS(:,161))+ STATES(:,59).*CONSTANTS(:,162)) -  STATES(:,74).*STATES(:,62).*CONSTANTS(:,159))+ STATES(:,61).*CONSTANTS(:,160)) -  STATES(:,74).*STATES(:,68).*CONSTANTS(:,171))+ STATES(:,71).*CONSTANTS(:,172);
    RATES(:,75) = ((( STATES(:,45).*CONSTANTS(:,193).*STATES(:,73))./(CONSTANTS(:,191)+STATES(:,73))+( STATES(:,55).*CONSTANTS(:,194).*STATES(:,73))./(CONSTANTS(:,192)+STATES(:,73))+( STATES(:,7).*CONSTANTS(:,198).*STATES(:,73))./(CONSTANTS(:,197)+STATES(:,73))) -  CONSTANTS(:,196).*STATES(:,75))+( STATES(:,8).*CONSTANTS(:,200).*STATES(:,73))./(CONSTANTS(:,199)+STATES(:,73));
    RATES(:,77) =  CONSTANTS(:,195).*STATES(:,74);
    RATES(:,76) =  CONSTANTS(:,196).*STATES(:,75);
   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
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