# 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 =10;
end
% There are a total of 11 entries in each of the rate and state variable arrays.
% There are a total of 45 entries in the constant variable array.
%

function [VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel()
% Create ALGEBRAIC of correct size
global algebraicVariableCount;  algebraicVariableCount = getAlgebraicVariableCount();
% Initialise constants and state variables
[INIT_STATES, CONSTANTS] = initConsts;

% Set timespan to solve over
tspan = [0, 10];

% Set numerical accuracy options for ODE solver
options = odeset('RelTol', 1e-06, 'AbsTol', 1e-06, 'MaxStep', 1);

% Solve model with ODE solver
[VOI, STATES] = ode15s(@(VOI, STATES)computeRates(VOI, STATES, CONSTANTS), tspan, INIT_STATES, options);

% Compute algebraic variables
[RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS);
ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI);

% Plot state variables against variable of integration
[LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends();
figure();
plot(VOI, STATES);
xlabel(LEGEND_VOI);
l = legend(LEGEND_STATES);
set(l,'Interpreter','none');
end

function [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends()
LEGEND_STATES = ''; LEGEND_ALGEBRAIC = ''; LEGEND_VOI = ''; LEGEND_CONSTANTS = '';
LEGEND_VOI = strpad('time in component environment (minute)');
LEGEND_STATES(:,1) = strpad('Cdc13_Cdc2 in component Cdc13_Cdc2 (dimensionless)');
LEGEND_CONSTANTS(:,1) = strpad('k1 in component Cdc13_Cdc2 (first_order_rate_constant)');
LEGEND_ALGEBRAIC(:,4) = strpad('kwee in component kwee (first_order_rate_constant)');
LEGEND_CONSTANTS(:,2) = strpad('ki in component parameters (first_order_rate_constant)');
LEGEND_ALGEBRAIC(:,3) = strpad('kcdc25 in component kcdc25 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,3) = strpad('kir in component parameters (first_order_rate_constant)');
LEGEND_ALGEBRAIC(:,1) = strpad('k2 in component k2 (first_order_rate_constant)');
LEGEND_ALGEBRAIC(:,6) = strpad('k4 in component k4 (first_order_rate_constant)');
LEGEND_STATES(:,2) = strpad('mass in component mass (dimensionless)');
LEGEND_STATES(:,3) = strpad('Cdc13_P_Cdc2 in component Cdc13_P_Cdc2 (dimensionless)');
LEGEND_STATES(:,4) = strpad('Rum1_Cdc13_Cdc2 in component Rum1_Cdc13_Cdc2 (dimensionless)');
LEGEND_STATES(:,5) = strpad('Rum1 in component Rum1 (dimensionless)');
LEGEND_ALGEBRAIC(:,2) = strpad('k2c in component k2c (first_order_rate_constant)');
LEGEND_CONSTANTS(:,4) = strpad('k3 in component Rum1 (first_order_rate_constant)');
LEGEND_STATES(:,6) = strpad('Cdc25P in component Cdc25P (dimensionless)');
LEGEND_CONSTANTS(:,5) = strpad('k25 in component Cdc25P (first_order_rate_constant)');
LEGEND_ALGEBRAIC(:,8) = strpad('k25r in component Cdc25P (first_order_rate_constant)');
LEGEND_CONSTANTS(:,6) = strpad('k25r_ in component Cdc25P (first_order_rate_constant)');
LEGEND_CONSTANTS(:,7) = strpad('J25 in component Cdc25P (dimensionless)');
LEGEND_CONSTANTS(:,8) = strpad('J25r in component Cdc25P (dimensionless)');
LEGEND_ALGEBRAIC(:,7) = strpad('ks in component parameters (first_order_rate_constant)');
LEGEND_ALGEBRAIC(:,5) = strpad('MPF in component MPF (dimensionless)');
LEGEND_STATES(:,7) = strpad('Wee1 in component Wee1 (dimensionless)');
LEGEND_CONSTANTS(:,9) = strpad('kw in component Wee1 (first_order_rate_constant)');
LEGEND_ALGEBRAIC(:,9) = strpad('kwr in component Wee1 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,10) = strpad('kwr_ in component Wee1 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,11) = strpad('Jw in component Wee1 (dimensionless)');
LEGEND_CONSTANTS(:,12) = strpad('Jwr in component Wee1 (dimensionless)');
LEGEND_STATES(:,8) = strpad('Mik1 in component Mik1 (dimensionless)');
LEGEND_CONSTANTS(:,13) = strpad('km in component Mik1 (first_order_rate_constant)');
LEGEND_ALGEBRAIC(:,10) = strpad('kmr in component Mik1 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,14) = strpad('kmr_ in component Mik1 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,15) = strpad('Jm in component Mik1 (dimensionless)');
LEGEND_CONSTANTS(:,16) = strpad('Jmr in component Mik1 (dimensionless)');
LEGEND_STATES(:,9) = strpad('AAE_total in component AAE_total (dimensionless)');
LEGEND_CONSTANTS(:,17) = strpad('kas in component AAE_total (first_order_rate_constant)');
LEGEND_STATES(:,10) = strpad('AAE in component AAE (dimensionless)');
LEGEND_CONSTANTS(:,19) = strpad('kaa in component AAE (first_order_rate_constant)');
LEGEND_CONSTANTS(:,20) = strpad('kaa_ in component AAE (first_order_rate_constant)');
LEGEND_CONSTANTS(:,45) = strpad('kai in component AAE (first_order_rate_constant)');
LEGEND_CONSTANTS(:,21) = strpad('kai_ in component AAE (first_order_rate_constant)');
LEGEND_CONSTANTS(:,22) = strpad('kx in component AAE (first_order_rate_constant)');
LEGEND_CONSTANTS(:,23) = strpad('Jaa in component AAE (dimensionless)');
LEGEND_CONSTANTS(:,24) = strpad('Jai in component AAE (dimensionless)');
LEGEND_STATES(:,11) = strpad('APC in component APC (dimensionless)');
LEGEND_CONSTANTS(:,25) = strpad('kapr in component APC (first_order_rate_constant)');
LEGEND_CONSTANTS(:,26) = strpad('kapr_ in component APC (first_order_rate_constant)');
LEGEND_CONSTANTS(:,27) = strpad('kap in component APC (first_order_rate_constant)');
LEGEND_CONSTANTS(:,28) = strpad('Japr in component APC (dimensionless)');
LEGEND_CONSTANTS(:,29) = strpad('Jap in component APC (dimensionless)');
LEGEND_CONSTANTS(:,30) = strpad('Puc1 in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,31) = strpad('mu in component mass (first_order_rate_constant)');
LEGEND_CONSTANTS(:,32) = strpad('V2 in component k2 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,33) = strpad('V2_ in component k2 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,34) = strpad('V2c in component k2c (first_order_rate_constant)');
LEGEND_CONSTANTS(:,35) = strpad('V2c_ in component k2c (first_order_rate_constant)');
LEGEND_CONSTANTS(:,36) = strpad('k4_ in component k4 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,37) = strpad('k4__ in component k4 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,38) = strpad('V25 in component kcdc25 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,39) = strpad('V25_ in component kcdc25 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,40) = strpad('Vwee in component kwee (first_order_rate_constant)');
LEGEND_CONSTANTS(:,41) = strpad('Vwee_ in component kwee (first_order_rate_constant)');
LEGEND_CONSTANTS(:,42) = strpad('Vmik in component kwee (first_order_rate_constant)');
LEGEND_CONSTANTS(:,43) = strpad('Vmik_ in component kwee (first_order_rate_constant)');
LEGEND_CONSTANTS(:,44) = strpad('alpha in component MPF (dimensionless)');
LEGEND_RATES(:,1) = strpad('d/dt Cdc13_Cdc2 in component Cdc13_Cdc2 (dimensionless)');
LEGEND_RATES(:,3) = strpad('d/dt Cdc13_P_Cdc2 in component Cdc13_P_Cdc2 (dimensionless)');
LEGEND_RATES(:,4) = strpad('d/dt Rum1_Cdc13_Cdc2 in component Rum1_Cdc13_Cdc2 (dimensionless)');
LEGEND_RATES(:,5) = strpad('d/dt Rum1 in component Rum1 (dimensionless)');
LEGEND_RATES(:,6) = strpad('d/dt Cdc25P in component Cdc25P (dimensionless)');
LEGEND_RATES(:,7) = strpad('d/dt Wee1 in component Wee1 (dimensionless)');
LEGEND_RATES(:,8) = strpad('d/dt Mik1 in component Mik1 (dimensionless)');
LEGEND_RATES(:,9) = strpad('d/dt AAE_total in component AAE_total (dimensionless)');
LEGEND_RATES(:,10) = strpad('d/dt AAE in component AAE (dimensionless)');
LEGEND_RATES(:,11) = strpad('d/dt APC in component APC (dimensionless)');
LEGEND_RATES(:,2) = strpad('d/dt mass in component mass (dimensionless)');
LEGEND_STATES  = LEGEND_STATES';
LEGEND_ALGEBRAIC = LEGEND_ALGEBRAIC';
LEGEND_RATES = LEGEND_RATES';
LEGEND_CONSTANTS = LEGEND_CONSTANTS';
end

function [STATES, CONSTANTS] = initConsts()
VOI = 0; CONSTANTS = []; STATES = []; ALGEBRAIC = [];
STATES(:,1) = 1;
CONSTANTS(:,1) = 0.03;
CONSTANTS(:,2) = 200;
CONSTANTS(:,3) = 1;
STATES(:,2) = 1;
STATES(:,3) = 0;
STATES(:,4) = 0;
STATES(:,5) = 0;
CONSTANTS(:,4) = 0.15;
STATES(:,6) = 0;
CONSTANTS(:,5) = 0.5;
CONSTANTS(:,6) = 0.2;
CONSTANTS(:,7) = 0.2;
CONSTANTS(:,8) = 0.2;
STATES(:,7) = 0;
CONSTANTS(:,9) = 0.5;
CONSTANTS(:,10) = 0.2;
CONSTANTS(:,11) = 0.2;
CONSTANTS(:,12) = 0.2;
STATES(:,8) = 0;
CONSTANTS(:,13) = 0.1;
CONSTANTS(:,14) = 0;
CONSTANTS(:,15) = 0.2;
CONSTANTS(:,16) = 0.2;
STATES(:,9) = 2;
CONSTANTS(:,17) = 0.25;
CONSTANTS(:,18) = 0.1;
STATES(:,10) = 2;
CONSTANTS(:,19) = 0.001;
CONSTANTS(:,20) = 1;
CONSTANTS(:,21) = 0.25;
CONSTANTS(:,22) = 0;
CONSTANTS(:,23) = 0.1;
CONSTANTS(:,24) = 0.1;
STATES(:,11) = 0;
CONSTANTS(:,25) = 0.04;
CONSTANTS(:,26) = 3;
CONSTANTS(:,27) = 4;
CONSTANTS(:,28) = 0.01;
CONSTANTS(:,29) = 0.01;
CONSTANTS(:,30) = 0.013;
CONSTANTS(:,31) = 0.005776;
CONSTANTS(:,32) = 0.03;
CONSTANTS(:,33) = 1;
CONSTANTS(:,34) = 0.03;
CONSTANTS(:,35) = 0.16;
CONSTANTS(:,36) = 0.15;
CONSTANTS(:,37) = 20;
CONSTANTS(:,38) = 0.01;
CONSTANTS(:,39) = 0.4;
CONSTANTS(:,40) = 0.01;
CONSTANTS(:,41) = 0.93;
CONSTANTS(:,42) = 0.002;
CONSTANTS(:,43) = 0.2;
CONSTANTS(:,44) = 0.1;
CONSTANTS(:,45) = CONSTANTS(:,21)+CONSTANTS(:,22);
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(:,2) =  CONSTANTS(:,31).*STATES(:,2);
ALGEBRAIC(:,4) =  CONSTANTS(:,40).*( (1.00000 - STATES(:,7)).*1.00000+ CONSTANTS(:,41).*STATES(:,7)+ CONSTANTS(:,42).*(1.00000 - STATES(:,8))).*1.00000+ CONSTANTS(:,43).*STATES(:,8);
ALGEBRAIC(:,3) =  CONSTANTS(:,38).*(1.00000 - STATES(:,6))+ CONSTANTS(:,39).*STATES(:,6);
ALGEBRAIC(:,1) =  CONSTANTS(:,32).*(1.00000 - STATES(:,11))+ CONSTANTS(:,33).*STATES(:,11);
RATES(:,3) =  ALGEBRAIC(:,4).*STATES(:,1) - ( ALGEBRAIC(:,3).*STATES(:,3)+ ALGEBRAIC(:,1).*STATES(:,3));
ALGEBRAIC(:,5) = STATES(:,1)+ CONSTANTS(:,44).*STATES(:,3);
RATES(:,9) =  CONSTANTS(:,17).*ALGEBRAIC(:,5) -  CONSTANTS(:,18).*STATES(:,9);
RATES(:,10) = ( (CONSTANTS(:,19)+ CONSTANTS(:,20).*ALGEBRAIC(:,5)).*(STATES(:,9) - STATES(:,10)))./((CONSTANTS(:,23)+STATES(:,9)) - STATES(:,10)) - (( CONSTANTS(:,45).*STATES(:,10))./(CONSTANTS(:,24)+STATES(:,10))+ CONSTANTS(:,18).*STATES(:,10));
RATES(:,11) = ( (CONSTANTS(:,25)+ CONSTANTS(:,26).*STATES(:,10)).*(1.00000 - STATES(:,11)))./((CONSTANTS(:,28)+1.00000) - STATES(:,11)) - ( CONSTANTS(:,27).*( CONSTANTS(:,30).*STATES(:,2)+ALGEBRAIC(:,5)).*STATES(:,11))./(CONSTANTS(:,29)+STATES(:,11));
ALGEBRAIC(:,6) = CONSTANTS(:,36)+ CONSTANTS(:,37).*( CONSTANTS(:,30).*STATES(:,2)+ALGEBRAIC(:,5));
RATES(:,1) = ( CONSTANTS(:,1).*STATES(:,2)+ ALGEBRAIC(:,3).*STATES(:,3)+ STATES(:,4).*(CONSTANTS(:,3)+ALGEBRAIC(:,6))) - ( ALGEBRAIC(:,4).*STATES(:,1)+ CONSTANTS(:,2).*STATES(:,1).*STATES(:,5)+ ALGEBRAIC(:,1).*STATES(:,1));
ALGEBRAIC(:,2) =  CONSTANTS(:,34).*(1.00000 - STATES(:,11))+ CONSTANTS(:,35).*STATES(:,11);
RATES(:,4) =  CONSTANTS(:,2).*STATES(:,5).*STATES(:,1) -  STATES(:,4).*(ALGEBRAIC(:,6)+ALGEBRAIC(:,2)+CONSTANTS(:,3));
RATES(:,5) = (CONSTANTS(:,4)+ STATES(:,4).*(CONSTANTS(:,3)+ALGEBRAIC(:,2))) - ( ALGEBRAIC(:,6).*STATES(:,5)+ CONSTANTS(:,2).*STATES(:,1).*STATES(:,5));
ALGEBRAIC(:,7) = piecewise({STATES(:,11)<=0.200000, 0.500000 }, 0.00000);
ALGEBRAIC(:,8) = CONSTANTS(:,6)+ALGEBRAIC(:,7);
RATES(:,6) = ( CONSTANTS(:,5).*ALGEBRAIC(:,5).*(1.00000 - STATES(:,6)))./((CONSTANTS(:,7)+1.00000) - STATES(:,6)) - ( ALGEBRAIC(:,8).*STATES(:,6))./(CONSTANTS(:,8)+STATES(:,6));
ALGEBRAIC(:,9) = CONSTANTS(:,10)+ALGEBRAIC(:,7);
RATES(:,7) = ( ALGEBRAIC(:,9).*(1.00000 - STATES(:,7)))./((CONSTANTS(:,12)+1.00000) - STATES(:,7)) - ( CONSTANTS(:,9).*ALGEBRAIC(:,5).*STATES(:,7))./(CONSTANTS(:,11)+STATES(:,7));
ALGEBRAIC(:,10) = CONSTANTS(:,14)+ALGEBRAIC(:,7);
RATES(:,8) = ( ALGEBRAIC(:,10).*(1.00000 - STATES(:,8)))./((CONSTANTS(:,16)+1.00000) - STATES(:,8)) - ( CONSTANTS(:,13).*STATES(:,8))./(CONSTANTS(:,15)+STATES(:,8));
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(:,4) =  CONSTANTS(:,40).*( (1.00000 - STATES(:,7)).*1.00000+ CONSTANTS(:,41).*STATES(:,7)+ CONSTANTS(:,42).*(1.00000 - STATES(:,8))).*1.00000+ CONSTANTS(:,43).*STATES(:,8);
ALGEBRAIC(:,3) =  CONSTANTS(:,38).*(1.00000 - STATES(:,6))+ CONSTANTS(:,39).*STATES(:,6);
ALGEBRAIC(:,1) =  CONSTANTS(:,32).*(1.00000 - STATES(:,11))+ CONSTANTS(:,33).*STATES(:,11);
ALGEBRAIC(:,5) = STATES(:,1)+ CONSTANTS(:,44).*STATES(:,3);
ALGEBRAIC(:,6) = CONSTANTS(:,36)+ CONSTANTS(:,37).*( CONSTANTS(:,30).*STATES(:,2)+ALGEBRAIC(:,5));
ALGEBRAIC(:,2) =  CONSTANTS(:,34).*(1.00000 - STATES(:,11))+ CONSTANTS(:,35).*STATES(:,11);
ALGEBRAIC(:,7) = piecewise({STATES(:,11)<=0.200000, 0.500000 }, 0.00000);
ALGEBRAIC(:,8) = CONSTANTS(:,6)+ALGEBRAIC(:,7);
ALGEBRAIC(:,9) = CONSTANTS(:,10)+ALGEBRAIC(:,7);
ALGEBRAIC(:,10) = CONSTANTS(:,14)+ALGEBRAIC(:,7);
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

Source
Derived from workspace Novak, Csikasznagy, Gyorffy, Chen, Tyson, 1998 at changeset 4de4e8c9f085.
Collaboration
To begin collaborating on this work, please use your git client and issue this command: