# 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 =33;
end
% There are a total of 7 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 (ms)');
LEGEND_ALGEBRAIC(:,16) = strpad('Jpdh in component J_variables (uM_per_ms)');
LEGEND_ALGEBRAIC(:,9) = strpad('Jo in component J_variables (uM_per_ms)');
LEGEND_CONSTANTS(:,1) = strpad('gamma in component Mitochondrial_variables (dimensionless)');
LEGEND_STATES(:,3) = strpad('PSIm in component Mitochondrial_variables (mV)');
LEGEND_STATES(:,4) = strpad('Cam in component Mitochondrial_variables (uM)');
LEGEND_CONSTANTS(:,3) = strpad('fm in component Mitochondrial_variables (dimensionless)');
LEGEND_CONSTANTS(:,4) = strpad('Cmito in component Mitochondrial_variables (uM_per_mV)');
LEGEND_CONSTANTS(:,5) = strpad('Amtot in component Mitochondrial_variables (mM)');
LEGEND_ALGEBRAIC(:,2) = strpad('ATPm in component Mitochondrial_variables (mM)');
LEGEND_ALGEBRAIC(:,6) = strpad('RATm in component Mitochondrial_variables (dimensionless)');
LEGEND_ALGEBRAIC(:,33) = strpad('Jant in component J_variables (uM_per_ms)');
LEGEND_ALGEBRAIC(:,32) = strpad('Jf1f0 in component J_variables (uM_per_ms)');
LEGEND_ALGEBRAIC(:,26) = strpad('Jh_res in component J_variables (uM_per_ms)');
LEGEND_ALGEBRAIC(:,30) = strpad('Jh_atp in component J_variables (uM_per_ms)');
LEGEND_ALGEBRAIC(:,21) = strpad('Jh_leak in component J_variables (uM_per_ms)');
LEGEND_ALGEBRAIC(:,19) = strpad('Jnaca in component J_variables (uM_per_ms)');
LEGEND_ALGEBRAIC(:,17) = strpad('Juni in component J_variables (uM_per_ms)');
LEGEND_ALGEBRAIC(:,22) = strpad('Jmito in component J_variables (uM_per_ms)');
LEGEND_STATES(:,5) = strpad('c in component Clamp_protocol (uM)');
LEGEND_ALGEBRAIC(:,10) = strpad('ATPc in component Cytosol (mM)');
LEGEND_CONSTANTS(:,6) = strpad('Ac_tot in component Cytosol (uM)');
LEGEND_CONSTANTS(:,7) = strpad('khyd in component Cytosol (dimensionless)');
LEGEND_CONSTANTS(:,8) = strpad('Jhydbas in component Cytosol (mM)');
LEGEND_ALGEBRAIC(:,14) = strpad('Jh_yd in component Cytosol (mM)');
LEGEND_CONSTANTS(:,47) = strpad('delta in component Cytosol (dimensionless)');
LEGEND_ALGEBRAIC(:,11) = strpad('Fproto in component Clamp_parameters (uM)');
LEGEND_ALGEBRAIC(:,29) = strpad('Cproto in component Clamp_parameters (uM)');
LEGEND_STATES(:,7) = strpad('FBP in component Clamp_protocol (uM)');
LEGEND_CONSTANTS(:,9) = strpad('Fhold in component Clamp_parameters (uM)');
LEGEND_CONSTANTS(:,10) = strpad('Ftest in component Clamp_parameters (uM)');
LEGEND_CONSTANTS(:,11) = strpad('Fton in component Clamp_parameters (ms)');
LEGEND_CONSTANTS(:,12) = strpad('Ftoff in component Clamp_parameters (ms)');
LEGEND_CONSTANTS(:,13) = strpad('Chold in component Clamp_parameters (uM)');
LEGEND_CONSTANTS(:,14) = strpad('Ctest in component Clamp_parameters (uM)');
LEGEND_CONSTANTS(:,15) = strpad('Cton1 in component Clamp_parameters (ms)');
LEGEND_CONSTANTS(:,16) = strpad('Cton2 in component Clamp_parameters (ms)');
LEGEND_CONSTANTS(:,17) = strpad('Cton3 in component Clamp_parameters (ms)');
LEGEND_CONSTANTS(:,18) = strpad('Ctoff1 in component Clamp_parameters (ms)');
LEGEND_CONSTANTS(:,19) = strpad('Ctoff2 in component Clamp_parameters (ms)');
LEGEND_CONSTANTS(:,20) = strpad('Ctoff3 in component Clamp_parameters (ms)');
LEGEND_ALGEBRAIC(:,18) = strpad('pulse1 in component Clamp_parameters (uM)');
LEGEND_ALGEBRAIC(:,23) = strpad('pulse2 in component Clamp_parameters (uM)');
LEGEND_ALGEBRAIC(:,27) = strpad('pulse3 in component Clamp_parameters (uM)');
LEGEND_ALGEBRAIC(:,3) = strpad('heav_on in component Clamp_parameters (dimensionless)');
LEGEND_ALGEBRAIC(:,7) = strpad('heav_off in component Clamp_parameters (dimensionless)');
LEGEND_ALGEBRAIC(:,4) = strpad('heav_Cton1 in component Clamp_parameters (dimensionless)');
LEGEND_ALGEBRAIC(:,8) = strpad('heav_Cton2 in component Clamp_parameters (dimensionless)');
LEGEND_ALGEBRAIC(:,12) = strpad('heav_Cton3 in component Clamp_parameters (dimensionless)');
LEGEND_ALGEBRAIC(:,15) = strpad('heav_Ctoff1 in component Clamp_parameters (dimensionless)');
LEGEND_ALGEBRAIC(:,20) = strpad('heav_Ctoff2 in component Clamp_parameters (dimensionless)');
LEGEND_ALGEBRAIC(:,25) = strpad('heav_Ctoff3 in component Clamp_parameters (dimensionless)');
LEGEND_ALGEBRAIC(:,13) = strpad('Jgpdh in component J_variables (uM_per_ms)');
LEGEND_CONSTANTS(:,21) = strpad('p1 in component Parameters (dimensionless)');
LEGEND_CONSTANTS(:,22) = strpad('p2 in component Parameters (dimensionless)');
LEGEND_CONSTANTS(:,23) = strpad('p3 in component Parameters (uM)');
LEGEND_CONSTANTS(:,24) = strpad('p21 in component Parameters (per_uM_per_ms_per_mV)');
LEGEND_CONSTANTS(:,25) = strpad('p22 in component Parameters (per_uM_per_ms)');
LEGEND_CONSTANTS(:,26) = strpad('p23 in component Parameters (uM_per_ms)');
LEGEND_CONSTANTS(:,27) = strpad('p24 in component Parameters (per_mV)');
LEGEND_CONSTANTS(:,28) = strpad('p4 in component Parameters (uM_per_ms)');
LEGEND_CONSTANTS(:,29) = strpad('p5 in component Parameters (mM)');
LEGEND_CONSTANTS(:,30) = strpad('p6 in component Parameters (mV)');
LEGEND_CONSTANTS(:,31) = strpad('p7 in component Parameters (mV)');
LEGEND_CONSTANTS(:,32) = strpad('p8 in component Parameters (uM_per_ms)');
LEGEND_CONSTANTS(:,33) = strpad('p9 in component Parameters (mM)');
LEGEND_CONSTANTS(:,34) = strpad('p10 in component Parameters (mV)');
LEGEND_CONSTANTS(:,35) = strpad('p11 in component Parameters (mV)');
LEGEND_CONSTANTS(:,36) = strpad('p12 in component Parameters (uM_per_ms)');
LEGEND_CONSTANTS(:,37) = strpad('p13 in component Parameters (mM)');
LEGEND_CONSTANTS(:,38) = strpad('p14 in component Parameters (mV)');
LEGEND_CONSTANTS(:,39) = strpad('p15 in component Parameters (mV)');
LEGEND_CONSTANTS(:,40) = strpad('p16 in component Parameters (uM_per_ms)');
LEGEND_CONSTANTS(:,41) = strpad('p17 in component Parameters (uM_per_ms_per_mV)');
LEGEND_CONSTANTS(:,42) = strpad('p18 in component Parameters (uM_per_ms)');
LEGEND_CONSTANTS(:,43) = strpad('p19 in component Parameters (uM_per_ms)');
LEGEND_CONSTANTS(:,44) = strpad('p20 in component Parameters (dimensionless)');
LEGEND_ALGEBRAIC(:,5) = strpad('MM1 in component J_variables (uM_per_ms)');
LEGEND_ALGEBRAIC(:,24) = strpad('MM2 in component J_variables (uM_per_ms)');
LEGEND_ALGEBRAIC(:,28) = strpad('b13 in component J_variables (uM_per_ms)');
LEGEND_ALGEBRAIC(:,31) = strpad('b2 in component J_variables (uM_per_ms)');
LEGEND_CONSTANTS(:,45) = strpad('FRT in component J_variables (per_mV)');
LEGEND_CONSTANTS(:,46) = strpad('kgpdh in component J_variables (uM_per_ms)');
LEGEND_RATES(:,3) = strpad('d/dt PSIm in component Mitochondrial_variables (mV)');
LEGEND_RATES(:,4) = strpad('d/dt Cam in component Mitochondrial_variables (uM)');
LEGEND_RATES(:,7) = strpad('d/dt FBP in component Clamp_protocol (uM)');
LEGEND_RATES(:,5) = strpad('d/dt c in component Clamp_protocol (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 = [];
STATES(:,1) = 0.6;
CONSTANTS(:,1) = 0.001;
STATES(:,2) = 7.4;
STATES(:,3) = 93;
STATES(:,4) = 0.1;
CONSTANTS(:,2) = 10;
CONSTANTS(:,3) = 0.01;
CONSTANTS(:,4) = 1.8;
CONSTANTS(:,5) = 15;
STATES(:,5) = 0.1;
STATES(:,6) = 1850;
CONSTANTS(:,6) = 2500;
CONSTANTS(:,7) = 0.00005;
CONSTANTS(:,8) = 0.00005;
STATES(:,7) = 0.5;
CONSTANTS(:,9) = 1;
CONSTANTS(:,10) = 5;
CONSTANTS(:,11) = 90000;
CONSTANTS(:,12) = 330000;
CONSTANTS(:,13) = 0.1;
CONSTANTS(:,14) = 0.1;
CONSTANTS(:,15) = 120000;
CONSTANTS(:,16) = 180000;
CONSTANTS(:,17) = 240000;
CONSTANTS(:,18) = 150000;
CONSTANTS(:,19) = 210000;
CONSTANTS(:,20) = 270000;
CONSTANTS(:,21) = 400;
CONSTANTS(:,22) = 1;
CONSTANTS(:,23) = 0.01;
CONSTANTS(:,24) = 0.01;
CONSTANTS(:,25) = 1.1;
CONSTANTS(:,26) = 0.001;
CONSTANTS(:,27) = 0.016;
CONSTANTS(:,28) = 0.6;
CONSTANTS(:,29) = 0.1;
CONSTANTS(:,30) = 177;
CONSTANTS(:,31) = 5;
CONSTANTS(:,32) = 7;
CONSTANTS(:,33) = 0.1;
CONSTANTS(:,34) = 177;
CONSTANTS(:,35) = 5;
CONSTANTS(:,36) = 120;
CONSTANTS(:,37) = 10;
CONSTANTS(:,38) = 190;
CONSTANTS(:,39) = 8.5;
CONSTANTS(:,40) = 35;
CONSTANTS(:,41) = 0.002;
CONSTANTS(:,42) = -0.03;
CONSTANTS(:,43) = 0.35;
CONSTANTS(:,44) = 2;
CONSTANTS(:,45) = 0.037;
CONSTANTS(:,46) = 0.0005;
CONSTANTS(:,47) = 3.90000./53.2000;
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
ALGEBRAIC(:,3) = piecewise({VOI - CONSTANTS(:,11)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,7) = piecewise({VOI - CONSTANTS(:,12)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,11) = CONSTANTS(:,9)+ (CONSTANTS(:,10) - CONSTANTS(:,9)).*(ALGEBRAIC(:,3) - ALGEBRAIC(:,7));
RATES(:,7) = (ALGEBRAIC(:,11) - STATES(:,7))./0.100000;
ALGEBRAIC(:,1) = CONSTANTS(:,2) - STATES(:,1);
ALGEBRAIC(:,13) =  CONSTANTS(:,46).*power((STATES(:,7)./1.00000), 1.0 ./ 2);
ALGEBRAIC(:,16) =  (CONSTANTS(:,21)./(CONSTANTS(:,22)+STATES(:,1)./ALGEBRAIC(:,1))).*(STATES(:,4)./(CONSTANTS(:,23)+STATES(:,4))).*ALGEBRAIC(:,13);
ALGEBRAIC(:,5) = ( CONSTANTS(:,28).*STATES(:,1))./(CONSTANTS(:,29)+STATES(:,1));
ALGEBRAIC(:,9) = ALGEBRAIC(:,5)./(1.00000+exp((STATES(:,3) - CONSTANTS(:,30))./CONSTANTS(:,31)));
RATES(:,1) =  CONSTANTS(:,1).*(ALGEBRAIC(:,16) - ALGEBRAIC(:,9));
ALGEBRAIC(:,19) =  (( CONSTANTS(:,26).*STATES(:,4))./STATES(:,5)).*exp( CONSTANTS(:,27).*STATES(:,3));
ALGEBRAIC(:,17) =  ( CONSTANTS(:,24).*STATES(:,3) - CONSTANTS(:,25)).*power(STATES(:,5), 2.00000);
ALGEBRAIC(:,22) = ALGEBRAIC(:,19) - ALGEBRAIC(:,17);
RATES(:,4) =   - CONSTANTS(:,3).*ALGEBRAIC(:,22);
ALGEBRAIC(:,4) = piecewise({VOI - CONSTANTS(:,15)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,15) = piecewise({VOI - CONSTANTS(:,18)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,18) =  (CONSTANTS(:,14) - CONSTANTS(:,13)).*(ALGEBRAIC(:,4) - ALGEBRAIC(:,15));
ALGEBRAIC(:,8) = piecewise({VOI - CONSTANTS(:,16)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,20) = piecewise({VOI - CONSTANTS(:,19)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,23) =  (CONSTANTS(:,14) - CONSTANTS(:,13)).*(ALGEBRAIC(:,8) - ALGEBRAIC(:,20));
ALGEBRAIC(:,12) = piecewise({VOI - CONSTANTS(:,17)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,25) = piecewise({VOI - CONSTANTS(:,20)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,27) =  (CONSTANTS(:,14) - CONSTANTS(:,13)).*(ALGEBRAIC(:,12) - ALGEBRAIC(:,25));
ALGEBRAIC(:,29) = CONSTANTS(:,13)+ALGEBRAIC(:,18)+ALGEBRAIC(:,23)+ALGEBRAIC(:,27);
RATES(:,5) = (ALGEBRAIC(:,29) - STATES(:,5))./0.100000;
ALGEBRAIC(:,2) = CONSTANTS(:,5) - STATES(:,2);
ALGEBRAIC(:,6) = ALGEBRAIC(:,2)./STATES(:,2);
ALGEBRAIC(:,33) = (( CONSTANTS(:,43).*ALGEBRAIC(:,6))./(ALGEBRAIC(:,6)+CONSTANTS(:,44)))./exp(  - 0.500000.*CONSTANTS(:,45).*STATES(:,3));
ALGEBRAIC(:,31) = ( CONSTANTS(:,40).*CONSTANTS(:,37))./(CONSTANTS(:,37)+ALGEBRAIC(:,2));
ALGEBRAIC(:,32) = ALGEBRAIC(:,31)./(1.00000+exp((CONSTANTS(:,38) - STATES(:,3))./CONSTANTS(:,39)));
RATES(:,2) =  CONSTANTS(:,1).*(ALGEBRAIC(:,33) - ALGEBRAIC(:,32));
ALGEBRAIC(:,24) = ( CONSTANTS(:,32).*STATES(:,1))./(CONSTANTS(:,33)+STATES(:,1));
ALGEBRAIC(:,26) = ALGEBRAIC(:,24)./(1.00000+exp((STATES(:,3) - CONSTANTS(:,34))./CONSTANTS(:,35)));
ALGEBRAIC(:,28) = ( CONSTANTS(:,36).*CONSTANTS(:,37))./(CONSTANTS(:,37)+ALGEBRAIC(:,2));
ALGEBRAIC(:,30) = ALGEBRAIC(:,28)./(1.00000+exp((CONSTANTS(:,38) - STATES(:,3))./CONSTANTS(:,39)));
ALGEBRAIC(:,21) =  CONSTANTS(:,41).*STATES(:,3)+CONSTANTS(:,42);
RATES(:,3) = (((((ALGEBRAIC(:,26) - ALGEBRAIC(:,30)) - ALGEBRAIC(:,33)) - ALGEBRAIC(:,21)) - ALGEBRAIC(:,19)) -  ALGEBRAIC(:,17).*2.00000)./CONSTANTS(:,4);
ALGEBRAIC(:,10) = CONSTANTS(:,6) - STATES(:,6);
ALGEBRAIC(:,14) = ( ( CONSTANTS(:,7).*STATES(:,5)+CONSTANTS(:,8)).*ALGEBRAIC(:,10))./1.00000;
RATES(:,6) =   - CONSTANTS(:,47).*ALGEBRAIC(:,33)+ ALGEBRAIC(:,14).*1.00000;
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(:,3) = piecewise({VOI - CONSTANTS(:,11)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,7) = piecewise({VOI - CONSTANTS(:,12)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,11) = CONSTANTS(:,9)+ (CONSTANTS(:,10) - CONSTANTS(:,9)).*(ALGEBRAIC(:,3) - ALGEBRAIC(:,7));
ALGEBRAIC(:,1) = CONSTANTS(:,2) - STATES(:,1);
ALGEBRAIC(:,13) =  CONSTANTS(:,46).*power((STATES(:,7)./1.00000), 1.0 ./ 2);
ALGEBRAIC(:,16) =  (CONSTANTS(:,21)./(CONSTANTS(:,22)+STATES(:,1)./ALGEBRAIC(:,1))).*(STATES(:,4)./(CONSTANTS(:,23)+STATES(:,4))).*ALGEBRAIC(:,13);
ALGEBRAIC(:,5) = ( CONSTANTS(:,28).*STATES(:,1))./(CONSTANTS(:,29)+STATES(:,1));
ALGEBRAIC(:,9) = ALGEBRAIC(:,5)./(1.00000+exp((STATES(:,3) - CONSTANTS(:,30))./CONSTANTS(:,31)));
ALGEBRAIC(:,19) =  (( CONSTANTS(:,26).*STATES(:,4))./STATES(:,5)).*exp( CONSTANTS(:,27).*STATES(:,3));
ALGEBRAIC(:,17) =  ( CONSTANTS(:,24).*STATES(:,3) - CONSTANTS(:,25)).*power(STATES(:,5), 2.00000);
ALGEBRAIC(:,22) = ALGEBRAIC(:,19) - ALGEBRAIC(:,17);
ALGEBRAIC(:,4) = piecewise({VOI - CONSTANTS(:,15)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,15) = piecewise({VOI - CONSTANTS(:,18)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,18) =  (CONSTANTS(:,14) - CONSTANTS(:,13)).*(ALGEBRAIC(:,4) - ALGEBRAIC(:,15));
ALGEBRAIC(:,8) = piecewise({VOI - CONSTANTS(:,16)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,20) = piecewise({VOI - CONSTANTS(:,19)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,23) =  (CONSTANTS(:,14) - CONSTANTS(:,13)).*(ALGEBRAIC(:,8) - ALGEBRAIC(:,20));
ALGEBRAIC(:,12) = piecewise({VOI - CONSTANTS(:,17)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,25) = piecewise({VOI - CONSTANTS(:,20)>=0.00000, 1.00000 }, 0.00000);
ALGEBRAIC(:,27) =  (CONSTANTS(:,14) - CONSTANTS(:,13)).*(ALGEBRAIC(:,12) - ALGEBRAIC(:,25));
ALGEBRAIC(:,29) = CONSTANTS(:,13)+ALGEBRAIC(:,18)+ALGEBRAIC(:,23)+ALGEBRAIC(:,27);
ALGEBRAIC(:,2) = CONSTANTS(:,5) - STATES(:,2);
ALGEBRAIC(:,6) = ALGEBRAIC(:,2)./STATES(:,2);
ALGEBRAIC(:,33) = (( CONSTANTS(:,43).*ALGEBRAIC(:,6))./(ALGEBRAIC(:,6)+CONSTANTS(:,44)))./exp(  - 0.500000.*CONSTANTS(:,45).*STATES(:,3));
ALGEBRAIC(:,31) = ( CONSTANTS(:,40).*CONSTANTS(:,37))./(CONSTANTS(:,37)+ALGEBRAIC(:,2));
ALGEBRAIC(:,32) = ALGEBRAIC(:,31)./(1.00000+exp((CONSTANTS(:,38) - STATES(:,3))./CONSTANTS(:,39)));
ALGEBRAIC(:,24) = ( CONSTANTS(:,32).*STATES(:,1))./(CONSTANTS(:,33)+STATES(:,1));
ALGEBRAIC(:,26) = ALGEBRAIC(:,24)./(1.00000+exp((STATES(:,3) - CONSTANTS(:,34))./CONSTANTS(:,35)));
ALGEBRAIC(:,28) = ( CONSTANTS(:,36).*CONSTANTS(:,37))./(CONSTANTS(:,37)+ALGEBRAIC(:,2));
ALGEBRAIC(:,30) = ALGEBRAIC(:,28)./(1.00000+exp((CONSTANTS(:,38) - STATES(:,3))./CONSTANTS(:,39)));
ALGEBRAIC(:,21) =  CONSTANTS(:,41).*STATES(:,3)+CONSTANTS(:,42);
ALGEBRAIC(:,10) = CONSTANTS(:,6) - STATES(:,6);
ALGEBRAIC(:,14) = ( ( CONSTANTS(:,7).*STATES(:,5)+CONSTANTS(:,8)).*ALGEBRAIC(:,10))./1.00000;
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 Bertram, Pedersen, Luciani and Sherman 2006 at changeset ccce6e569232.
Collaboration
To begin collaborating on this work, please use your git client and issue this command: