# 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 =6;
end
% There are a total of 9 entries in each of the rate and state variable arrays.
% There are a total of 47 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('Cdc13T in component Cdc13T (dimensionless)');
LEGEND_CONSTANTS(:,1) = strpad('k1 in component Cdc13T (first_order_rate_constant)');
LEGEND_CONSTANTS(:,2) = strpad('k2_ in component kinetic_parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,3) = strpad('k2__ in component kinetic_parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,4) = strpad('k2___ in component kinetic_parameters (first_order_rate_constant)');
LEGEND_STATES(:,2) = strpad('M in component M (dimensionless)');
LEGEND_STATES(:,3) = strpad('Ste9 in component Ste9 (dimensionless)');
LEGEND_STATES(:,4) = strpad('Slp1 in component Slp1 (dimensionless)');
LEGEND_STATES(:,5) = strpad('preMPF in component preMPF (dimensionless)');
LEGEND_ALGEBRAIC(:,4) = strpad('kwee in component preMPF (first_order_rate_constant)');
LEGEND_CONSTANTS(:,5) = strpad('kwee_ in component preMPF (first_order_rate_constant)');
LEGEND_CONSTANTS(:,6) = strpad('kwee__ in component preMPF (first_order_rate_constant)');
LEGEND_CONSTANTS(:,7) = strpad('Vawee in component preMPF (first_order_rate_constant)');
LEGEND_CONSTANTS(:,8) = strpad('Viwee in component preMPF (first_order_rate_constant)');
LEGEND_CONSTANTS(:,9) = strpad('Jawee in component preMPF (dimensionless)');
LEGEND_CONSTANTS(:,10) = strpad('Jiwee in component preMPF (dimensionless)');
LEGEND_ALGEBRAIC(:,6) = strpad('k25 in component preMPF (first_order_rate_constant)');
LEGEND_CONSTANTS(:,11) = strpad('k25_ in component preMPF (first_order_rate_constant)');
LEGEND_CONSTANTS(:,12) = strpad('k25__ in component preMPF (first_order_rate_constant)');
LEGEND_CONSTANTS(:,13) = strpad('Va25 in component preMPF (first_order_rate_constant)');
LEGEND_CONSTANTS(:,14) = strpad('Vi25 in component preMPF (first_order_rate_constant)');
LEGEND_CONSTANTS(:,15) = strpad('Ja25 in component preMPF (dimensionless)');
LEGEND_CONSTANTS(:,16) = strpad('Ji25 in component preMPF (dimensionless)');
LEGEND_ALGEBRAIC(:,3) = strpad('MPF in component MPF (dimensionless)');
LEGEND_CONSTANTS(:,17) = strpad('k3_ in component Ste9 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,18) = strpad('k3__ in component Ste9 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,19) = strpad('k4 in component Ste9 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,20) = strpad('k4_ in component Ste9 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,21) = strpad('J3 in component Ste9 (dimensionless)');
LEGEND_CONSTANTS(:,22) = strpad('J4 in component Ste9 (dimensionless)');
LEGEND_STATES(:,6) = strpad('SK in component SK (dimensionless)');
LEGEND_STATES(:,7) = strpad('Slp1T in component Slp1T (dimensionless)');
LEGEND_CONSTANTS(:,23) = strpad('k5_ in component Slp1T (first_order_rate_constant)');
LEGEND_CONSTANTS(:,24) = strpad('k5__ in component Slp1T (first_order_rate_constant)');
LEGEND_CONSTANTS(:,25) = strpad('J5 in component Slp1T (dimensionless)');
LEGEND_CONSTANTS(:,26) = strpad('k6 in component kinetic_parameters (first_order_rate_constant)');
LEGEND_CONSTANTS(:,27) = strpad('k7 in component Slp1 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,28) = strpad('k8 in component Slp1 (first_order_rate_constant)');
LEGEND_CONSTANTS(:,29) = strpad('J7 in component Slp1 (dimensionless)');
LEGEND_CONSTANTS(:,30) = strpad('J8 in component Slp1 (dimensionless)');
LEGEND_STATES(:,8) = strpad('IEP in component IEP (dimensionless)');
LEGEND_CONSTANTS(:,31) = strpad('k9 in component IEP (first_order_rate_constant)');
LEGEND_CONSTANTS(:,32) = strpad('k10 in component IEP (first_order_rate_constant)');
LEGEND_CONSTANTS(:,33) = strpad('J9 in component IEP (dimensionless)');
LEGEND_CONSTANTS(:,34) = strpad('J10 in component IEP (dimensionless)');
LEGEND_STATES(:,9) = strpad('Rum1T in component Rum1T (dimensionless)');
LEGEND_CONSTANTS(:,35) = strpad('k11 in component Rum1T (first_order_rate_constant)');
LEGEND_CONSTANTS(:,36) = strpad('k12 in component Rum1T (first_order_rate_constant)');
LEGEND_CONSTANTS(:,37) = strpad('k12_ in component Rum1T (first_order_rate_constant)');
LEGEND_CONSTANTS(:,38) = strpad('k12__ in component Rum1T (first_order_rate_constant)');
LEGEND_CONSTANTS(:,39) = strpad('k13 in component SK (first_order_rate_constant)');
LEGEND_CONSTANTS(:,40) = strpad('k14 in component SK (first_order_rate_constant)');
LEGEND_ALGEBRAIC(:,5) = strpad('TF in component TF (dimensionless)');
LEGEND_CONSTANTS(:,41) = strpad('mu in component M (first_order_rate_constant)');
LEGEND_ALGEBRAIC(:,2) = strpad('Trimer in component Trimer (dimensionless)');
LEGEND_ALGEBRAIC(:,1) = strpad('sum in component Trimer (dimensionless)');
LEGEND_CONSTANTS(:,42) = strpad('Kdiss in component Trimer (dimensionless)');
LEGEND_CONSTANTS(:,43) = strpad('k15 in component TF (first_order_rate_constant)');
LEGEND_CONSTANTS(:,44) = strpad('k16_ in component TF (first_order_rate_constant)');
LEGEND_CONSTANTS(:,45) = strpad('k16__ in component TF (first_order_rate_constant)');
LEGEND_CONSTANTS(:,46) = strpad('J15 in component TF (dimensionless)');
LEGEND_CONSTANTS(:,47) = strpad('J16 in component TF (dimensionless)');
LEGEND_RATES(:,1) = strpad('d/dt Cdc13T in component Cdc13T (dimensionless)');
LEGEND_RATES(:,5) = strpad('d/dt preMPF in component preMPF (dimensionless)');
LEGEND_RATES(:,3) = strpad('d/dt Ste9 in component Ste9 (dimensionless)');
LEGEND_RATES(:,7) = strpad('d/dt Slp1T in component Slp1T (dimensionless)');
LEGEND_RATES(:,4) = strpad('d/dt Slp1 in component Slp1 (dimensionless)');
LEGEND_RATES(:,8) = strpad('d/dt IEP in component IEP (dimensionless)');
LEGEND_RATES(:,9) = strpad('d/dt Rum1T in component Rum1T (dimensionless)');
LEGEND_RATES(:,6) = strpad('d/dt SK in component SK (dimensionless)');
LEGEND_RATES(:,2) = strpad('d/dt M in component M (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.2;
CONSTANTS(:,1) = 0.03;
CONSTANTS(:,2) = 0.03;
CONSTANTS(:,3) = 1;
CONSTANTS(:,4) = 0.1;
STATES(:,2) = 1;
STATES(:,3) = 1;
STATES(:,4) = 2.2;
STATES(:,5) = 0;
CONSTANTS(:,5) = 0.15;
CONSTANTS(:,6) = 1.3;
CONSTANTS(:,7) = 0.25;
CONSTANTS(:,8) = 1;
CONSTANTS(:,9) = 0.01;
CONSTANTS(:,10) = 0.01;
CONSTANTS(:,11) = 0.05;
CONSTANTS(:,12) = 5;
CONSTANTS(:,13) = 1;
CONSTANTS(:,14) = 0.25;
CONSTANTS(:,15) = 0.01;
CONSTANTS(:,16) = 0.01;
CONSTANTS(:,17) = 1;
CONSTANTS(:,18) = 10;
CONSTANTS(:,19) = 35;
CONSTANTS(:,20) = 2;
CONSTANTS(:,21) = 0.01;
CONSTANTS(:,22) = 0.01;
STATES(:,6) = 0;
STATES(:,7) = 0;
CONSTANTS(:,23) = 0.005;
CONSTANTS(:,24) = 0.3;
CONSTANTS(:,25) = 0.3;
CONSTANTS(:,26) = 0.1;
CONSTANTS(:,27) = 1;
CONSTANTS(:,28) = 0.25;
CONSTANTS(:,29) = 0.001;
CONSTANTS(:,30) = 0.001;
STATES(:,8) = 0;
CONSTANTS(:,31) = 0.1;
CONSTANTS(:,32) = 0.04;
CONSTANTS(:,33) = 0.01;
CONSTANTS(:,34) = 0.01;
STATES(:,9) = 0;
CONSTANTS(:,35) = 0.1;
CONSTANTS(:,36) = 0.01;
CONSTANTS(:,37) = 1;
CONSTANTS(:,38) = 3;
CONSTANTS(:,39) = 0.1;
CONSTANTS(:,40) = 0.1;
CONSTANTS(:,41) = 0.005;
CONSTANTS(:,42) = 0.001;
CONSTANTS(:,43) = 1.5;
CONSTANTS(:,44) = 1;
CONSTANTS(:,45) = 2;
CONSTANTS(:,46) = 0.01;
CONSTANTS(:,47) = 0.01;
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(:,1) =  CONSTANTS(:,1).*STATES(:,2) -  (CONSTANTS(:,2)+ CONSTANTS(:,3).*STATES(:,3)+ CONSTANTS(:,4).*STATES(:,4)).*STATES(:,1);
RATES(:,4) = ( CONSTANTS(:,27).*STATES(:,8).*(STATES(:,7) - STATES(:,4)))./((CONSTANTS(:,29)+STATES(:,7)) - STATES(:,4)) - (( CONSTANTS(:,28).*STATES(:,4))./(CONSTANTS(:,30)+STATES(:,4))+ CONSTANTS(:,26).*STATES(:,4));
RATES(:,2) =  CONSTANTS(:,41).*STATES(:,2);
ALGEBRAIC(:,1) = STATES(:,1)+STATES(:,9)+CONSTANTS(:,42);
ALGEBRAIC(:,2) = ( 2.00000.*STATES(:,1).*STATES(:,9))./(ALGEBRAIC(:,1)+power((power(ALGEBRAIC(:,1), 2.00000) -  4.00000.*STATES(:,1).*STATES(:,9)), 1.0 ./ 2));
ALGEBRAIC(:,3) = ( (STATES(:,1) - STATES(:,5)).*(STATES(:,1) - ALGEBRAIC(:,2)))./STATES(:,1);
RATES(:,3) = ( (CONSTANTS(:,17)+ CONSTANTS(:,18).*STATES(:,4)).*(1.00000 - STATES(:,3)))./((CONSTANTS(:,21)+1.00000) - STATES(:,3)) - ( ( CONSTANTS(:,20).*STATES(:,6)+ CONSTANTS(:,19).*ALGEBRAIC(:,3)).*STATES(:,3))./(CONSTANTS(:,22)+STATES(:,3));
RATES(:,7) = (CONSTANTS(:,23)+( CONSTANTS(:,24).*power(ALGEBRAIC(:,3), 4.00000))./(power(CONSTANTS(:,25), 4.00000)+power(ALGEBRAIC(:,3), 4.00000))) -  CONSTANTS(:,26).*STATES(:,7);
RATES(:,8) = ( CONSTANTS(:,31).*ALGEBRAIC(:,3).*(1.00000 - STATES(:,8)))./((CONSTANTS(:,33)+1.00000) - STATES(:,8)) - ( CONSTANTS(:,32).*STATES(:,8))./(CONSTANTS(:,34)+STATES(:,8));
RATES(:,9) = CONSTANTS(:,35) -  (CONSTANTS(:,36)+ CONSTANTS(:,37).*STATES(:,6)+ CONSTANTS(:,38).*ALGEBRAIC(:,3)).*STATES(:,9);
ALGEBRAIC(:,5) = ( 2.00000.*CONSTANTS(:,43).*STATES(:,2).*CONSTANTS(:,47))./(((CONSTANTS(:,44)+ CONSTANTS(:,45).*ALGEBRAIC(:,3)) -  CONSTANTS(:,43).*STATES(:,2))+ (CONSTANTS(:,44)+ CONSTANTS(:,45).*ALGEBRAIC(:,3)).*CONSTANTS(:,46)+ CONSTANTS(:,43).*STATES(:,2).*CONSTANTS(:,47)+power((power(((CONSTANTS(:,44)+ CONSTANTS(:,45).*ALGEBRAIC(:,3)) -  CONSTANTS(:,43).*STATES(:,2))+ (CONSTANTS(:,44)+ CONSTANTS(:,45).*ALGEBRAIC(:,3)).*CONSTANTS(:,46)+ CONSTANTS(:,43).*STATES(:,2).*CONSTANTS(:,47), 2.00000) -  4.00000.*CONSTANTS(:,43).*STATES(:,2).*CONSTANTS(:,47).*((CONSTANTS(:,44)+ CONSTANTS(:,45).*ALGEBRAIC(:,3)) -  CONSTANTS(:,43).*STATES(:,2))), 1.0 ./ 2));
RATES(:,6) =  CONSTANTS(:,39).*ALGEBRAIC(:,5) -  CONSTANTS(:,40).*STATES(:,6);
ALGEBRAIC(:,4) = CONSTANTS(:,5)+( (CONSTANTS(:,6) - CONSTANTS(:,5)).*2.00000.*CONSTANTS(:,7).*CONSTANTS(:,10))./(( CONSTANTS(:,8).*ALGEBRAIC(:,3) - CONSTANTS(:,7))+ CONSTANTS(:,8).*ALGEBRAIC(:,3).*CONSTANTS(:,9)+ CONSTANTS(:,7).*CONSTANTS(:,10)+power((power(( CONSTANTS(:,8).*ALGEBRAIC(:,3) - CONSTANTS(:,7))+ CONSTANTS(:,8).*ALGEBRAIC(:,3).*CONSTANTS(:,9)+ CONSTANTS(:,7).*CONSTANTS(:,10), 2.00000) -  4.00000.*CONSTANTS(:,7).*CONSTANTS(:,10).*( CONSTANTS(:,8).*ALGEBRAIC(:,3) - CONSTANTS(:,7))), 1.0 ./ 2));
ALGEBRAIC(:,6) = CONSTANTS(:,11)+( (CONSTANTS(:,12) - CONSTANTS(:,11)).*2.00000.*CONSTANTS(:,13).*ALGEBRAIC(:,3).*CONSTANTS(:,16))./((CONSTANTS(:,14) -  CONSTANTS(:,13).*ALGEBRAIC(:,3))+ CONSTANTS(:,14).*CONSTANTS(:,15)+ CONSTANTS(:,13).*ALGEBRAIC(:,3).*CONSTANTS(:,16)+power((power((CONSTANTS(:,14) -  CONSTANTS(:,13).*ALGEBRAIC(:,3))+ CONSTANTS(:,14).*CONSTANTS(:,15)+ CONSTANTS(:,13).*ALGEBRAIC(:,3).*CONSTANTS(:,16), 2.00000) -  4.00000.*CONSTANTS(:,13).*ALGEBRAIC(:,3).*CONSTANTS(:,16).*(CONSTANTS(:,14) -  CONSTANTS(:,13).*ALGEBRAIC(:,3))), 1.0 ./ 2));
RATES(:,5) = ( ALGEBRAIC(:,4).*(STATES(:,1) - STATES(:,5)) -  ALGEBRAIC(:,6).*STATES(:,5)) -  (CONSTANTS(:,2)+ CONSTANTS(:,3).*STATES(:,3)+ CONSTANTS(:,4).*STATES(:,4)).*STATES(:,5);
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) = STATES(:,1)+STATES(:,9)+CONSTANTS(:,42);
ALGEBRAIC(:,2) = ( 2.00000.*STATES(:,1).*STATES(:,9))./(ALGEBRAIC(:,1)+power((power(ALGEBRAIC(:,1), 2.00000) -  4.00000.*STATES(:,1).*STATES(:,9)), 1.0 ./ 2));
ALGEBRAIC(:,3) = ( (STATES(:,1) - STATES(:,5)).*(STATES(:,1) - ALGEBRAIC(:,2)))./STATES(:,1);
ALGEBRAIC(:,5) = ( 2.00000.*CONSTANTS(:,43).*STATES(:,2).*CONSTANTS(:,47))./(((CONSTANTS(:,44)+ CONSTANTS(:,45).*ALGEBRAIC(:,3)) -  CONSTANTS(:,43).*STATES(:,2))+ (CONSTANTS(:,44)+ CONSTANTS(:,45).*ALGEBRAIC(:,3)).*CONSTANTS(:,46)+ CONSTANTS(:,43).*STATES(:,2).*CONSTANTS(:,47)+power((power(((CONSTANTS(:,44)+ CONSTANTS(:,45).*ALGEBRAIC(:,3)) -  CONSTANTS(:,43).*STATES(:,2))+ (CONSTANTS(:,44)+ CONSTANTS(:,45).*ALGEBRAIC(:,3)).*CONSTANTS(:,46)+ CONSTANTS(:,43).*STATES(:,2).*CONSTANTS(:,47), 2.00000) -  4.00000.*CONSTANTS(:,43).*STATES(:,2).*CONSTANTS(:,47).*((CONSTANTS(:,44)+ CONSTANTS(:,45).*ALGEBRAIC(:,3)) -  CONSTANTS(:,43).*STATES(:,2))), 1.0 ./ 2));
ALGEBRAIC(:,4) = CONSTANTS(:,5)+( (CONSTANTS(:,6) - CONSTANTS(:,5)).*2.00000.*CONSTANTS(:,7).*CONSTANTS(:,10))./(( CONSTANTS(:,8).*ALGEBRAIC(:,3) - CONSTANTS(:,7))+ CONSTANTS(:,8).*ALGEBRAIC(:,3).*CONSTANTS(:,9)+ CONSTANTS(:,7).*CONSTANTS(:,10)+power((power(( CONSTANTS(:,8).*ALGEBRAIC(:,3) - CONSTANTS(:,7))+ CONSTANTS(:,8).*ALGEBRAIC(:,3).*CONSTANTS(:,9)+ CONSTANTS(:,7).*CONSTANTS(:,10), 2.00000) -  4.00000.*CONSTANTS(:,7).*CONSTANTS(:,10).*( CONSTANTS(:,8).*ALGEBRAIC(:,3) - CONSTANTS(:,7))), 1.0 ./ 2));
ALGEBRAIC(:,6) = CONSTANTS(:,11)+( (CONSTANTS(:,12) - CONSTANTS(:,11)).*2.00000.*CONSTANTS(:,13).*ALGEBRAIC(:,3).*CONSTANTS(:,16))./((CONSTANTS(:,14) -  CONSTANTS(:,13).*ALGEBRAIC(:,3))+ CONSTANTS(:,14).*CONSTANTS(:,15)+ CONSTANTS(:,13).*ALGEBRAIC(:,3).*CONSTANTS(:,16)+power((power((CONSTANTS(:,14) -  CONSTANTS(:,13).*ALGEBRAIC(:,3))+ CONSTANTS(:,14).*CONSTANTS(:,15)+ CONSTANTS(:,13).*ALGEBRAIC(:,3).*CONSTANTS(:,16), 2.00000) -  4.00000.*CONSTANTS(:,13).*ALGEBRAIC(:,3).*CONSTANTS(:,16).*(CONSTANTS(:,14) -  CONSTANTS(:,13).*ALGEBRAIC(:,3))), 1.0 ./ 2));
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, Pataki, Ciliberto, Tyson, 2001 at changeset 8dce5c2f9133.
Collaboration
To begin collaborating on this work, please use your git client and issue this command: