# 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 =51;
end
% There are a total of 13 entries in each of the rate and state variable arrays.
% There are a total of 58 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('t in component environment (ms)');
LEGEND_CONSTANTS(:,1) = strpad('R in component environment (mJ_per_mole_kelvin)');
LEGEND_CONSTANTS(:,2) = strpad('T in component environment (kelvin)');
LEGEND_CONSTANTS(:,3) = strpad('F in component environment (coulomb_per_mole)');
LEGEND_CONSTANTS(:,49) = strpad('V_tau in component environment (mV)');
LEGEND_CONSTANTS(:,4) = strpad('Ca_o in component environment (mM)');
LEGEND_CONSTANTS(:,5) = strpad('Na_o in component environment (mM)');
LEGEND_CONSTANTS(:,6) = strpad('K_o in component environment (mM)');
LEGEND_CONSTANTS(:,50) = strpad('vol_cyt in component environment (pl)');
LEGEND_CONSTANTS(:,7) = strpad('vol_pmu in component environment (pl)');
LEGEND_CONSTANTS(:,8) = strpad('fr_cyt in component environment (dimensionless)');
LEGEND_STATES(:,1) = strpad('V in component Membrane (mV)');
LEGEND_ALGEBRAIC(:,1) = strpad('VD in component Membrane (dimensionless)');
LEGEND_CONSTANTS(:,9) = strpad('C_sp in component Membrane (pF_per_sqcm)');
LEGEND_STATES(:,2) = strpad('Ca_i in component Cytosol (mM)');
LEGEND_STATES(:,3) = strpad('Na_i in component Cytosol (mM)');
LEGEND_STATES(:,4) = strpad('K_i in component Cytosol (mM)');
LEGEND_ALGEBRAIC(:,3) = strpad('V_Ca in component Membrane (dimensionless)');
LEGEND_ALGEBRAIC(:,5) = strpad('V_Na in component Membrane (dimensionless)');
LEGEND_ALGEBRAIC(:,7) = strpad('V_K in component Membrane (dimensionless)');
LEGEND_CONSTANTS(:,56) = strpad('A_pmu in component Membrane (sqcm)');
LEGEND_CONSTANTS(:,10) = strpad('SVR_pmu in component Membrane (per_cm)');
LEGEND_ALGEBRAIC(:,41) = strpad('J_Ca in component calcium_dynamics (mM_per_ms)');
LEGEND_ALGEBRAIC(:,49) = strpad('J_Na in component sodium_dynamics (mM_per_ms)');
LEGEND_ALGEBRAIC(:,51) = strpad('J_K in component potassium_dynamics (mM_per_ms)');
LEGEND_CONSTANTS(:,11) = strpad('atp in component Cytosol (mM)');
LEGEND_ALGEBRAIC(:,40) = strpad('J_ca in component calcium_dynamics (mM_per_ms)');
LEGEND_ALGEBRAIC(:,20) = strpad('I_CaL in component L_type_Ca_channel (pA)');
LEGEND_ALGEBRAIC(:,35) = strpad('I_pmca in component PMCA (pA)');
LEGEND_ALGEBRAIC(:,39) = strpad('I_xm in component NaCa (pA)');
LEGEND_ALGEBRAIC(:,16) = strpad('J_calb in component calcium_buffer_dynamics (mM_per_ms)');
LEGEND_ALGEBRAIC(:,18) = strpad('J_cam in component calcium_buffer_dynamics (mM_per_ms)');
LEGEND_ALGEBRAIC(:,22) = strpad('I_Na in component transient_Na_channel (pA)');
LEGEND_ALGEBRAIC(:,23) = strpad('I_Nalk in component Leak_Na_channel (pA)');
LEGEND_ALGEBRAIC(:,24) = strpad('I_NaHCN in component HCN_channel (pA)');
LEGEND_ALGEBRAIC(:,47) = strpad('I_nk in component sodium_pump (pA)');
LEGEND_ALGEBRAIC(:,31) = strpad('I_K in component potassium_dynamics (pA)');
LEGEND_ALGEBRAIC(:,26) = strpad('I_Ksk in component SK_K_channel (pA)');
LEGEND_ALGEBRAIC(:,28) = strpad('I_Kdr in component DR_K_channel (pA)');
LEGEND_ALGEBRAIC(:,30) = strpad('I_Kir in component IR_K_channel (pA)');
LEGEND_STATES(:,5) = strpad('Calb in component calcium_buffer_dynamics (mM)');
LEGEND_STATES(:,6) = strpad('Cam in component calcium_buffer_dynamics (mM)');
LEGEND_CONSTANTS(:,12) = strpad('Calbtot in component calcium_buffer_dynamics (mM)');
LEGEND_CONSTANTS(:,13) = strpad('Camtot in component calcium_buffer_dynamics (mM)');
LEGEND_ALGEBRAIC(:,15) = strpad('CaCalb in component calcium_buffer_dynamics (mM)');
LEGEND_ALGEBRAIC(:,17) = strpad('CaCam in component calcium_buffer_dynamics (mM)');
LEGEND_CONSTANTS(:,14) = strpad('kcal_1 in component calcium_buffer_dynamics (per_mM_ms)');
LEGEND_CONSTANTS(:,15) = strpad('kcal_2 in component calcium_buffer_dynamics (per_ms)');
LEGEND_ALGEBRAIC(:,9) = strpad('kcam_cb in component calcium_buffer_dynamics (per_ms)');
LEGEND_CONSTANTS(:,16) = strpad('kcam_cd in component calcium_buffer_dynamics (per_ms)');
LEGEND_ALGEBRAIC(:,11) = strpad('kcam_nb in component calcium_buffer_dynamics (per_ms)');
LEGEND_CONSTANTS(:,17) = strpad('kcam_nd in component calcium_buffer_dynamics (per_ms)');
LEGEND_ALGEBRAIC(:,13) = strpad('alpha_cam in component calcium_buffer_dynamics (per_ms)');
LEGEND_ALGEBRAIC(:,14) = strpad('beta_cam in component calcium_buffer_dynamics (per_ms)');
LEGEND_STATES(:,7) = strpad('m_cal in component L_type_Ca_channel (dimensionless)');
LEGEND_ALGEBRAIC(:,19) = strpad('h_cal in component L_type_Ca_channel (dimensionless)');
LEGEND_CONSTANTS(:,18) = strpad('g_cal in component L_type_Ca_channel (pA_per_mM)');
LEGEND_CONSTANTS(:,19) = strpad('g_na in component transient_Na_channel (pA_per_mM)');
LEGEND_ALGEBRAIC(:,21) = strpad('O_na in component transient_Na_channel (dimensionless)');
LEGEND_STATES(:,8) = strpad('m_na in component transient_Na_channel (dimensionless)');
LEGEND_STATES(:,9) = strpad('h_na in component transient_Na_channel (dimensionless)');
LEGEND_CONSTANTS(:,20) = strpad('A_mna in component transient_Na_channel (per_ms)');
LEGEND_CONSTANTS(:,21) = strpad('B_mna in component transient_Na_channel (per_ms)');
LEGEND_CONSTANTS(:,22) = strpad('A_hna in component transient_Na_channel (per_ms)');
LEGEND_CONSTANTS(:,23) = strpad('B_hna in component transient_Na_channel (per_ms)');
LEGEND_CONSTANTS(:,24) = strpad('za_mna in component transient_Na_channel (dimensionless)');
LEGEND_CONSTANTS(:,25) = strpad('zb_mna in component transient_Na_channel (dimensionless)');
LEGEND_CONSTANTS(:,26) = strpad('za_hna in component transient_Na_channel (dimensionless)');
LEGEND_CONSTANTS(:,27) = strpad('zb_hna in component transient_Na_channel (dimensionless)');
LEGEND_CONSTANTS(:,28) = strpad('g_nalk in component Leak_Na_channel (pA_per_mM)');
LEGEND_CONSTANTS(:,29) = strpad('g_nahcn in component HCN_channel (pA_per_mM)');
LEGEND_STATES(:,10) = strpad('O_hcn in component HCN_channel (dimensionless)');
LEGEND_ALGEBRAIC(:,8) = strpad('kf_hcn in component HCN_channel (per_ms)');
LEGEND_ALGEBRAIC(:,12) = strpad('kr_hcn in component HCN_channel (per_ms)');
LEGEND_ALGEBRAIC(:,2) = strpad('kf_free in component HCN_channel (per_ms)');
LEGEND_ALGEBRAIC(:,4) = strpad('kr_free in component HCN_channel (per_ms)');
LEGEND_ALGEBRAIC(:,6) = strpad('kf_bnd in component HCN_channel (per_ms)');
LEGEND_ALGEBRAIC(:,10) = strpad('kr_bnd in component HCN_channel (per_ms)');
LEGEND_CONSTANTS(:,51) = strpad('P_c in component HCN_channel (dimensionless)');
LEGEND_CONSTANTS(:,52) = strpad('P_o in component HCN_channel (dimensionless)');
LEGEND_CONSTANTS(:,30) = strpad('cAMP in component HCN_channel (mM)');
LEGEND_ALGEBRAIC(:,25) = strpad('O_sk in component SK_K_channel (dimensionless)');
LEGEND_CONSTANTS(:,31) = strpad('g_ksk in component SK_K_channel (pA_per_mM)');
LEGEND_ALGEBRAIC(:,27) = strpad('O_kdr in component DR_K_channel (dimensionless)');
LEGEND_STATES(:,11) = strpad('m_kdr in component DR_K_channel (dimensionless)');
LEGEND_CONSTANTS(:,32) = strpad('g_kdr in component DR_K_channel (nS)');
LEGEND_ALGEBRAIC(:,29) = strpad('O_kir in component IR_K_channel (dimensionless)');
LEGEND_CONSTANTS(:,33) = strpad('g_kir in component IR_K_channel (nS)');
LEGEND_STATES(:,12) = strpad('y_pc in component PMCA (dimensionless)');
LEGEND_ALGEBRAIC(:,32) = strpad('K_pmca in component PMCA (pA)');
LEGEND_CONSTANTS(:,53) = strpad('k_1pc in component PMCA (per_ms)');
LEGEND_CONSTANTS(:,34) = strpad('k_2pc in component PMCA (per_ms)');
LEGEND_CONSTANTS(:,35) = strpad('k_3pc in component PMCA (per_ms)');
LEGEND_CONSTANTS(:,36) = strpad('k_4pc in component PMCA (per_ms)');
LEGEND_ALGEBRAIC(:,34) = strpad('P_E1Spc in component PMCA (dimensionless)');
LEGEND_CONSTANTS(:,54) = strpad('P_E2Spc in component PMCA (dimensionless)');
LEGEND_ALGEBRAIC(:,36) = strpad('P_E1pc in component PMCA (dimensionless)');
LEGEND_CONSTANTS(:,57) = strpad('P_E2pc in component PMCA (dimensionless)');
LEGEND_ALGEBRAIC(:,38) = strpad('alpha_pc in component PMCA (per_ms)');
LEGEND_CONSTANTS(:,58) = strpad('beta_pc in component PMCA (per_ms)');
LEGEND_ALGEBRAIC(:,33) = strpad('K_pci in component PMCA (mM)');
LEGEND_CONSTANTS(:,37) = strpad('K_pco in component PMCA (mM)');
LEGEND_CONSTANTS(:,38) = strpad('k_pmca in component PMCA (dimensionless)');
LEGEND_CONSTANTS(:,39) = strpad('del in component NaCa (dimensionless)');
LEGEND_CONSTANTS(:,40) = strpad('k_xm in component NaCa (pA)');
LEGEND_ALGEBRAIC(:,37) = strpad('Dr in component NaCa (mM4)');
LEGEND_ALGEBRAIC(:,42) = strpad('Na_eff in component sodium_pump (mM)');
LEGEND_STATES(:,13) = strpad('y_nk in component sodium_pump (dimensionless)');
LEGEND_ALGEBRAIC(:,45) = strpad('alpha_nk in component sodium_pump (per_ms)');
LEGEND_ALGEBRAIC(:,50) = strpad('beta_nk in component sodium_pump (per_ms)');
LEGEND_ALGEBRAIC(:,43) = strpad('P_E1Snk in component sodium_pump (dimensionless)');
LEGEND_ALGEBRAIC(:,46) = strpad('P_E2Snk in component sodium_pump (dimensionless)');
LEGEND_ALGEBRAIC(:,44) = strpad('P_E1Dnk in component sodium_pump (dimensionless)');
LEGEND_ALGEBRAIC(:,48) = strpad('P_E2Dnk in component sodium_pump (dimensionless)');
LEGEND_CONSTANTS(:,55) = strpad('k_1nk in component sodium_pump (per_ms)');
LEGEND_CONSTANTS(:,41) = strpad('k_2nk in component sodium_pump (per_ms)');
LEGEND_CONSTANTS(:,42) = strpad('k_3nk in component sodium_pump (per_ms)');
LEGEND_CONSTANTS(:,43) = strpad('k_4nk in component sodium_pump (per_ms)');
LEGEND_CONSTANTS(:,44) = strpad('K_nknai in component sodium_pump (mM)');
LEGEND_CONSTANTS(:,45) = strpad('K_nknao in component sodium_pump (mM)');
LEGEND_CONSTANTS(:,46) = strpad('K_nkki in component sodium_pump (mM)');
LEGEND_CONSTANTS(:,47) = strpad('K_nkko in component sodium_pump (mM)');
LEGEND_CONSTANTS(:,48) = strpad('k_nk in component sodium_pump (pA)');
LEGEND_RATES(:,1) = strpad('d/dt V in component Membrane (mV)');
LEGEND_RATES(:,2) = strpad('d/dt Ca_i in component Cytosol (mM)');
LEGEND_RATES(:,3) = strpad('d/dt Na_i in component Cytosol (mM)');
LEGEND_RATES(:,4) = strpad('d/dt K_i in component Cytosol (mM)');
LEGEND_RATES(:,5) = strpad('d/dt Calb in component calcium_buffer_dynamics (mM)');
LEGEND_RATES(:,6) = strpad('d/dt Cam in component calcium_buffer_dynamics (mM)');
LEGEND_RATES(:,7) = strpad('d/dt m_cal in component L_type_Ca_channel (dimensionless)');
LEGEND_RATES(:,8) = strpad('d/dt m_na in component transient_Na_channel (dimensionless)');
LEGEND_RATES(:,9) = strpad('d/dt h_na in component transient_Na_channel (dimensionless)');
LEGEND_RATES(:,10) = strpad('d/dt O_hcn in component HCN_channel (dimensionless)');
LEGEND_RATES(:,11) = strpad('d/dt m_kdr in component DR_K_channel (dimensionless)');
LEGEND_RATES(:,12) = strpad('d/dt y_pc in component PMCA (dimensionless)');
LEGEND_RATES(:,13) = strpad('d/dt y_nk in component sodium_pump (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 = [];
CONSTANTS(:,1) = 8314.472;
CONSTANTS(:,2) = 310.15;
CONSTANTS(:,3) = 96485.30929;
CONSTANTS(:,4) = 1.8;
CONSTANTS(:,5) = 137;
CONSTANTS(:,6) = 5.4;
CONSTANTS(:,7) = 5;
CONSTANTS(:,8) = 0.5;
STATES(:,1) = -49.42;
CONSTANTS(:,9) = 0.9e6;
STATES(:,2) = 0.000188;
STATES(:,3) = 4.6876;
STATES(:,4) = 126.05893;
CONSTANTS(:,10) = 1.6667e4;
CONSTANTS(:,11) = 2;
STATES(:,5) = 0.0026;
STATES(:,6) = 0.0222;
CONSTANTS(:,12) = 0.005;
CONSTANTS(:,13) = 0.0235;
CONSTANTS(:,14) = 10;
CONSTANTS(:,15) = 2e-3;
CONSTANTS(:,16) = 0.003;
CONSTANTS(:,17) = 3;
STATES(:,7) = 0.006271;
CONSTANTS(:,18) = 2101.2;
CONSTANTS(:,19) = 907.68;
STATES(:,8) = 0.0952;
STATES(:,9) = 0.1848;
CONSTANTS(:,20) = 1.9651;
CONSTANTS(:,21) = 0.0424;
CONSTANTS(:,22) = 9.566e-5;
CONSTANTS(:,23) = 0.5296;
CONSTANTS(:,24) = 1.7127;
CONSTANTS(:,25) = 1.5581;
CONSTANTS(:,26) = -2.4317;
CONSTANTS(:,27) = -1.1868;
CONSTANTS(:,28) = 0.0053;
CONSTANTS(:,29) = 51.1;
STATES(:,10) = 0.003;
CONSTANTS(:,30) = 1e-5;
CONSTANTS(:,31) = 2.2515;
STATES(:,11) = 0.0932;
CONSTANTS(:,32) = 31.237;
CONSTANTS(:,33) = 13.816;
STATES(:,12) = 0.483;
CONSTANTS(:,34) = 0.001;
CONSTANTS(:,35) = 0.001;
CONSTANTS(:,36) = 1;
CONSTANTS(:,37) = 2;
CONSTANTS(:,38) = 2.233;
CONSTANTS(:,39) = 0.35;
CONSTANTS(:,40) = 0.0166;
STATES(:,13) = 0.6213;
CONSTANTS(:,41) = 0.04;
CONSTANTS(:,42) = 0.01;
CONSTANTS(:,43) = 0.165;
CONSTANTS(:,44) = 4.05;
CONSTANTS(:,45) = 69.8;
CONSTANTS(:,46) = 32.88;
CONSTANTS(:,47) = 0.258;
CONSTANTS(:,48) = 1085.7;
CONSTANTS(:,49) = ( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3);
CONSTANTS(:,50) =  CONSTANTS(:,8).*CONSTANTS(:,7);
CONSTANTS(:,51) = 1.00000./(1.00000+CONSTANTS(:,30)./0.00116300);
CONSTANTS(:,52) = 1.00000./(1.00000+CONSTANTS(:,30)./1.45000e-05);
CONSTANTS(:,53) = 1.00000./(1.00000+0.100000./CONSTANTS(:,11));
CONSTANTS(:,54) = 1.00000./(1.00000+CONSTANTS(:,37)./CONSTANTS(:,4));
CONSTANTS(:,55) = 0.370000./(1.00000+0.0940000./CONSTANTS(:,11));
CONSTANTS(:,56) = ( CONSTANTS(:,10).*CONSTANTS(:,7).*0.00100000.*0.00100000.*0.00100000)./1.00000;
CONSTANTS(:,57) = 1.00000 - CONSTANTS(:,54);
CONSTANTS(:,58) =  CONSTANTS(:,34).*CONSTANTS(:,54)+ CONSTANTS(:,36).*CONSTANTS(:,57);
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(:,7) = (1.00000./(1.00000+exp( - (STATES(:,1)+15.0000)./7.00000)) - STATES(:,7))./( 7.68000.*exp( - power((STATES(:,1)+65.0000)./17.3300, 2.00000))+0.723100);
RATES(:,11) = (1.00000./(1.00000+exp( - (STATES(:,1)+25.0000)./12.0000)) - STATES(:,11))./(18.0000./(1.00000+exp((STATES(:,1)+39.0000)./8.00000))+1.00000);
ALGEBRAIC(:,1) = STATES(:,1)./CONSTANTS(:,49);
RATES(:,8) =  CONSTANTS(:,20).*exp( CONSTANTS(:,24).*ALGEBRAIC(:,1)).*(1.00000 - STATES(:,8)) -  CONSTANTS(:,21).*exp(  - CONSTANTS(:,25).*ALGEBRAIC(:,1)).*STATES(:,8);
RATES(:,9) =  CONSTANTS(:,22).*exp( CONSTANTS(:,26).*ALGEBRAIC(:,1)).*(1.00000 - STATES(:,9)) -  CONSTANTS(:,23).*exp(  - CONSTANTS(:,27).*ALGEBRAIC(:,1)).*STATES(:,9);
ALGEBRAIC(:,2) = 0.00600000./(1.00000+exp((STATES(:,1)+87.7000)./6.45000));
ALGEBRAIC(:,6) = 0.0268000./(1.00000+exp((STATES(:,1)+94.2000)./13.3000));
ALGEBRAIC(:,8) =  ALGEBRAIC(:,2).*CONSTANTS(:,51)+ ALGEBRAIC(:,6).*(1.00000 - CONSTANTS(:,51));
ALGEBRAIC(:,4) = 0.0800000./(1.00000+exp( - (STATES(:,1)+51.7000)./7.00000));
ALGEBRAIC(:,10) = 0.0800000./(1.00000+exp( - (STATES(:,1)+35.5000)./7.00000));
ALGEBRAIC(:,12) =  ALGEBRAIC(:,4).*CONSTANTS(:,52)+ ALGEBRAIC(:,10).*(1.00000 - CONSTANTS(:,52));
RATES(:,10) =  ALGEBRAIC(:,8).*(1.00000 - STATES(:,10)) -  ALGEBRAIC(:,12).*STATES(:,10);
ALGEBRAIC(:,15) = CONSTANTS(:,12) - STATES(:,5);
ALGEBRAIC(:,16) =  CONSTANTS(:,14).*STATES(:,5).*STATES(:,2) -  CONSTANTS(:,15).*ALGEBRAIC(:,15);
RATES(:,5) =  - ALGEBRAIC(:,16);
ALGEBRAIC(:,17) = CONSTANTS(:,13) - STATES(:,6);
ALGEBRAIC(:,9) =  12000.0.*power(STATES(:,2), 2.00000);
ALGEBRAIC(:,11) =  3.70000e+06.*power(STATES(:,2), 2.00000);
ALGEBRAIC(:,13) =  ALGEBRAIC(:,9).*ALGEBRAIC(:,11).*(1.00000./(ALGEBRAIC(:,9)+CONSTANTS(:,17))+1.00000./(CONSTANTS(:,16)+CONSTANTS(:,17)));
ALGEBRAIC(:,14) =  CONSTANTS(:,16).*CONSTANTS(:,17).*(1.00000./(ALGEBRAIC(:,9)+CONSTANTS(:,17))+1.00000./(CONSTANTS(:,16)+CONSTANTS(:,17)));
ALGEBRAIC(:,18) =  ALGEBRAIC(:,13).*STATES(:,6) -  ALGEBRAIC(:,14).*ALGEBRAIC(:,17);
RATES(:,6) =  - ALGEBRAIC(:,18);
ALGEBRAIC(:,33) =  (173.600./(1.00000+ALGEBRAIC(:,17)./5.00000e-05)+6.40000).*1.00000e-05;
ALGEBRAIC(:,34) = 1.00000./(1.00000+ALGEBRAIC(:,33)./STATES(:,2));
ALGEBRAIC(:,36) = 1.00000 - ALGEBRAIC(:,34);
ALGEBRAIC(:,38) =  CONSTANTS(:,53).*ALGEBRAIC(:,34)+ CONSTANTS(:,35).*ALGEBRAIC(:,36);
RATES(:,12) =  CONSTANTS(:,58).*(1.00000 - STATES(:,12)) -  ALGEBRAIC(:,38).*STATES(:,12);
ALGEBRAIC(:,3) =  0.500000.*log(CONSTANTS(:,4)./STATES(:,2));
ALGEBRAIC(:,19) = 0.000450000./(0.000450000+STATES(:,2));
ALGEBRAIC(:,20) = ( CONSTANTS(:,18).*STATES(:,7).*ALGEBRAIC(:,19).*power(( STATES(:,2).*CONSTANTS(:,4)), 1.0 ./ 2).* sinh(ALGEBRAIC(:,1) - ALGEBRAIC(:,3)))./( sinh(ALGEBRAIC(:,1))./ALGEBRAIC(:,1));
ALGEBRAIC(:,32) =  CONSTANTS(:,38).*(( 10.5600.*ALGEBRAIC(:,17))./(ALGEBRAIC(:,17)+5.00000e-05)+1.20000);
ALGEBRAIC(:,35) =  ALGEBRAIC(:,32).*( CONSTANTS(:,53).*ALGEBRAIC(:,34).*STATES(:,12) -  CONSTANTS(:,34).*CONSTANTS(:,54).*(1.00000 - STATES(:,12))).*1.00000;
ALGEBRAIC(:,37) =  (1.00000+ 0.00100000.*( power(STATES(:,3), 3.00000).*CONSTANTS(:,4)+ power(CONSTANTS(:,5), 3.00000).*STATES(:,2))).*(1.00000+STATES(:,2)./0.00690000);
ALGEBRAIC(:,39) = ( CONSTANTS(:,40).*( power(STATES(:,3), 3.00000).*CONSTANTS(:,4).*exp( CONSTANTS(:,39).*ALGEBRAIC(:,1)) -  power(CONSTANTS(:,5), 3.00000).*STATES(:,2).*exp( (CONSTANTS(:,39) - 1.00000).*ALGEBRAIC(:,1))))./ALGEBRAIC(:,37);
ALGEBRAIC(:,40) =  ( - 1.00000./( 2.00000.*CONSTANTS(:,3).*CONSTANTS(:,50))).*((ALGEBRAIC(:,20)+ 2.00000.*ALGEBRAIC(:,35)) -  2.00000.*ALGEBRAIC(:,39));
ALGEBRAIC(:,41) = ALGEBRAIC(:,40) - (ALGEBRAIC(:,16)+ 4.00000.*ALGEBRAIC(:,18));
RATES(:,2) = ALGEBRAIC(:,41);
ALGEBRAIC(:,5) = log(CONSTANTS(:,5)./STATES(:,3));
ALGEBRAIC(:,21) =  power(STATES(:,8), 3.00000).*STATES(:,9);
ALGEBRAIC(:,22) = ( CONSTANTS(:,19).*ALGEBRAIC(:,21).*power(( STATES(:,3).*CONSTANTS(:,5)), 1.0 ./ 2).* sinh( 0.500000.*(ALGEBRAIC(:,1) - ALGEBRAIC(:,5))))./( sinh( 0.500000.*ALGEBRAIC(:,1))./( 0.500000.*ALGEBRAIC(:,1)));
ALGEBRAIC(:,23) = ( CONSTANTS(:,28).*power(( STATES(:,3).*CONSTANTS(:,5)), 1.0 ./ 2).* sinh( 0.500000.*(ALGEBRAIC(:,1) - ALGEBRAIC(:,5))))./( sinh( 0.500000.*ALGEBRAIC(:,1))./( 0.500000.*ALGEBRAIC(:,1)));
ALGEBRAIC(:,24) = ( CONSTANTS(:,29).*STATES(:,10).*power(( STATES(:,3).*CONSTANTS(:,5)), 1.0 ./ 2).* sinh( 0.500000.*(ALGEBRAIC(:,1) - ALGEBRAIC(:,5))))./( sinh( 0.500000.*ALGEBRAIC(:,1))./( 0.500000.*ALGEBRAIC(:,1)));
ALGEBRAIC(:,43) = 1.00000./(1.00000+ (CONSTANTS(:,44)./STATES(:,3)).*(1.00000+STATES(:,4)./CONSTANTS(:,46)));
ALGEBRAIC(:,42) =  CONSTANTS(:,5).*exp(  - 0.820000.*ALGEBRAIC(:,1));
ALGEBRAIC(:,46) = 1.00000./(1.00000+ (CONSTANTS(:,45)./ALGEBRAIC(:,42)).*(1.00000+CONSTANTS(:,6)./CONSTANTS(:,47)));
ALGEBRAIC(:,47) =  CONSTANTS(:,48).*( CONSTANTS(:,55).*ALGEBRAIC(:,43).*STATES(:,13) -  CONSTANTS(:,41).*ALGEBRAIC(:,46).*(1.00000 - STATES(:,13))).*1.00000;
ALGEBRAIC(:,49) =  ( - 1.00000./( CONSTANTS(:,3).*CONSTANTS(:,50))).*( 3.00000.*ALGEBRAIC(:,47)+ 3.00000.*ALGEBRAIC(:,39)+ALGEBRAIC(:,22)+ALGEBRAIC(:,23)+ALGEBRAIC(:,24));
RATES(:,3) = ALGEBRAIC(:,49);
ALGEBRAIC(:,44) = 1.00000./(1.00000+ (CONSTANTS(:,46)./STATES(:,4)).*(1.00000+STATES(:,3)./CONSTANTS(:,44)));
ALGEBRAIC(:,45) =  CONSTANTS(:,55).*ALGEBRAIC(:,43)+ CONSTANTS(:,42).*ALGEBRAIC(:,44);
ALGEBRAIC(:,48) = 1.00000./(1.00000+ (CONSTANTS(:,47)./CONSTANTS(:,6)).*(1.00000+ALGEBRAIC(:,42)./CONSTANTS(:,45)));
ALGEBRAIC(:,50) =  CONSTANTS(:,41).*ALGEBRAIC(:,46)+ CONSTANTS(:,43).*ALGEBRAIC(:,48);
RATES(:,13) =  ALGEBRAIC(:,50).*(1.00000 - STATES(:,13)) -  ALGEBRAIC(:,45).*STATES(:,13);
ALGEBRAIC(:,7) = log(CONSTANTS(:,6)./STATES(:,4));
ALGEBRAIC(:,25) = power(STATES(:,2), 4.20000)./(power(0.000350000, 4.20000)+power(STATES(:,2), 4.20000));
ALGEBRAIC(:,26) = ( CONSTANTS(:,31).*ALGEBRAIC(:,25).*power(( STATES(:,4).*CONSTANTS(:,6)), 1.0 ./ 2).* sinh( 0.500000.*(ALGEBRAIC(:,1) - ALGEBRAIC(:,7))))./( sinh( 0.500000.*ALGEBRAIC(:,1))./( 0.500000.*ALGEBRAIC(:,1)));
ALGEBRAIC(:,27) = power(STATES(:,11), 3.00000);
ALGEBRAIC(:,28) =  CONSTANTS(:,32).*ALGEBRAIC(:,27).*(STATES(:,1) -  ALGEBRAIC(:,7).*CONSTANTS(:,49));
ALGEBRAIC(:,29) = 1.00000./(1.00000+exp((STATES(:,1)+85.0000)./12.1000));
ALGEBRAIC(:,30) =  CONSTANTS(:,33).*ALGEBRAIC(:,29).*(STATES(:,1) -  ALGEBRAIC(:,7).*CONSTANTS(:,49));
ALGEBRAIC(:,31) = ALGEBRAIC(:,26)+ALGEBRAIC(:,28)+ALGEBRAIC(:,30);
ALGEBRAIC(:,51) =  ( - 1.00000./( CONSTANTS(:,3).*CONSTANTS(:,50))).*(ALGEBRAIC(:,31) -  2.00000.*ALGEBRAIC(:,47));
RATES(:,1) =  (( CONSTANTS(:,3).*CONSTANTS(:,50))./( CONSTANTS(:,9).*CONSTANTS(:,56))).*(ALGEBRAIC(:,49)+ALGEBRAIC(:,51)+ 2.00000.*ALGEBRAIC(:,41));
RATES(:,4) = ALGEBRAIC(:,51);
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)./CONSTANTS(:,49);
ALGEBRAIC(:,2) = 0.00600000./(1.00000+exp((STATES(:,1)+87.7000)./6.45000));
ALGEBRAIC(:,6) = 0.0268000./(1.00000+exp((STATES(:,1)+94.2000)./13.3000));
ALGEBRAIC(:,8) =  ALGEBRAIC(:,2).*CONSTANTS(:,51)+ ALGEBRAIC(:,6).*(1.00000 - CONSTANTS(:,51));
ALGEBRAIC(:,4) = 0.0800000./(1.00000+exp( - (STATES(:,1)+51.7000)./7.00000));
ALGEBRAIC(:,10) = 0.0800000./(1.00000+exp( - (STATES(:,1)+35.5000)./7.00000));
ALGEBRAIC(:,12) =  ALGEBRAIC(:,4).*CONSTANTS(:,52)+ ALGEBRAIC(:,10).*(1.00000 - CONSTANTS(:,52));
ALGEBRAIC(:,15) = CONSTANTS(:,12) - STATES(:,5);
ALGEBRAIC(:,16) =  CONSTANTS(:,14).*STATES(:,5).*STATES(:,2) -  CONSTANTS(:,15).*ALGEBRAIC(:,15);
ALGEBRAIC(:,17) = CONSTANTS(:,13) - STATES(:,6);
ALGEBRAIC(:,9) =  12000.0.*power(STATES(:,2), 2.00000);
ALGEBRAIC(:,11) =  3.70000e+06.*power(STATES(:,2), 2.00000);
ALGEBRAIC(:,13) =  ALGEBRAIC(:,9).*ALGEBRAIC(:,11).*(1.00000./(ALGEBRAIC(:,9)+CONSTANTS(:,17))+1.00000./(CONSTANTS(:,16)+CONSTANTS(:,17)));
ALGEBRAIC(:,14) =  CONSTANTS(:,16).*CONSTANTS(:,17).*(1.00000./(ALGEBRAIC(:,9)+CONSTANTS(:,17))+1.00000./(CONSTANTS(:,16)+CONSTANTS(:,17)));
ALGEBRAIC(:,18) =  ALGEBRAIC(:,13).*STATES(:,6) -  ALGEBRAIC(:,14).*ALGEBRAIC(:,17);
ALGEBRAIC(:,33) =  (173.600./(1.00000+ALGEBRAIC(:,17)./5.00000e-05)+6.40000).*1.00000e-05;
ALGEBRAIC(:,34) = 1.00000./(1.00000+ALGEBRAIC(:,33)./STATES(:,2));
ALGEBRAIC(:,36) = 1.00000 - ALGEBRAIC(:,34);
ALGEBRAIC(:,38) =  CONSTANTS(:,53).*ALGEBRAIC(:,34)+ CONSTANTS(:,35).*ALGEBRAIC(:,36);
ALGEBRAIC(:,3) =  0.500000.*log(CONSTANTS(:,4)./STATES(:,2));
ALGEBRAIC(:,19) = 0.000450000./(0.000450000+STATES(:,2));
ALGEBRAIC(:,20) = ( CONSTANTS(:,18).*STATES(:,7).*ALGEBRAIC(:,19).*power(( STATES(:,2).*CONSTANTS(:,4)), 1.0 ./ 2).* sinh(ALGEBRAIC(:,1) - ALGEBRAIC(:,3)))./( sinh(ALGEBRAIC(:,1))./ALGEBRAIC(:,1));
ALGEBRAIC(:,32) =  CONSTANTS(:,38).*(( 10.5600.*ALGEBRAIC(:,17))./(ALGEBRAIC(:,17)+5.00000e-05)+1.20000);
ALGEBRAIC(:,35) =  ALGEBRAIC(:,32).*( CONSTANTS(:,53).*ALGEBRAIC(:,34).*STATES(:,12) -  CONSTANTS(:,34).*CONSTANTS(:,54).*(1.00000 - STATES(:,12))).*1.00000;
ALGEBRAIC(:,37) =  (1.00000+ 0.00100000.*( power(STATES(:,3), 3.00000).*CONSTANTS(:,4)+ power(CONSTANTS(:,5), 3.00000).*STATES(:,2))).*(1.00000+STATES(:,2)./0.00690000);
ALGEBRAIC(:,39) = ( CONSTANTS(:,40).*( power(STATES(:,3), 3.00000).*CONSTANTS(:,4).*exp( CONSTANTS(:,39).*ALGEBRAIC(:,1)) -  power(CONSTANTS(:,5), 3.00000).*STATES(:,2).*exp( (CONSTANTS(:,39) - 1.00000).*ALGEBRAIC(:,1))))./ALGEBRAIC(:,37);
ALGEBRAIC(:,40) =  ( - 1.00000./( 2.00000.*CONSTANTS(:,3).*CONSTANTS(:,50))).*((ALGEBRAIC(:,20)+ 2.00000.*ALGEBRAIC(:,35)) -  2.00000.*ALGEBRAIC(:,39));
ALGEBRAIC(:,41) = ALGEBRAIC(:,40) - (ALGEBRAIC(:,16)+ 4.00000.*ALGEBRAIC(:,18));
ALGEBRAIC(:,5) = log(CONSTANTS(:,5)./STATES(:,3));
ALGEBRAIC(:,21) =  power(STATES(:,8), 3.00000).*STATES(:,9);
ALGEBRAIC(:,22) = ( CONSTANTS(:,19).*ALGEBRAIC(:,21).*power(( STATES(:,3).*CONSTANTS(:,5)), 1.0 ./ 2).* sinh( 0.500000.*(ALGEBRAIC(:,1) - ALGEBRAIC(:,5))))./( sinh( 0.500000.*ALGEBRAIC(:,1))./( 0.500000.*ALGEBRAIC(:,1)));
ALGEBRAIC(:,23) = ( CONSTANTS(:,28).*power(( STATES(:,3).*CONSTANTS(:,5)), 1.0 ./ 2).* sinh( 0.500000.*(ALGEBRAIC(:,1) - ALGEBRAIC(:,5))))./( sinh( 0.500000.*ALGEBRAIC(:,1))./( 0.500000.*ALGEBRAIC(:,1)));
ALGEBRAIC(:,24) = ( CONSTANTS(:,29).*STATES(:,10).*power(( STATES(:,3).*CONSTANTS(:,5)), 1.0 ./ 2).* sinh( 0.500000.*(ALGEBRAIC(:,1) - ALGEBRAIC(:,5))))./( sinh( 0.500000.*ALGEBRAIC(:,1))./( 0.500000.*ALGEBRAIC(:,1)));
ALGEBRAIC(:,43) = 1.00000./(1.00000+ (CONSTANTS(:,44)./STATES(:,3)).*(1.00000+STATES(:,4)./CONSTANTS(:,46)));
ALGEBRAIC(:,42) =  CONSTANTS(:,5).*exp(  - 0.820000.*ALGEBRAIC(:,1));
ALGEBRAIC(:,46) = 1.00000./(1.00000+ (CONSTANTS(:,45)./ALGEBRAIC(:,42)).*(1.00000+CONSTANTS(:,6)./CONSTANTS(:,47)));
ALGEBRAIC(:,47) =  CONSTANTS(:,48).*( CONSTANTS(:,55).*ALGEBRAIC(:,43).*STATES(:,13) -  CONSTANTS(:,41).*ALGEBRAIC(:,46).*(1.00000 - STATES(:,13))).*1.00000;
ALGEBRAIC(:,49) =  ( - 1.00000./( CONSTANTS(:,3).*CONSTANTS(:,50))).*( 3.00000.*ALGEBRAIC(:,47)+ 3.00000.*ALGEBRAIC(:,39)+ALGEBRAIC(:,22)+ALGEBRAIC(:,23)+ALGEBRAIC(:,24));
ALGEBRAIC(:,44) = 1.00000./(1.00000+ (CONSTANTS(:,46)./STATES(:,4)).*(1.00000+STATES(:,3)./CONSTANTS(:,44)));
ALGEBRAIC(:,45) =  CONSTANTS(:,55).*ALGEBRAIC(:,43)+ CONSTANTS(:,42).*ALGEBRAIC(:,44);
ALGEBRAIC(:,48) = 1.00000./(1.00000+ (CONSTANTS(:,47)./CONSTANTS(:,6)).*(1.00000+ALGEBRAIC(:,42)./CONSTANTS(:,45)));
ALGEBRAIC(:,50) =  CONSTANTS(:,41).*ALGEBRAIC(:,46)+ CONSTANTS(:,43).*ALGEBRAIC(:,48);
ALGEBRAIC(:,7) = log(CONSTANTS(:,6)./STATES(:,4));
ALGEBRAIC(:,25) = power(STATES(:,2), 4.20000)./(power(0.000350000, 4.20000)+power(STATES(:,2), 4.20000));
ALGEBRAIC(:,26) = ( CONSTANTS(:,31).*ALGEBRAIC(:,25).*power(( STATES(:,4).*CONSTANTS(:,6)), 1.0 ./ 2).* sinh( 0.500000.*(ALGEBRAIC(:,1) - ALGEBRAIC(:,7))))./( sinh( 0.500000.*ALGEBRAIC(:,1))./( 0.500000.*ALGEBRAIC(:,1)));
ALGEBRAIC(:,27) = power(STATES(:,11), 3.00000);
ALGEBRAIC(:,28) =  CONSTANTS(:,32).*ALGEBRAIC(:,27).*(STATES(:,1) -  ALGEBRAIC(:,7).*CONSTANTS(:,49));
ALGEBRAIC(:,29) = 1.00000./(1.00000+exp((STATES(:,1)+85.0000)./12.1000));
ALGEBRAIC(:,30) =  CONSTANTS(:,33).*ALGEBRAIC(:,29).*(STATES(:,1) -  ALGEBRAIC(:,7).*CONSTANTS(:,49));
ALGEBRAIC(:,31) = ALGEBRAIC(:,26)+ALGEBRAIC(:,28)+ALGEBRAIC(:,30);
ALGEBRAIC(:,51) =  ( - 1.00000./( CONSTANTS(:,3).*CONSTANTS(:,50))).*(ALGEBRAIC(:,31) -  2.00000.*ALGEBRAIC(:,47));
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: