# 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 =4;
end
% There are a total of 17 entries in each of the rate and state variable arrays.
% There are a total of 43 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('MPF_n in component MPF_n (dimensionless)');
LEGEND_CONSTANTS(:,1) = strpad('k_in in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,2) = strpad('k_out in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,3) = strpad('k_dn_ in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,4) = strpad('k_dn__ in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,5) = strpad('k_wee_ in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,6) = strpad('k_wee__ in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,7) = strpad('k_stg_ in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,8) = strpad('k_stg__ in component parameters (first_order_rate_constant)');
LEGEND_STATES(:,2) = strpad('MPF_c in component MPF_c (dimensionless)');
LEGEND_STATES(:,3) = strpad('FZY in component FZY (dimensionless)');
LEGEND_STATES(:,4) = strpad('Wee1_n in component Wee1_n (dimensionless)');
LEGEND_STATES(:,5) = strpad('StgP_n in component StgP_n (dimensionless)');
LEGEND_STATES(:,6) = strpad('preMPF_n in component preMPF_n (dimensionless)');
LEGEND_STATES(:,7) = strpad('preMPF_c in component preMPF_c (dimensionless)');
LEGEND_CONSTANTS(:,9) = strpad('k_sc in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,10) = strpad('k_dc_ in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,11) = strpad('epsilon in component parameters (dimensionless)');
LEGEND_STATES(:,8) = strpad('N in component N (dimensionless)');
LEGEND_STATES(:,9) = strpad('StgP_c in component StgP_c (dimensionless)');
LEGEND_STATES(:,10) = strpad('Wee1_c in component Wee1_c (dimensionless)');
LEGEND_STATES(:,11) = strpad('IE in component IE (dimensionless)');
LEGEND_CONSTANTS(:,12) = strpad('j_aie in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,13) = strpad('j_iie in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,14) = strpad('k_aie in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,15) = strpad('k_iie in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,16) = strpad('j_afz in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,17) = strpad('j_ifz in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,18) = strpad('k_afz in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,19) = strpad('k_ifz in component parameters (first_order_rate_constant)');
LEGEND_STATES(:,12) = strpad('Stg_m in component Stg_m (dimensionless)');
LEGEND_CONSTANTS(:,20) = strpad('k_dm_ in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,21) = strpad('k_dm__ in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,22) = strpad('j_m in component parameters (dimensionless)');
LEGEND_STATES(:,13) = strpad('Xp in component Xp (dimensionless)');
LEGEND_STATES(:,14) = strpad('Xm in component Xm (dimensionless)');
LEGEND_CONSTANTS(:,23) = strpad('k_sxm in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,24) = strpad('k_sxp in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,25) = strpad('k_ins in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,26) = strpad('k_outs in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,27) = strpad('k_astg_ in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,28) = strpad('k_astg__ in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,29) = strpad('k_istg in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,30) = strpad('k_dstg in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,31) = strpad('j_astg in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,32) = strpad('j_istg in component parameters (dimensionless)');
LEGEND_STATES(:,15) = strpad('Stg_n in component Stg_n (dimensionless)');
LEGEND_STATES(:,16) = strpad('Stg_c in component Stg_c (dimensionless)');
LEGEND_CONSTANTS(:,33) = strpad('k_sstg in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,34) = strpad('k_inw in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,35) = strpad('k_outw in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,36) = strpad('k_awee in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,37) = strpad('k_iwee_ in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,38) = strpad('k_iwee__ in component parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,39) = strpad('j_awee in component parameters (dimensionless)');
LEGEND_CONSTANTS(:,40) = strpad('j_iwee in component parameters (dimensionless)');
LEGEND_STATES(:,17) = strpad('Wee1P_n in component Wee1P_n (dimensionless)');
LEGEND_ALGEBRAIC(:,1) = strpad('Wee1P_c in component Wee1P_c (dimensionless)');
LEGEND_CONSTANTS(:,41) = strpad('Wee1_T in component Wee1P_c (dimensionless)');
LEGEND_ALGEBRAIC(:,2) = strpad('CycB_T in component CycB_T (dimensionless)');
LEGEND_ALGEBRAIC(:,3) = strpad('Stg_T in component Stg_T (dimensionless)');
LEGEND_ALGEBRAIC(:,4) = strpad('StgP_T in component StgP_T (dimensionless)');
LEGEND_CONSTANTS(:,42) = strpad('k_ez in component parameters (first_order_rate_constant)');
LEGEND_RATES(:,1) = strpad('d/dt MPF_n in component MPF_n (dimensionless)');
LEGEND_RATES(:,6) = strpad('d/dt preMPF_n in component preMPF_n (dimensionless)');
LEGEND_RATES(:,2) = strpad('d/dt MPF_c in component MPF_c (dimensionless)');
LEGEND_RATES(:,7) = strpad('d/dt preMPF_c in component preMPF_c (dimensionless)');
LEGEND_RATES(:,11) = strpad('d/dt IE in component IE (dimensionless)');
LEGEND_RATES(:,3) = strpad('d/dt FZY in component FZY (dimensionless)');
LEGEND_RATES(:,12) = strpad('d/dt Stg_m in component Stg_m (dimensionless)');
LEGEND_RATES(:,14) = strpad('d/dt Xm in component Xm (dimensionless)');
LEGEND_RATES(:,13) = strpad('d/dt Xp in component Xp (dimensionless)');
LEGEND_RATES(:,5) = strpad('d/dt StgP_n in component StgP_n (dimensionless)');
LEGEND_RATES(:,15) = strpad('d/dt Stg_n in component Stg_n (dimensionless)');
LEGEND_RATES(:,9) = strpad('d/dt StgP_c in component StgP_c (dimensionless)');
LEGEND_RATES(:,16) = strpad('d/dt Stg_c in component Stg_c (dimensionless)');
LEGEND_RATES(:,4) = strpad('d/dt Wee1_n in component Wee1_n (dimensionless)');
LEGEND_RATES(:,10) = strpad('d/dt Wee1_c in component Wee1_c (dimensionless)');
LEGEND_RATES(:,17) = strpad('d/dt Wee1P_n in component Wee1P_n (dimensionless)');
LEGEND_RATES(:,8) = strpad('d/dt N in component N (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) = 0;
CONSTANTS(:,1) = 0.15;
CONSTANTS(:,2) = 0;
CONSTANTS(:,3) = 0.01;
CONSTANTS(:,4) = 1.5;
CONSTANTS(:,5) = 0.005;
CONSTANTS(:,6) = 1;
CONSTANTS(:,7) = 0.2;
CONSTANTS(:,8) = 2;
STATES(:,2) = 1;
STATES(:,3) = 0;
STATES(:,4) = 0;
STATES(:,5) = 0;
STATES(:,6) = 0;
STATES(:,7) = 0;
CONSTANTS(:,9) = 0.01;
CONSTANTS(:,10) = 0.01;
CONSTANTS(:,11) = 0.00007;
STATES(:,8) = 1;
STATES(:,9) = 0;
STATES(:,10) = 0;
STATES(:,11) = 0;
CONSTANTS(:,12) = 0.01;
CONSTANTS(:,13) = 0.01;
CONSTANTS(:,14) = 1;
CONSTANTS(:,15) = 0.4;
CONSTANTS(:,16) = 0.01;
CONSTANTS(:,17) = 0.01;
CONSTANTS(:,18) = 1;
CONSTANTS(:,19) = 0.2;
STATES(:,12) = 1;
CONSTANTS(:,20) = 0.002;
CONSTANTS(:,21) = 0.2;
CONSTANTS(:,22) = 0.05;
STATES(:,13) = 0;
STATES(:,14) = 0;
CONSTANTS(:,23) = 0.0005;
CONSTANTS(:,24) = 0.001;
CONSTANTS(:,25) = 0.08;
CONSTANTS(:,26) = 0.02;
CONSTANTS(:,27) = 0;
CONSTANTS(:,28) = 1;
CONSTANTS(:,29) = 0.3;
CONSTANTS(:,30) = 0.015;
CONSTANTS(:,31) = 0.05;
CONSTANTS(:,32) = 0.05;
STATES(:,15) = 0;
STATES(:,16) = 1;
CONSTANTS(:,33) = 0.02;
CONSTANTS(:,34) = 0.04;
CONSTANTS(:,35) = 0.01;
CONSTANTS(:,36) = 0.3;
CONSTANTS(:,37) = 0.01;
CONSTANTS(:,38) = 1;
CONSTANTS(:,39) = 0.05;
CONSTANTS(:,40) = 0.05;
STATES(:,17) = 0;
CONSTANTS(:,41) = 0.8;
CONSTANTS(:,42) = 0.5;
CONSTANTS(:,42) = 0.00000;
if (isempty(STATES)), warning('Initial values for states not set');, end
end

function [RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS)
global algebraicVariableCount;
statesSize = size(STATES);
statesColumnCount = statesSize(2);
if ( statesColumnCount == 1)
STATES = STATES';
ALGEBRAIC = zeros(1, algebraicVariableCount);
utilOnes = 1;
else
statesRowCount = statesSize(1);
ALGEBRAIC = zeros(statesRowCount, algebraicVariableCount);
RATES = zeros(statesRowCount, statesColumnCount);
utilOnes = ones(statesRowCount, 1);
end
RATES(:,8) = CONSTANTS(:,42);
RATES(:,1) = ((( CONSTANTS(:,1).*STATES(:,2) -  CONSTANTS(:,2).*STATES(:,1)) -  (CONSTANTS(:,3)+ CONSTANTS(:,4).*STATES(:,3)).*STATES(:,1)) -  (CONSTANTS(:,5)+ CONSTANTS(:,6).*STATES(:,4)).*STATES(:,1))+ (CONSTANTS(:,7)+ CONSTANTS(:,8).*STATES(:,5)).*STATES(:,6);
RATES(:,6) = ((( CONSTANTS(:,1).*STATES(:,7) -  CONSTANTS(:,2).*STATES(:,6)) -  (CONSTANTS(:,3)+ CONSTANTS(:,4).*STATES(:,3)).*STATES(:,6))+ (CONSTANTS(:,5)+ CONSTANTS(:,6).*STATES(:,4)).*STATES(:,1)) -  (CONSTANTS(:,5)+ CONSTANTS(:,8).*STATES(:,5)).*STATES(:,6);
RATES(:,2) = (((CONSTANTS(:,9) - ( CONSTANTS(:,11).*STATES(:,8).*( CONSTANTS(:,1).*STATES(:,2) -  CONSTANTS(:,2).*STATES(:,1)))./(1.00000 -  STATES(:,8).*CONSTANTS(:,11))) -  CONSTANTS(:,10).*STATES(:,2))+ (CONSTANTS(:,7)+ CONSTANTS(:,8).*STATES(:,9)).*STATES(:,7)) -  (CONSTANTS(:,5)+ CONSTANTS(:,6).*STATES(:,10)).*STATES(:,2);
RATES(:,7) = (((  - CONSTANTS(:,11).*STATES(:,8).*( CONSTANTS(:,1).*STATES(:,7) -  CONSTANTS(:,2).*STATES(:,6)))./(1.00000 -  STATES(:,8).*CONSTANTS(:,11)) -  CONSTANTS(:,10).*STATES(:,7)) -  (CONSTANTS(:,7)+ CONSTANTS(:,8).*STATES(:,9)).*STATES(:,7))+ (CONSTANTS(:,5)+ CONSTANTS(:,6).*STATES(:,10)).*STATES(:,2);
RATES(:,11) = ( CONSTANTS(:,14).*(1.00000 - STATES(:,11)).*STATES(:,1))./((CONSTANTS(:,12)+1.00000) - STATES(:,11)) - ( CONSTANTS(:,15).*STATES(:,11))./(CONSTANTS(:,13)+STATES(:,11));
RATES(:,3) = ( CONSTANTS(:,18).*STATES(:,11).*(1.00000 - STATES(:,3)))./((CONSTANTS(:,16)+1.00000) - STATES(:,3)) - ( CONSTANTS(:,19).*STATES(:,3))./(CONSTANTS(:,17)+STATES(:,3));
RATES(:,12) =   - (CONSTANTS(:,20)./(CONSTANTS(:,22)+STATES(:,12))+ CONSTANTS(:,21).*STATES(:,13)).*STATES(:,12);
RATES(:,14) =  CONSTANTS(:,23).*STATES(:,8);
RATES(:,13) =  CONSTANTS(:,24).*STATES(:,14);
RATES(:,5) = ((( CONSTANTS(:,25).*STATES(:,9) -  CONSTANTS(:,26).*STATES(:,5))+( (CONSTANTS(:,27)+ CONSTANTS(:,28).*STATES(:,1)).*STATES(:,15))./(CONSTANTS(:,31)+STATES(:,15))) - ( CONSTANTS(:,29).*STATES(:,5))./(CONSTANTS(:,32)+STATES(:,5))) -  CONSTANTS(:,30).*STATES(:,5);
RATES(:,15) = ((( CONSTANTS(:,25).*STATES(:,16) -  CONSTANTS(:,26).*STATES(:,15)) - ( (CONSTANTS(:,27)+ CONSTANTS(:,28).*STATES(:,1)).*STATES(:,15))./(CONSTANTS(:,31)+STATES(:,15)))+( CONSTANTS(:,29).*STATES(:,5))./(CONSTANTS(:,32)+STATES(:,5))) -  CONSTANTS(:,30).*STATES(:,15);
RATES(:,9) = ((  - CONSTANTS(:,30).*STATES(:,9) - ( CONSTANTS(:,11).*STATES(:,8).*( CONSTANTS(:,25).*STATES(:,9) -  CONSTANTS(:,26).*STATES(:,5)))./(1.00000 -  STATES(:,8).*CONSTANTS(:,11)))+( (CONSTANTS(:,27)+ CONSTANTS(:,28).*STATES(:,2)).*STATES(:,16))./(CONSTANTS(:,31)+STATES(:,16))) - ( CONSTANTS(:,29).*STATES(:,9))./(CONSTANTS(:,32)+STATES(:,9));
RATES(:,16) = ((( CONSTANTS(:,33).*STATES(:,12) -  CONSTANTS(:,30).*STATES(:,16)) - ( CONSTANTS(:,11).*STATES(:,8).*( CONSTANTS(:,25).*STATES(:,16) -  CONSTANTS(:,26).*STATES(:,15)))./(1.00000 -  STATES(:,8).*CONSTANTS(:,11))) - ( (CONSTANTS(:,27)+ CONSTANTS(:,28).*STATES(:,2)).*STATES(:,16))./(CONSTANTS(:,31)+STATES(:,16)))+( CONSTANTS(:,29).*STATES(:,9))./(CONSTANTS(:,32)+STATES(:,9));
RATES(:,4) = (( CONSTANTS(:,34).*STATES(:,10) -  CONSTANTS(:,35).*STATES(:,4))+( CONSTANTS(:,36).*STATES(:,17))./(CONSTANTS(:,39)+STATES(:,17))) - ( (CONSTANTS(:,37)+ CONSTANTS(:,38).*STATES(:,1)).*STATES(:,4))./(CONSTANTS(:,40)+STATES(:,4));
ALGEBRAIC(:,1) = (CONSTANTS(:,41) -  STATES(:,8).*CONSTANTS(:,11).*(STATES(:,4)+STATES(:,17)))./(1.00000 -  STATES(:,8).*CONSTANTS(:,11)) - STATES(:,10);
RATES(:,10) = ((  - ( CONSTANTS(:,34).*STATES(:,10) -  CONSTANTS(:,35).*STATES(:,4)).*STATES(:,8).*CONSTANTS(:,11))./(1.00000 -  STATES(:,8).*CONSTANTS(:,11))+( CONSTANTS(:,36).*ALGEBRAIC(:,1))./(CONSTANTS(:,39)+ALGEBRAIC(:,1))) - ( (CONSTANTS(:,37)+ CONSTANTS(:,38).*STATES(:,2)).*STATES(:,10))./(CONSTANTS(:,40)+STATES(:,10));
RATES(:,17) = (( CONSTANTS(:,34).*ALGEBRAIC(:,1) -  CONSTANTS(:,35).*STATES(:,17)) - ( CONSTANTS(:,36).*STATES(:,17))./(CONSTANTS(:,39)+STATES(:,17)))+( (CONSTANTS(:,37)+ CONSTANTS(:,38).*STATES(:,1)).*STATES(:,4))./(CONSTANTS(:,40)+STATES(:,4));
RATES = RATES';
end

% Calculate algebraic variables
function ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI)
statesSize = size(STATES);
statesColumnCount = statesSize(2);
if ( statesColumnCount == 1)
STATES = STATES';
utilOnes = 1;
else
statesRowCount = statesSize(1);
utilOnes = ones(statesRowCount, 1);
end
ALGEBRAIC(:,1) = (CONSTANTS(:,41) -  STATES(:,8).*CONSTANTS(:,11).*(STATES(:,4)+STATES(:,17)))./(1.00000 -  STATES(:,8).*CONSTANTS(:,11)) - STATES(:,10);
ALGEBRAIC(:,2) =  (1.00000 -  STATES(:,8).*CONSTANTS(:,11)).*(STATES(:,2)+STATES(:,7))+ STATES(:,8).*CONSTANTS(:,11).*(STATES(:,1)+STATES(:,6));
ALGEBRAIC(:,3) =  (1.00000 -  STATES(:,8).*CONSTANTS(:,11)).*(STATES(:,16)+STATES(:,9))+ STATES(:,8).*CONSTANTS(:,11).*(STATES(:,15)+STATES(:,5));
ALGEBRAIC(:,4) =  (1.00000 -  STATES(:,8).*CONSTANTS(:,11)).*STATES(:,9)+ STATES(:,8).*CONSTANTS(:,11).*STATES(:,5);
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 Calzone, Thieffry, Tyson, Novak, 2007 at changeset e6e9d2607d3f.
Collaboration
To begin collaborating on this work, please use your git client and issue this command: