# 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 =5;
end
% There are a total of 48 entries in each of the rate and state variable arrays.
% There are a total of 101 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 (day)');
LEGEND_ALGEBRAIC(:,1) = strpad('FAt in component FAt (litre_per_day)');
LEGEND_CONSTANTS(:,1) = strpad('FA1 in component FAt (litre_per_day)');
LEGEND_CONSTANTS(:,2) = strpad('tA in component FAt (day)');
LEGEND_CONSTANTS(:,3) = strpad('FA2 in component FAt (litre_per_day)');
LEGEND_ALGEBRAIC(:,4) = strpad('FBt in component FBt (litre_per_day)');
LEGEND_CONSTANTS(:,4) = strpad('FB1 in component FBt (litre_per_day)');
LEGEND_CONSTANTS(:,5) = strpad('tB in component FBt (day)');
LEGEND_CONSTANTS(:,6) = strpad('FB2 in component FBt (litre_per_day)');
LEGEND_ALGEBRAIC(:,5) = strpad('F0t in component F0t (litre_per_day)');
LEGEND_STATES(:,1) = strpad('c15 in component c15 (micromole_per_litre)');
LEGEND_CONSTANTS(:,7) = strpad('p0 in component model_parameters (litre_per_day)');
LEGEND_CONSTANTS(:,8) = strpad('V2 in component model_parameters (litre)');
LEGEND_STATES(:,2) = strpad('c015 in component c015 (micromole_per_litre)');
LEGEND_CONSTANTS(:,9) = strpad('p16 in component model_parameters (per_day)');
LEGEND_STATES(:,3) = strpad('c16 in component c16 (micromole_per_litre)');
LEGEND_CONSTANTS(:,10) = strpad('p18 in component model_parameters (per_day)');
LEGEND_STATES(:,4) = strpad('c17 in component c17 (micromole_per_litre)');
LEGEND_CONSTANTS(:,11) = strpad('p15 in component model_parameters (per_day_per_micromole_litre)');
LEGEND_STATES(:,5) = strpad('c19 in component c19 (micromole_per_litre)');
LEGEND_CONSTANTS(:,12) = strpad('p17 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,13) = strpad('p19 in component model_parameters (per_day_per_micromole_litre)');
LEGEND_CONSTANTS(:,14) = strpad('p20 in component model_parameters (micromole_per_litre)');
LEGEND_CONSTANTS(:,15) = strpad('p29 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,16) = strpad('pAA15 in component model_parameters (dimensionless)');
LEGEND_ALGEBRAIC(:,2) = strpad('pp in component pp (dimensionless)');
LEGEND_STATES(:,6) = strpad('c016 in component c016 (micromole_per_litre)');
LEGEND_CONSTANTS(:,17) = strpad('pAA16 in component model_parameters (dimensionless)');
LEGEND_STATES(:,7) = strpad('c017 in component c017 (micromole_per_litre)');
LEGEND_CONSTANTS(:,18) = strpad('p22 in component model_parameters (per_day)');
LEGEND_STATES(:,8) = strpad('c18 in component c18 (micromole_per_litre)');
LEGEND_CONSTANTS(:,19) = strpad('p21 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,20) = strpad('p23 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,21) = strpad('p1 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,22) = strpad('s1 in component c17 (dimensionless)');
LEGEND_STATES(:,9) = strpad('c1 in component c1 (micromole_per_litre)');
LEGEND_CONSTANTS(:,23) = strpad('p2 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,24) = strpad('s2 in component c17 (dimensionless)');
LEGEND_STATES(:,10) = strpad('c2 in component c2 (micromole_per_litre)');
LEGEND_CONSTANTS(:,25) = strpad('p3 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,26) = strpad('s3 in component c17 (dimensionless)');
LEGEND_STATES(:,11) = strpad('c3 in component c3 (micromole_per_litre)');
LEGEND_CONSTANTS(:,27) = strpad('p4 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,28) = strpad('s4 in component c17 (dimensionless)');
LEGEND_STATES(:,12) = strpad('c4 in component c4 (micromole_per_litre)');
LEGEND_CONSTANTS(:,29) = strpad('p5 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,30) = strpad('s5 in component c17 (dimensionless)');
LEGEND_STATES(:,13) = strpad('c5 in component c5 (micromole_per_litre)');
LEGEND_CONSTANTS(:,31) = strpad('p6 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,32) = strpad('s6 in component c17 (dimensionless)');
LEGEND_STATES(:,14) = strpad('c6 in component c6 (micromole_per_litre)');
LEGEND_CONSTANTS(:,33) = strpad('p7 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,34) = strpad('s7 in component c17 (dimensionless)');
LEGEND_STATES(:,15) = strpad('c7 in component c7 (micromole_per_litre)');
LEGEND_CONSTANTS(:,35) = strpad('p8 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,36) = strpad('s8 in component c17 (dimensionless)');
LEGEND_STATES(:,16) = strpad('c8 in component c8 (micromole_per_litre)');
LEGEND_CONSTANTS(:,37) = strpad('p9 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,38) = strpad('s9 in component c17 (dimensionless)');
LEGEND_STATES(:,17) = strpad('c9 in component c9 (micromole_per_litre)');
LEGEND_CONSTANTS(:,39) = strpad('p14 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,40) = strpad('s14 in component c17 (dimensionless)');
LEGEND_STATES(:,18) = strpad('c14 in component c14 (micromole_per_litre)');
LEGEND_CONSTANTS(:,41) = strpad('p25 in component model_parameters (per_day_per_micromole_litre)');
LEGEND_CONSTANTS(:,42) = strpad('p26 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,43) = strpad('p28 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,44) = strpad('pAA17 in component model_parameters (dimensionless)');
LEGEND_STATES(:,19) = strpad('c018 in component c018 (micromole_per_litre)');
LEGEND_CONSTANTS(:,45) = strpad('pAA18 in component model_parameters (dimensionless)');
LEGEND_STATES(:,20) = strpad('c019 in component c019 (micromole_per_litre)');
LEGEND_ALGEBRAIC(:,3) = strpad('gt in component gt (dimensionless)');
LEGEND_CONSTANTS(:,46) = strpad('p11 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,47) = strpad('s11 in component c19 (dimensionless)');
LEGEND_STATES(:,21) = strpad('c11 in component c11 (micromole_per_litre)');
LEGEND_CONSTANTS(:,48) = strpad('p12 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,49) = strpad('s12 in component c19 (dimensionless)');
LEGEND_STATES(:,22) = strpad('c12 in component c12 (micromole_per_litre)');
LEGEND_CONSTANTS(:,50) = strpad('p13 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,51) = strpad('s13 in component c19 (dimensionless)');
LEGEND_STATES(:,23) = strpad('c13 in component c13 (micromole_per_litre)');
LEGEND_CONSTANTS(:,52) = strpad('p10 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,53) = strpad('s10 in component c19 (dimensionless)');
LEGEND_STATES(:,24) = strpad('c10 in component c10 (micromole_per_litre)');
LEGEND_STATES(:,25) = strpad('c20 in component c20 (micromole_per_litre)');
LEGEND_STATES(:,26) = strpad('c020 in component c020 (micromole_per_litre)');
LEGEND_STATES(:,27) = strpad('c21 in component c21 (micromole_per_litre)');
LEGEND_STATES(:,28) = strpad('c021 in component c021 (micromole_per_litre)');
LEGEND_STATES(:,29) = strpad('c22 in component c22 (micromole_per_litre)');
LEGEND_STATES(:,30) = strpad('c022 in component c022 (micromole_per_litre)');
LEGEND_STATES(:,31) = strpad('c23 in component c23 (micromole_per_litre)');
LEGEND_STATES(:,32) = strpad('c023 in component c023 (micromole_per_litre)');
LEGEND_CONSTANTS(:,54) = strpad('p31 in component model_parameters (per_day)');
LEGEND_STATES(:,33) = strpad('c24 in component c24 (micromole_per_litre)');
LEGEND_STATES(:,34) = strpad('c024 in component c024 (micromole_per_litre)');
LEGEND_CONSTANTS(:,55) = strpad('p30 in component model_parameters (dimensionless)');
LEGEND_CONSTANTS(:,56) = strpad('p32 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,57) = strpad('p24 in component model_parameters (per_day)');
LEGEND_CONSTANTS(:,58) = strpad('p33 in component pp (micromole_per_litre_per_day)');
LEGEND_CONSTANTS(:,59) = strpad('t1 in component pp (day)');
LEGEND_CONSTANTS(:,60) = strpad('p27 in component model_parameters (dimensionless)');
LEGEND_STATES(:,35) = strpad('c01 in component c01 (micromole_per_litre)');
LEGEND_CONSTANTS(:,61) = strpad('pAA1 in component model_parameters (dimensionless)');
LEGEND_STATES(:,36) = strpad('c02 in component c02 (micromole_per_litre)');
LEGEND_CONSTANTS(:,62) = strpad('pAA2 in component model_parameters (dimensionless)');
LEGEND_STATES(:,37) = strpad('c03 in component c03 (micromole_per_litre)');
LEGEND_CONSTANTS(:,63) = strpad('pAA3 in component model_parameters (dimensionless)');
LEGEND_STATES(:,38) = strpad('c04 in component c04 (micromole_per_litre)');
LEGEND_CONSTANTS(:,64) = strpad('pAA4 in component model_parameters (dimensionless)');
LEGEND_STATES(:,39) = strpad('c05 in component c05 (micromole_per_litre)');
LEGEND_CONSTANTS(:,65) = strpad('pAA5 in component model_parameters (dimensionless)');
LEGEND_STATES(:,40) = strpad('c06 in component c06 (micromole_per_litre)');
LEGEND_CONSTANTS(:,66) = strpad('pAA6 in component model_parameters (dimensionless)');
LEGEND_STATES(:,41) = strpad('c07 in component c07 (micromole_per_litre)');
LEGEND_CONSTANTS(:,67) = strpad('pAA7 in component model_parameters (dimensionless)');
LEGEND_STATES(:,42) = strpad('c08 in component c08 (micromole_per_litre)');
LEGEND_CONSTANTS(:,68) = strpad('pAA8 in component model_parameters (dimensionless)');
LEGEND_STATES(:,43) = strpad('c09 in component c09 (micromole_per_litre)');
LEGEND_CONSTANTS(:,69) = strpad('pAA9 in component model_parameters (dimensionless)');
LEGEND_STATES(:,44) = strpad('c010 in component c010 (micromole_per_litre)');
LEGEND_CONSTANTS(:,70) = strpad('pAA10 in component model_parameters (dimensionless)');
LEGEND_STATES(:,45) = strpad('c011 in component c011 (micromole_per_litre)');
LEGEND_CONSTANTS(:,71) = strpad('pAA11 in component model_parameters (dimensionless)');
LEGEND_STATES(:,46) = strpad('c012 in component c012 (micromole_per_litre)');
LEGEND_CONSTANTS(:,72) = strpad('pAA12 in component model_parameters (dimensionless)');
LEGEND_STATES(:,47) = strpad('c013 in component c013 (micromole_per_litre)');
LEGEND_CONSTANTS(:,73) = strpad('pAA13 in component model_parameters (dimensionless)');
LEGEND_STATES(:,48) = strpad('c014 in component c014 (micromole_per_litre)');
LEGEND_CONSTANTS(:,74) = strpad('pAA14 in component model_parameters (dimensionless)');
LEGEND_CONSTANTS(:,75) = strpad('V1 in component model_parameters (litre)');
LEGEND_CONSTANTS(:,76) = strpad('CA1 in component c01 (micromole_per_litre)');
LEGEND_CONSTANTS(:,77) = strpad('CB1 in component model_parameters (micromole_per_litre)');
LEGEND_CONSTANTS(:,78) = strpad('CA2 in component c02 (micromole_per_litre)');
LEGEND_CONSTANTS(:,79) = strpad('CA3 in component c03 (micromole_per_litre)');
LEGEND_CONSTANTS(:,80) = strpad('CA4 in component c04 (micromole_per_litre)');
LEGEND_CONSTANTS(:,81) = strpad('CA5 in component c05 (micromole_per_litre)');
LEGEND_CONSTANTS(:,82) = strpad('CA6 in component c06 (micromole_per_litre)');
LEGEND_CONSTANTS(:,83) = strpad('CA7 in component c07 (micromole_per_litre)');
LEGEND_CONSTANTS(:,84) = strpad('CA8 in component c08 (micromole_per_litre)');
LEGEND_CONSTANTS(:,85) = strpad('CA9 in component c09 (micromole_per_litre)');
LEGEND_CONSTANTS(:,86) = strpad('CA10 in component c010 (micromole_per_litre)');
LEGEND_CONSTANTS(:,87) = strpad('CA11 in component c011 (micromole_per_litre)');
LEGEND_CONSTANTS(:,88) = strpad('CA12 in component c012 (micromole_per_litre)');
LEGEND_CONSTANTS(:,89) = strpad('CA13 in component c013 (micromole_per_litre)');
LEGEND_CONSTANTS(:,90) = strpad('CA14 in component c014 (micromole_per_litre)');
LEGEND_CONSTANTS(:,91) = strpad('CA15 in component c015 (micromole_per_litre)');
LEGEND_CONSTANTS(:,92) = strpad('CB15 in component model_parameters (micromole_per_litre)');
LEGEND_CONSTANTS(:,93) = strpad('CA16 in component c016 (micromole_per_litre)');
LEGEND_CONSTANTS(:,94) = strpad('CA17 in component c017 (micromole_per_litre)');
LEGEND_CONSTANTS(:,95) = strpad('CA18 in component c018 (micromole_per_litre)');
LEGEND_CONSTANTS(:,96) = strpad('CA19 in component c019 (micromole_per_litre)');
LEGEND_CONSTANTS(:,97) = strpad('CA20 in component c020 (micromole_per_litre)');
LEGEND_CONSTANTS(:,98) = strpad('CA21 in component c021 (micromole_per_litre)');
LEGEND_CONSTANTS(:,99) = strpad('CA22 in component c022 (micromole_per_litre)');
LEGEND_CONSTANTS(:,100) = strpad('CA23 in component c023 (micromole_per_litre)');
LEGEND_CONSTANTS(:,101) = strpad('CA24 in component c024 (micromole_per_litre)');
LEGEND_RATES(:,1) = strpad('d/dt c15 in component c15 (micromole_per_litre)');
LEGEND_RATES(:,3) = strpad('d/dt c16 in component c16 (micromole_per_litre)');
LEGEND_RATES(:,4) = strpad('d/dt c17 in component c17 (micromole_per_litre)');
LEGEND_RATES(:,8) = strpad('d/dt c18 in component c18 (micromole_per_litre)');
LEGEND_RATES(:,5) = strpad('d/dt c19 in component c19 (micromole_per_litre)');
LEGEND_RATES(:,25) = strpad('d/dt c20 in component c20 (micromole_per_litre)');
LEGEND_RATES(:,27) = strpad('d/dt c21 in component c21 (micromole_per_litre)');
LEGEND_RATES(:,29) = strpad('d/dt c22 in component c22 (micromole_per_litre)');
LEGEND_RATES(:,31) = strpad('d/dt c23 in component c23 (micromole_per_litre)');
LEGEND_RATES(:,33) = strpad('d/dt c24 in component c24 (micromole_per_litre)');
LEGEND_RATES(:,9) = strpad('d/dt c1 in component c1 (micromole_per_litre)');
LEGEND_RATES(:,10) = strpad('d/dt c2 in component c2 (micromole_per_litre)');
LEGEND_RATES(:,11) = strpad('d/dt c3 in component c3 (micromole_per_litre)');
LEGEND_RATES(:,12) = strpad('d/dt c4 in component c4 (micromole_per_litre)');
LEGEND_RATES(:,13) = strpad('d/dt c5 in component c5 (micromole_per_litre)');
LEGEND_RATES(:,14) = strpad('d/dt c6 in component c6 (micromole_per_litre)');
LEGEND_RATES(:,15) = strpad('d/dt c7 in component c7 (micromole_per_litre)');
LEGEND_RATES(:,16) = strpad('d/dt c8 in component c8 (micromole_per_litre)');
LEGEND_RATES(:,17) = strpad('d/dt c9 in component c9 (micromole_per_litre)');
LEGEND_RATES(:,24) = strpad('d/dt c10 in component c10 (micromole_per_litre)');
LEGEND_RATES(:,21) = strpad('d/dt c11 in component c11 (micromole_per_litre)');
LEGEND_RATES(:,22) = strpad('d/dt c12 in component c12 (micromole_per_litre)');
LEGEND_RATES(:,23) = strpad('d/dt c13 in component c13 (micromole_per_litre)');
LEGEND_RATES(:,18) = strpad('d/dt c14 in component c14 (micromole_per_litre)');
LEGEND_RATES(:,35) = strpad('d/dt c01 in component c01 (micromole_per_litre)');
LEGEND_RATES(:,36) = strpad('d/dt c02 in component c02 (micromole_per_litre)');
LEGEND_RATES(:,37) = strpad('d/dt c03 in component c03 (micromole_per_litre)');
LEGEND_RATES(:,38) = strpad('d/dt c04 in component c04 (micromole_per_litre)');
LEGEND_RATES(:,39) = strpad('d/dt c05 in component c05 (micromole_per_litre)');
LEGEND_RATES(:,40) = strpad('d/dt c06 in component c06 (micromole_per_litre)');
LEGEND_RATES(:,41) = strpad('d/dt c07 in component c07 (micromole_per_litre)');
LEGEND_RATES(:,42) = strpad('d/dt c08 in component c08 (micromole_per_litre)');
LEGEND_RATES(:,43) = strpad('d/dt c09 in component c09 (micromole_per_litre)');
LEGEND_RATES(:,44) = strpad('d/dt c010 in component c010 (micromole_per_litre)');
LEGEND_RATES(:,45) = strpad('d/dt c011 in component c011 (micromole_per_litre)');
LEGEND_RATES(:,46) = strpad('d/dt c012 in component c012 (micromole_per_litre)');
LEGEND_RATES(:,47) = strpad('d/dt c013 in component c013 (micromole_per_litre)');
LEGEND_RATES(:,48) = strpad('d/dt c014 in component c014 (micromole_per_litre)');
LEGEND_RATES(:,2) = strpad('d/dt c015 in component c015 (micromole_per_litre)');
LEGEND_RATES(:,6) = strpad('d/dt c016 in component c016 (micromole_per_litre)');
LEGEND_RATES(:,7) = strpad('d/dt c017 in component c017 (micromole_per_litre)');
LEGEND_RATES(:,19) = strpad('d/dt c018 in component c018 (micromole_per_litre)');
LEGEND_RATES(:,20) = strpad('d/dt c019 in component c019 (micromole_per_litre)');
LEGEND_RATES(:,26) = strpad('d/dt c020 in component c020 (micromole_per_litre)');
LEGEND_RATES(:,28) = strpad('d/dt c021 in component c021 (micromole_per_litre)');
LEGEND_RATES(:,30) = strpad('d/dt c022 in component c022 (micromole_per_litre)');
LEGEND_RATES(:,32) = strpad('d/dt c023 in component c023 (micromole_per_litre)');
LEGEND_RATES(:,34) = strpad('d/dt c024 in component c024 (micromole_per_litre)');
LEGEND_STATES  = LEGEND_STATES';
LEGEND_ALGEBRAIC = LEGEND_ALGEBRAIC';
LEGEND_RATES = LEGEND_RATES';
LEGEND_CONSTANTS = LEGEND_CONSTANTS';
end

function [STATES, CONSTANTS] = initConsts()
VOI = 0; CONSTANTS = []; STATES = []; ALGEBRAIC = [];
CONSTANTS(:,1) = 3.6;
CONSTANTS(:,2) = 1;
CONSTANTS(:,3) = 1.2;
CONSTANTS(:,4) = 0;
CONSTANTS(:,5) = 3;
CONSTANTS(:,6) = 0.024;
STATES(:,1) = 284;
CONSTANTS(:,7) = 1191.072;
CONSTANTS(:,8) = 0.9;
STATES(:,2) = 284;
CONSTANTS(:,9) = 3.593;
STATES(:,3) = 168;
CONSTANTS(:,10) = 56.73;
STATES(:,4) = 265;
CONSTANTS(:,11) = 0.0009;
STATES(:,5) = 41;
CONSTANTS(:,12) = 50.08;
CONSTANTS(:,13) = 225.76;
CONSTANTS(:,14) = 5;
CONSTANTS(:,15) = 2.8119;
CONSTANTS(:,16) = 0.31;
STATES(:,6) = 168;
CONSTANTS(:,17) = 0.25;
STATES(:,7) = 265;
CONSTANTS(:,18) = 0.0205;
STATES(:,8) = 687;
CONSTANTS(:,19) = 0.0033;
CONSTANTS(:,20) = 40.68;
CONSTANTS(:,21) = 1.816;
CONSTANTS(:,22) = 1;
STATES(:,9) = 2258;
CONSTANTS(:,23) = 16.29;
CONSTANTS(:,24) = 3;
STATES(:,10) = 940;
CONSTANTS(:,25) = 100;
CONSTANTS(:,26) = 4;
STATES(:,11) = 2604;
CONSTANTS(:,27) = 1.147;
CONSTANTS(:,28) = 1;
STATES(:,12) = 987;
CONSTANTS(:,29) = 15.99;
CONSTANTS(:,30) = 2;
STATES(:,13) = 464;
CONSTANTS(:,31) = 4.148;
CONSTANTS(:,32) = 1;
STATES(:,14) = 1300;
CONSTANTS(:,33) = 3.723;
CONSTANTS(:,34) = 1;
STATES(:,15) = 500;
CONSTANTS(:,35) = 1.573;
CONSTANTS(:,36) = 1;
STATES(:,16) = 1825;
CONSTANTS(:,37) = 1.135;
CONSTANTS(:,38) = 1;
STATES(:,17) = 2215;
CONSTANTS(:,39) = 9.326;
CONSTANTS(:,40) = 1;
STATES(:,18) = 859;
CONSTANTS(:,41) = 0;
CONSTANTS(:,42) = 0;
CONSTANTS(:,43) = 38.05;
CONSTANTS(:,44) = 1.27;
STATES(:,19) = 687;
CONSTANTS(:,45) = 0.06;
STATES(:,20) = 41;
CONSTANTS(:,46) = 34.53;
CONSTANTS(:,47) = 1;
STATES(:,21) = 259;
CONSTANTS(:,48) = 10.8;
CONSTANTS(:,49) = 1;
STATES(:,22) = 861;
CONSTANTS(:,50) = 10.76;
CONSTANTS(:,51) = 1;
STATES(:,23) = 1957;
CONSTANTS(:,52) = 0.192;
CONSTANTS(:,53) = 1;
STATES(:,24) = 327;
STATES(:,25) = 0;
STATES(:,26) = 0;
STATES(:,27) = 0;
STATES(:,28) = 0;
STATES(:,29) = 0;
STATES(:,30) = 0;
STATES(:,31) = 8159;
STATES(:,32) = 0;
CONSTANTS(:,54) = 1.31;
STATES(:,33) = 8159;
STATES(:,34) = 0;
CONSTANTS(:,55) = 0;
CONSTANTS(:,56) = 478.7;
CONSTANTS(:,57) = 0.5474;
CONSTANTS(:,58) = 0;
CONSTANTS(:,59) = 1;
CONSTANTS(:,60) = 0.6804;
STATES(:,35) = 2258;
CONSTANTS(:,61) = 1.4;
STATES(:,36) = 940;
CONSTANTS(:,62) = 0.18;
STATES(:,37) = 2604;
CONSTANTS(:,63) = 0;
STATES(:,38) = 987;
CONSTANTS(:,64) = 1.19;
STATES(:,39) = 464;
CONSTANTS(:,65) = 0.45;
STATES(:,40) = 1300;
CONSTANTS(:,66) = 1.05;
STATES(:,41) = 500;
CONSTANTS(:,67) = 0.62;
STATES(:,42) = 1825;
CONSTANTS(:,68) = 1.15;
STATES(:,43) = 2215;
CONSTANTS(:,69) = 1;
STATES(:,44) = 327;
CONSTANTS(:,70) = 0.15;
STATES(:,45) = 259;
CONSTANTS(:,71) = 0.77;
STATES(:,46) = 861;
CONSTANTS(:,72) = 1.55;
STATES(:,47) = 1957;
CONSTANTS(:,73) = 0.78;
STATES(:,48) = 859;
CONSTANTS(:,74) = 1.81;
CONSTANTS(:,75) = 0.6;
CONSTANTS(:,76) = 2258;
CONSTANTS(:,77) = 0;
CONSTANTS(:,78) = 940;
CONSTANTS(:,79) = 2604;
CONSTANTS(:,80) = 987;
CONSTANTS(:,81) = 464;
CONSTANTS(:,82) = 1300;
CONSTANTS(:,83) = 500;
CONSTANTS(:,84) = 1825;
CONSTANTS(:,85) = 2215;
CONSTANTS(:,86) = 327;
CONSTANTS(:,87) = 259;
CONSTANTS(:,88) = 861;
CONSTANTS(:,89) = 1957;
CONSTANTS(:,90) = 859;
CONSTANTS(:,91) = 284;
CONSTANTS(:,92) = 1500;
CONSTANTS(:,93) = 168;
CONSTANTS(:,94) = 265;
CONSTANTS(:,95) = 687;
CONSTANTS(:,96) = 41;
CONSTANTS(:,97) = 0;
CONSTANTS(:,98) = 0;
CONSTANTS(:,99) = 0;
CONSTANTS(:,100) = 0;
CONSTANTS(:,101) = 0;
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(:,25) =  (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,26) - STATES(:,25))+ (( CONSTANTS(:,13).*STATES(:,1))./(CONSTANTS(:,14)+STATES(:,1))).*STATES(:,5);
RATES(:,27) =  (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,28) - STATES(:,27)) -  CONSTANTS(:,19).*STATES(:,27);
RATES(:,29) =  (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,30) - STATES(:,29)) -  CONSTANTS(:,18).*STATES(:,29);
RATES(:,31) = (( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,32) - STATES(:,31))+ CONSTANTS(:,19).*STATES(:,27)+ CONSTANTS(:,18).*STATES(:,29)) -  CONSTANTS(:,20).*STATES(:,31))+ (( CONSTANTS(:,54).*STATES(:,1))./(CONSTANTS(:,14)+STATES(:,1))).*STATES(:,5);
RATES(:,33) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,34) - STATES(:,33))+ 2.00000.*CONSTANTS(:,55).*CONSTANTS(:,20).*STATES(:,31)+ (( CONSTANTS(:,56).*STATES(:,1))./(CONSTANTS(:,14)+STATES(:,1))).*STATES(:,5)) -  CONSTANTS(:,57).*STATES(:,33);
ALGEBRAIC(:,2) = piecewise({VOI<CONSTANTS(:,59), CONSTANTS(:,58) }, 0.00000);
RATES(:,1) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,2) - STATES(:,1))+ CONSTANTS(:,9).*STATES(:,3)+ CONSTANTS(:,12).*STATES(:,4)+ CONSTANTS(:,16).*ALGEBRAIC(:,2)) -  ( CONSTANTS(:,11).*STATES(:,5)+CONSTANTS(:,10)+( CONSTANTS(:,13).*STATES(:,5))./(CONSTANTS(:,14)+STATES(:,1))+CONSTANTS(:,15)).*STATES(:,1);
RATES(:,3) = (( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,6) - STATES(:,3))+ CONSTANTS(:,11).*STATES(:,1).*STATES(:,5)) -  CONSTANTS(:,9).*STATES(:,3))+ CONSTANTS(:,17).*ALGEBRAIC(:,2);
RATES(:,4) = (( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,7) - STATES(:,4))+ CONSTANTS(:,21).*CONSTANTS(:,22).*STATES(:,9)+ CONSTANTS(:,23).*CONSTANTS(:,24).*STATES(:,10)+ CONSTANTS(:,25).*CONSTANTS(:,26).*STATES(:,11)+ CONSTANTS(:,27).*CONSTANTS(:,28).*STATES(:,12)+ CONSTANTS(:,29).*CONSTANTS(:,30).*STATES(:,13)+ CONSTANTS(:,31).*CONSTANTS(:,32).*STATES(:,14)+ CONSTANTS(:,33).*CONSTANTS(:,34).*STATES(:,15)+ CONSTANTS(:,35).*CONSTANTS(:,36).*STATES(:,16)+ CONSTANTS(:,37).*CONSTANTS(:,38).*STATES(:,17)+ CONSTANTS(:,39).*CONSTANTS(:,40).*STATES(:,18)+ CONSTANTS(:,10).*STATES(:,1)+ CONSTANTS(:,42).*STATES(:,8)) -  (CONSTANTS(:,12)+ CONSTANTS(:,41).*STATES(:,5)+CONSTANTS(:,43)).*STATES(:,4))+ CONSTANTS(:,44).*ALGEBRAIC(:,2);
RATES(:,8) = (( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,19) - STATES(:,8))+ CONSTANTS(:,41).*STATES(:,4).*STATES(:,5)) -  CONSTANTS(:,42).*STATES(:,8))+ CONSTANTS(:,45).*ALGEBRAIC(:,2);
ALGEBRAIC(:,3) = piecewise({VOI<3.00000, 0.00000 }, CONSTANTS(:,60));
RATES(:,5) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,20) - STATES(:,5))+ CONSTANTS(:,46).*CONSTANTS(:,47).*STATES(:,21)+ CONSTANTS(:,48).*CONSTANTS(:,49).*STATES(:,22)+ CONSTANTS(:,50).*STATES(:,23).*CONSTANTS(:,51)+ CONSTANTS(:,52).*STATES(:,24).*CONSTANTS(:,53)+ CONSTANTS(:,20).*(1.00000 - ALGEBRAIC(:,3)).*STATES(:,4)+ CONSTANTS(:,9).*STATES(:,3)+ CONSTANTS(:,42).*STATES(:,8)) -  (( CONSTANTS(:,13).*STATES(:,1))./(CONSTANTS(:,14)+STATES(:,1))+ CONSTANTS(:,11).*STATES(:,1)+ CONSTANTS(:,41).*STATES(:,4)).*STATES(:,5);
RATES(:,9) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,35) - STATES(:,9)) -  CONSTANTS(:,21).*STATES(:,9))+ CONSTANTS(:,61).*ALGEBRAIC(:,2);
RATES(:,10) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,36) - STATES(:,10)) -  CONSTANTS(:,23).*STATES(:,10))+ CONSTANTS(:,62).*ALGEBRAIC(:,2);
RATES(:,11) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,37) - STATES(:,11)) -  CONSTANTS(:,25).*STATES(:,11))+ CONSTANTS(:,63).*ALGEBRAIC(:,2);
RATES(:,12) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,38) - STATES(:,12)) -  CONSTANTS(:,27).*STATES(:,12))+ CONSTANTS(:,64).*ALGEBRAIC(:,2);
RATES(:,13) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,39) - STATES(:,13)) -  CONSTANTS(:,29).*STATES(:,13))+ CONSTANTS(:,65).*ALGEBRAIC(:,2);
RATES(:,14) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,40) - STATES(:,14)) -  CONSTANTS(:,31).*STATES(:,14))+ CONSTANTS(:,66).*ALGEBRAIC(:,2);
RATES(:,15) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,41) - STATES(:,15)) -  CONSTANTS(:,33).*STATES(:,15))+ CONSTANTS(:,67).*ALGEBRAIC(:,2);
RATES(:,16) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,42) - STATES(:,16)) -  CONSTANTS(:,35).*STATES(:,16))+ CONSTANTS(:,68).*ALGEBRAIC(:,2);
RATES(:,17) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,43) - STATES(:,17)) -  CONSTANTS(:,37).*STATES(:,17))+ CONSTANTS(:,69).*ALGEBRAIC(:,2);
RATES(:,24) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,44) - STATES(:,24)) -  CONSTANTS(:,52).*STATES(:,24))+ CONSTANTS(:,70).*ALGEBRAIC(:,2);
RATES(:,21) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,45) - STATES(:,21)) -  CONSTANTS(:,46).*STATES(:,21))+ CONSTANTS(:,71).*ALGEBRAIC(:,2);
RATES(:,22) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,46) - STATES(:,22)) -  CONSTANTS(:,48).*STATES(:,22))+ CONSTANTS(:,72).*ALGEBRAIC(:,2);
RATES(:,23) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,47) - STATES(:,23)) -  CONSTANTS(:,50).*STATES(:,23))+ CONSTANTS(:,73).*ALGEBRAIC(:,2);
RATES(:,18) = ( (CONSTANTS(:,7)./CONSTANTS(:,8)).*(STATES(:,48) - STATES(:,18)) -  CONSTANTS(:,39).*STATES(:,18))+ CONSTANTS(:,74).*ALGEBRAIC(:,2);
ALGEBRAIC(:,1) = piecewise({VOI>=CONSTANTS(:,2), CONSTANTS(:,3) }, CONSTANTS(:,1));
ALGEBRAIC(:,4) = piecewise({VOI>=CONSTANTS(:,5), CONSTANTS(:,6) }, CONSTANTS(:,4));
ALGEBRAIC(:,5) = ALGEBRAIC(:,1)+ALGEBRAIC(:,4);
RATES(:,35) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,76)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,35)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,35) - STATES(:,9));
RATES(:,36) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,78)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,36)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,36) - STATES(:,10));
RATES(:,37) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,79)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,37)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,37) - STATES(:,11));
RATES(:,38) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,80)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,38)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,38) - STATES(:,12));
RATES(:,39) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,81)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,39)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,39) - STATES(:,13));
RATES(:,40) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,82)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,40)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,40) - STATES(:,14));
RATES(:,41) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,83)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,41)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,41) - STATES(:,15));
RATES(:,42) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,84)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,42)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,42) - STATES(:,16));
RATES(:,43) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,85)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,43)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,43) - STATES(:,17));
RATES(:,44) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,86)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,44)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,44) - STATES(:,24));
RATES(:,45) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,87)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,45)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,45) - STATES(:,21));
RATES(:,46) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,88)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,46)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,46) - STATES(:,22));
RATES(:,47) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,89)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,47)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,47) - STATES(:,23));
RATES(:,48) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,90)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,48)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,48) - STATES(:,18));
RATES(:,2) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,91)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,92)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,2)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,2) - STATES(:,1));
RATES(:,6) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,93)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,6)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,6) - STATES(:,3));
RATES(:,7) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,94)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,7)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,7) - STATES(:,4));
RATES(:,19) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,95)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,19)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,19) - STATES(:,8));
RATES(:,20) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,96)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,20)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,20) - STATES(:,5));
RATES(:,26) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,97)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,26)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,26) - STATES(:,25));
RATES(:,28) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,98)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,28)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,28) - STATES(:,27));
RATES(:,30) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,99)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,30)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,30) - STATES(:,29));
RATES(:,32) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,100)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,32)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,32) - STATES(:,31));
RATES(:,34) = (( (ALGEBRAIC(:,1)./CONSTANTS(:,75)).*CONSTANTS(:,101)+ (ALGEBRAIC(:,4)./CONSTANTS(:,75)).*CONSTANTS(:,77)) -  (ALGEBRAIC(:,5)./CONSTANTS(:,75)).*STATES(:,34)) -  (CONSTANTS(:,7)./CONSTANTS(:,75)).*(STATES(:,34) - STATES(:,33));
RATES = RATES';
end

% Calculate algebraic variables
function ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI)
statesSize = size(STATES);
statesColumnCount = statesSize(2);
if ( statesColumnCount == 1)
STATES = STATES';
utilOnes = 1;
else
statesRowCount = statesSize(1);
utilOnes = ones(statesRowCount, 1);
end
ALGEBRAIC(:,2) = piecewise({VOI<CONSTANTS(:,59), CONSTANTS(:,58) }, 0.00000);
ALGEBRAIC(:,3) = piecewise({VOI<3.00000, 0.00000 }, CONSTANTS(:,60));
ALGEBRAIC(:,1) = piecewise({VOI>=CONSTANTS(:,2), CONSTANTS(:,3) }, CONSTANTS(:,1));
ALGEBRAIC(:,4) = piecewise({VOI>=CONSTANTS(:,5), CONSTANTS(:,6) }, CONSTANTS(:,4));
ALGEBRAIC(:,5) = ALGEBRAIC(:,1)+ALGEBRAIC(:,4);
end

% Compute result of a piecewise function
function x = piecewise(cases, default)
set = [0];
for i = 1:2:length(cases)
if (length(cases{i+1}) == 1)
x(cases{i} & ~set,:) = cases{i+1};
else
x(cases{i} & ~set,:) = cases{i+1}(cases{i} & ~set);
end
set = set | cases{i};
if(set), break, end
end
if (length(default) == 1)
x(~set,:) = default;
else
x(~set,:) = default(~set);
end
end

% Pad out or shorten strings to a set length
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

```
Collaboration
To begin collaborating on this work, please use your git client and issue this command: