# 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 =56;
end
% There are a total of 22 entries in each of the rate and state variable arrays.
% There are a total of 132 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 Time (time_units)');
LEGEND_CONSTANTS(:,1) = strpad('T in component Environment (Temperature_units)');
LEGEND_CONSTANTS(:,2) = strpad('T_exp in component Environment (Temperature_units)');
LEGEND_CONSTANTS(:,3) = strpad('F in component Environment (F_units)');
LEGEND_CONSTANTS(:,4) = strpad('R in component Environment (R_units)');
LEGEND_CONSTANTS(:,5) = strpad('Q10Ca in component Environment (dimensionless)');
LEGEND_CONSTANTS(:,6) = strpad('Q10K in component Environment (dimensionless)');
LEGEND_CONSTANTS(:,7) = strpad('Q10Na in component Environment (dimensionless)');
LEGEND_CONSTANTS(:,8) = strpad('Ca_o in component Environment (millimolar)');
LEGEND_CONSTANTS(:,9) = strpad('Na_o in component Environment (millimolar)');
LEGEND_CONSTANTS(:,10) = strpad('K_o in component Environment (millimolar)');
LEGEND_CONSTANTS(:,11) = strpad('Cl_o in component Environment (millimolar)');
LEGEND_CONSTANTS(:,105) = strpad('T_correction_Na in component Environment (dimensionless)');
LEGEND_CONSTANTS(:,106) = strpad('T_correction_K in component Environment (dimensionless)');
LEGEND_CONSTANTS(:,107) = strpad('T_correction_Ca in component Environment (dimensionless)');
LEGEND_CONSTANTS(:,108) = strpad('T_correction_BK in component Environment (conductance_units)');
LEGEND_CONSTANTS(:,109) = strpad('FoRT in component Environment (Inverse_Voltage_units)');
LEGEND_CONSTANTS(:,110) = strpad('RToF in component Environment (voltage_units)');
LEGEND_CONSTANTS(:,12) = strpad('Cm in component ICC_Membrane (capacitance_units)');
LEGEND_CONSTANTS(:,13) = strpad('Vol in component ICC_Membrane (volume_units)');
LEGEND_CONSTANTS(:,14) = strpad('P_cyto in component ICC_Membrane (dimensionless)');
LEGEND_CONSTANTS(:,111) = strpad('V_cyto in component ICC_Membrane (volume_units)');
LEGEND_CONSTANTS(:,15) = strpad('fc in component ICC_Membrane (dimensionless)');
LEGEND_STATES(:,1) = strpad('Vm in component ICC_Membrane (voltage_units)');
LEGEND_STATES(:,2) = strpad('Ca_i in component ICC_Membrane (millimolar)');
LEGEND_CONSTANTS(:,16) = strpad('Na_i in component ICC_Membrane (millimolar)');
LEGEND_CONSTANTS(:,17) = strpad('K_i in component ICC_Membrane (millimolar)');
LEGEND_CONSTANTS(:,18) = strpad('Cl_i in component ICC_Membrane (millimolar)');
LEGEND_ALGEBRAIC(:,29) = strpad('J_leak in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,32) = strpad('I_Na in component I_Na (current_units)');
LEGEND_ALGEBRAIC(:,14) = strpad('I_Ltype in component I_Ltype (current_units)');
LEGEND_ALGEBRAIC(:,17) = strpad('I_VDDR in component I_VDDR (current_units)');
LEGEND_ALGEBRAIC(:,30) = strpad('I_kv11 in component I_kv11 (current_units)');
LEGEND_ALGEBRAIC(:,22) = strpad('I_BK in component I_BK (current_units)');
LEGEND_ALGEBRAIC(:,27) = strpad('I_ERG in component I_ERG (current_units)');
LEGEND_ALGEBRAIC(:,18) = strpad('I_CaCl in component I_CaCl (current_units)');
LEGEND_ALGEBRAIC(:,34) = strpad('I_NSCC in component I_NSCC (current_units)');
LEGEND_ALGEBRAIC(:,25) = strpad('I_bk in component I_bk (current_units)');
LEGEND_ALGEBRAIC(:,15) = strpad('J_PMCA in component J_PMCA (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,1) = strpad('d_inf_Ltype in component d_Ltype (dimensionless)');
LEGEND_CONSTANTS(:,112) = strpad('tau_d_Ltype in component d_Ltype (time_units)');
LEGEND_STATES(:,3) = strpad('d_Ltype in component d_Ltype (dimensionless)');
LEGEND_ALGEBRAIC(:,2) = strpad('f_inf_Ltype in component f_Ltype (dimensionless)');
LEGEND_CONSTANTS(:,113) = strpad('tau_f_Ltype in component f_Ltype (time_units)');
LEGEND_STATES(:,4) = strpad('f_Ltype in component f_Ltype (dimensionless)');
LEGEND_ALGEBRAIC(:,3) = strpad('f_ca_inf_Ltype in component f_ca_Ltype (dimensionless)');
LEGEND_CONSTANTS(:,114) = strpad('tau_f_ca_Ltype in component f_ca_Ltype (time_units)');
LEGEND_STATES(:,5) = strpad('f_ca_Ltype in component f_ca_Ltype (dimensionless)');
LEGEND_ALGEBRAIC(:,13) = strpad('E_Ca in component I_Ltype (voltage_units)');
LEGEND_CONSTANTS(:,19) = strpad('G_max_Ltype in component I_Ltype (conductance_units)');
LEGEND_CONSTANTS(:,20) = strpad('J_max_PMCA in component J_PMCA (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,4) = strpad('d_inf_VDDR in component d_VDDR (dimensionless)');
LEGEND_CONSTANTS(:,115) = strpad('tau_d_VDDR in component d_VDDR (time_units)');
LEGEND_STATES(:,6) = strpad('d_VDDR in component d_VDDR (dimensionless)');
LEGEND_ALGEBRAIC(:,5) = strpad('f_inf_VDDR in component f_VDDR (dimensionless)');
LEGEND_CONSTANTS(:,116) = strpad('tau_f_VDDR in component f_VDDR (time_units)');
LEGEND_STATES(:,7) = strpad('f_VDDR in component f_VDDR (dimensionless)');
LEGEND_ALGEBRAIC(:,16) = strpad('E_Ca in component I_VDDR (voltage_units)');
LEGEND_CONSTANTS(:,21) = strpad('G_max_VDDR in component I_VDDR (conductance_units)');
LEGEND_ALGEBRAIC(:,6) = strpad('d_inf_CaCl in component d_CaCl (dimensionless)');
LEGEND_CONSTANTS(:,22) = strpad('tau_d_CaCl in component d_CaCl (time_units)');
LEGEND_STATES(:,8) = strpad('d_CaCl in component d_CaCl (dimensionless)');
LEGEND_CONSTANTS(:,117) = strpad('E_Cl in component I_CaCl (voltage_units)');
LEGEND_CONSTANTS(:,23) = strpad('G_max_CaCl in component I_CaCl (conductance_units)');
LEGEND_ALGEBRAIC(:,20) = strpad('d_BK in component d_BK (dimensionless)');
LEGEND_CONSTANTS(:,118) = strpad('E_K in component I_BK (voltage_units)');
LEGEND_CONSTANTS(:,24) = strpad('G_max_BK in component I_BK (conductance_units)');
LEGEND_CONSTANTS(:,119) = strpad('E_K in component I_bk (voltage_units)');
LEGEND_CONSTANTS(:,25) = strpad('G_max_bk in component I_bk (conductance_units)');
LEGEND_ALGEBRAIC(:,7) = strpad('d_inf_ERG in component d_ERG (dimensionless)');
LEGEND_CONSTANTS(:,120) = strpad('tau_d_ERG in component d_ERG (time_units)');
LEGEND_STATES(:,9) = strpad('d_ERG in component d_ERG (dimensionless)');
LEGEND_CONSTANTS(:,121) = strpad('E_K in component I_ERG (voltage_units)');
LEGEND_CONSTANTS(:,26) = strpad('G_max_ERG in component I_ERG (conductance_units)');
LEGEND_ALGEBRAIC(:,8) = strpad('d_inf_kv11 in component d_kv11 (dimensionless)');
LEGEND_CONSTANTS(:,122) = strpad('tau_d_kv11 in component d_kv11 (time_units)');
LEGEND_STATES(:,10) = strpad('d_kv11 in component d_kv11 (dimensionless)');
LEGEND_ALGEBRAIC(:,9) = strpad('f_inf_kv11 in component f_kv11 (dimensionless)');
LEGEND_CONSTANTS(:,123) = strpad('tau_f_kv11 in component f_kv11 (time_units)');
LEGEND_STATES(:,11) = strpad('f_kv11 in component f_kv11 (dimensionless)');
LEGEND_CONSTANTS(:,124) = strpad('E_K in component I_kv11 (voltage_units)');
LEGEND_CONSTANTS(:,27) = strpad('G_max_kv11 in component I_kv11 (conductance_units)');
LEGEND_ALGEBRAIC(:,10) = strpad('d_inf_Na in component d_Na (dimensionless)');
LEGEND_CONSTANTS(:,125) = strpad('tau_d_Na in component d_Na (time_units)');
LEGEND_STATES(:,12) = strpad('d_Na in component d_Na (dimensionless)');
LEGEND_ALGEBRAIC(:,11) = strpad('f_inf_Na in component f_Na (dimensionless)');
LEGEND_CONSTANTS(:,126) = strpad('tau_f_Na in component f_Na (time_units)');
LEGEND_STATES(:,13) = strpad('f_Na in component f_Na (dimensionless)');
LEGEND_CONSTANTS(:,127) = strpad('E_Na in component I_Na (voltage_units)');
LEGEND_CONSTANTS(:,28) = strpad('G_max_Na in component I_Na (conductance_units)');
LEGEND_STATES(:,14) = strpad('Ca_PU in component PU_unit (millimolar)');
LEGEND_ALGEBRAIC(:,12) = strpad('d_inf_NSCC in component d_NSCC (dimensionless)');
LEGEND_CONSTANTS(:,29) = strpad('tau_d_NSCC in component d_NSCC (time_units)');
LEGEND_STATES(:,15) = strpad('d_NSCC in component d_NSCC (dimensionless)');
LEGEND_CONSTANTS(:,128) = strpad('E_NSCC in component I_NSCC (voltage_units)');
LEGEND_CONSTANTS(:,30) = strpad('G_max_NSCC in component I_NSCC (conductance_units)');
LEGEND_CONSTANTS(:,31) = strpad('NaPerm_o_Kperm in component I_NSCC (dimensionless)');
LEGEND_CONSTANTS(:,32) = strpad('P_PU in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,33) = strpad('P_mito in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,34) = strpad('P_ER in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,129) = strpad('V_MITO in component PU_unit (volume_units)');
LEGEND_CONSTANTS(:,131) = strpad('V_ER in component PU_unit (volume_units)');
LEGEND_CONSTANTS(:,130) = strpad('V_PU in component PU_unit (volume_units)');
LEGEND_CONSTANTS(:,35) = strpad('fe in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,36) = strpad('fm in component PU_unit (dimensionless)');
LEGEND_STATES(:,16) = strpad('Ca_m in component PU_unit (millimolar)');
LEGEND_STATES(:,17) = strpad('Ca_ER in component PU_unit (millimolar)');
LEGEND_STATES(:,21) = strpad('h in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,37) = strpad('IP3 in component PU_unit (millimolar)');
LEGEND_STATES(:,22) = strpad('deltaPsi in component PU_unit (voltage_units)');
LEGEND_CONSTANTS(:,38) = strpad('deltapH in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,40) = strpad('K_res in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,41) = strpad('r1 in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,42) = strpad('r2 in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,43) = strpad('r3 in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,44) = strpad('ra in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,45) = strpad('rb in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,46) = strpad('rc1 in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,47) = strpad('rc2 in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,48) = strpad('deltaPsi_B in component PU_unit (voltage_units)');
LEGEND_CONSTANTS(:,49) = strpad('g in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,50) = strpad('K_F1 in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,51) = strpad('Pi_m in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,52) = strpad('p1 in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,53) = strpad('p2 in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,54) = strpad('p3 in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,55) = strpad('pa in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,56) = strpad('pb in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,57) = strpad('pc1 in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,58) = strpad('pc2 in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,59) = strpad('frac in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,60) = strpad('K_act in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,61) = strpad('na in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,62) = strpad('deltaPsi_star in component PU_unit (voltage_units)');
LEGEND_CONSTANTS(:,63) = strpad('K_Na in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,64) = strpad('K_Ca in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,65) = strpad('K_trans in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,66) = strpad('L in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,67) = strpad('b in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,68) = strpad('beta_max in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,69) = strpad('beta1 in component PU_unit (per_millimolar)');
LEGEND_CONSTANTS(:,70) = strpad('beta2 in component PU_unit (per_millimolar)');
LEGEND_CONSTANTS(:,71) = strpad('beta3 in component PU_unit (per_millimolar)');
LEGEND_CONSTANTS(:,72) = strpad('beta4 in component PU_unit (per_millimolar)');
LEGEND_CONSTANTS(:,73) = strpad('beta5 in component PU_unit (per_millimolar)');
LEGEND_CONSTANTS(:,74) = strpad('beta6 in component PU_unit (per_millimolar)');
LEGEND_CONSTANTS(:,75) = strpad('beta7 in component PU_unit (per_millimolar)');
LEGEND_CONSTANTS(:,76) = strpad('KCa_PDH in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,77) = strpad('u1 in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,78) = strpad('u2 in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,79) = strpad('n in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,80) = strpad('K_Glc in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,81) = strpad('nhyd in component PU_unit (dimensionless)');
LEGEND_CONSTANTS(:,82) = strpad('K_hyd in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,83) = strpad('J_ERleak in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,84) = strpad('Jmax_IP3 in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,85) = strpad('d_IP3 in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,86) = strpad('d_ACT in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,87) = strpad('d_INH in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,88) = strpad('tauh in component PU_unit (time_units)');
LEGEND_CONSTANTS(:,89) = strpad('Jmax_serca in component PU_unit (millimolar_per_second)');
LEGEND_CONSTANTS(:,90) = strpad('k_serca in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,91) = strpad('conc in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,92) = strpad('Jmax_uni in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,93) = strpad('Jmax_NaCa in component PU_unit (millimolar_per_second)');
LEGEND_CONSTANTS(:,94) = strpad('J_max_leak in component PU_unit (rate_constants_units)');
LEGEND_CONSTANTS(:,95) = strpad('rho_res in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,96) = strpad('rho_F1 in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,97) = strpad('g_H in component PU_unit (millimolar_per_second_per_millivolt)');
LEGEND_CONSTANTS(:,98) = strpad('J_red_basal in component PU_unit (millimolar_per_second)');
LEGEND_CONSTANTS(:,99) = strpad('Jmax_ANT in component PU_unit (millimolar_per_second)');
LEGEND_CONSTANTS(:,100) = strpad('J_hyd_max in component PU_unit (millimolar_per_second)');
LEGEND_CONSTANTS(:,101) = strpad('Glc in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,103) = strpad('total_ANP_m in component PU_unit (millimolar)');
LEGEND_CONSTANTS(:,104) = strpad('total_ANP_i in component PU_unit (millimolar)');
LEGEND_ALGEBRAIC(:,39) = strpad('ATP_m in component PU_unit (millimolar)');
LEGEND_ALGEBRAIC(:,45) = strpad('ATP4_m in component PU_unit (millimolar)');
LEGEND_ALGEBRAIC(:,46) = strpad('ATP_i in component PU_unit (millimolar)');
LEGEND_ALGEBRAIC(:,55) = strpad('ATP4_i in component PU_unit (millimolar)');
LEGEND_ALGEBRAIC(:,19) = strpad('J_ERout in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,21) = strpad('J_SERCA in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,23) = strpad('MWC in component PU_unit (millimolar)');
LEGEND_ALGEBRAIC(:,24) = strpad('J_uni in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,26) = strpad('J_NaCa in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,49) = strpad('J_red in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,48) = strpad('J_pTCA in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,41) = strpad('A_F1 in component PU_unit (voltage_units)');
LEGEND_ALGEBRAIC(:,42) = strpad('J_pF1 in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,43) = strpad('J_HF1 in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,36) = strpad('A_res in component PU_unit (voltage_units)');
LEGEND_ALGEBRAIC(:,37) = strpad('J_o in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,47) = strpad('J_glyTotal in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,28) = strpad('f_PDHa in component PU_unit (dimensionless)');
LEGEND_ALGEBRAIC(:,38) = strpad('J_Hres in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,56) = strpad('J_ANT in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,31) = strpad('PMF in component PU_unit (voltage_units)');
LEGEND_ALGEBRAIC(:,33) = strpad('J_Hleak in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,50) = strpad('J_pGly in component PU_unit (millimolar_per_second)');
LEGEND_CONSTANTS(:,132) = strpad('J_hydSS in component PU_unit (millimolar_per_second)');
LEGEND_ALGEBRAIC(:,51) = strpad('J_hyd in component PU_unit (millimolar_per_second)');
LEGEND_RATES(:,1) = strpad('d/dt Vm in component ICC_Membrane (voltage_units)');
LEGEND_RATES(:,2) = strpad('d/dt Ca_i in component ICC_Membrane (millimolar)');
LEGEND_RATES(:,3) = strpad('d/dt d_Ltype in component d_Ltype (dimensionless)');
LEGEND_RATES(:,4) = strpad('d/dt f_Ltype in component f_Ltype (dimensionless)');
LEGEND_RATES(:,5) = strpad('d/dt f_ca_Ltype in component f_ca_Ltype (dimensionless)');
LEGEND_RATES(:,6) = strpad('d/dt d_VDDR in component d_VDDR (dimensionless)');
LEGEND_RATES(:,7) = strpad('d/dt f_VDDR in component f_VDDR (dimensionless)');
LEGEND_RATES(:,8) = strpad('d/dt d_CaCl in component d_CaCl (dimensionless)');
LEGEND_RATES(:,9) = strpad('d/dt d_ERG in component d_ERG (dimensionless)');
LEGEND_RATES(:,10) = strpad('d/dt d_kv11 in component d_kv11 (dimensionless)');
LEGEND_RATES(:,11) = strpad('d/dt f_kv11 in component f_kv11 (dimensionless)');
LEGEND_RATES(:,12) = strpad('d/dt d_Na in component d_Na (dimensionless)');
LEGEND_RATES(:,13) = strpad('d/dt f_Na in component f_Na (dimensionless)');
LEGEND_RATES(:,15) = strpad('d/dt d_NSCC in component d_NSCC (dimensionless)');
LEGEND_RATES(:,14) = strpad('d/dt Ca_PU in component PU_unit (millimolar)');
LEGEND_RATES(:,16) = strpad('d/dt Ca_m in component PU_unit (millimolar)');
LEGEND_RATES(:,17) = strpad('d/dt Ca_ER in component PU_unit (millimolar)');
LEGEND_RATES(:,22) = strpad('d/dt deltaPsi in component PU_unit (voltage_units)');
LEGEND_RATES(:,21) = strpad('d/dt h in component PU_unit (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) = 310;
CONSTANTS(:,2) = 297;
CONSTANTS(:,3) = 96.4846;
CONSTANTS(:,4) = 8.3144;
CONSTANTS(:,5) = 2.1;
CONSTANTS(:,6) = 1.5;
CONSTANTS(:,7) = 2.45;
CONSTANTS(:,8) = 2.5;
CONSTANTS(:,9) = 137;
CONSTANTS(:,10) = 7;
CONSTANTS(:,11) = 134;
CONSTANTS(:,12) = 0.025;
CONSTANTS(:,13) = 1e-12;
CONSTANTS(:,14) = 0.7;
CONSTANTS(:,15) = 0.01;
STATES(:,1) = -67;
STATES(:,2) = 0.00000993087;
CONSTANTS(:,16) = 30;
CONSTANTS(:,17) = 120;
CONSTANTS(:,18) = 88;
STATES(:,3) = 0;
STATES(:,4) = 1;
STATES(:,5) = 1;
CONSTANTS(:,19) = 2;
CONSTANTS(:,20) = 0.088464;
STATES(:,6) = 0;
STATES(:,7) = 1;
CONSTANTS(:,21) = 3;
CONSTANTS(:,22) = 0.03;
STATES(:,8) = 0;
CONSTANTS(:,23) = 10.1;
CONSTANTS(:,24) = 23;
CONSTANTS(:,25) = 0.15;
STATES(:,9) = 0;
CONSTANTS(:,26) = 2.5;
STATES(:,10) = 0;
STATES(:,11) = 1;
CONSTANTS(:,27) = 6.3;
STATES(:,12) = 0;
STATES(:,13) = 1;
CONSTANTS(:,28) = 20;
STATES(:,14) = 0.0000902;
CONSTANTS(:,29) = 0.35;
STATES(:,15) = 0;
CONSTANTS(:,30) = 12.15;
CONSTANTS(:,31) = 1.056075;
CONSTANTS(:,32) = 0.001;
CONSTANTS(:,33) = 0.12871;
CONSTANTS(:,34) = 0.1;
CONSTANTS(:,35) = 0.01;
CONSTANTS(:,36) = 0.0003;
STATES(:,16) = 0.000136;
STATES(:,17) = 0.007299;
STATES(:,18) = 2.60093454;
STATES(:,19) = 0.0077282;
STATES(:,20) = 0.101476;
STATES(:,21) = 0.9397;
CONSTANTS(:,37) = 0.0006;
STATES(:,22) = 164.000044;
CONSTANTS(:,38) = -0.4;
CONSTANTS(:,39) = 0.006995;
CONSTANTS(:,40) = 1.35e18;
CONSTANTS(:,41) = 2.077e-18;
CONSTANTS(:,42) = 1.728e-9;
CONSTANTS(:,43) = 1.059e-26;
CONSTANTS(:,44) = 6.394e-10;
CONSTANTS(:,45) = 1.762e-13;
CONSTANTS(:,46) = 2.656e-19;
CONSTANTS(:,47) = 8.632e-27;
CONSTANTS(:,48) = 50;
CONSTANTS(:,49) = 0.85;
CONSTANTS(:,50) = 1.71e9;
CONSTANTS(:,51) = 20;
CONSTANTS(:,52) = 1.346e-8;
CONSTANTS(:,53) = 7.739e-7;
CONSTANTS(:,54) = 6.65e-15;
CONSTANTS(:,55) = 1.656e-5;
CONSTANTS(:,56) = 3.373e-7;
CONSTANTS(:,57) = 9.651e-14;
CONSTANTS(:,58) = 4.845e-19;
CONSTANTS(:,59) = 0.5;
CONSTANTS(:,60) = 0.00038;
CONSTANTS(:,61) = 2.8;
CONSTANTS(:,62) = 91;
CONSTANTS(:,63) = 9.4;
CONSTANTS(:,64) = 0.003;
CONSTANTS(:,65) = 0.006;
CONSTANTS(:,66) = 50;
CONSTANTS(:,67) = 0.5;
CONSTANTS(:,68) = 2.055;
CONSTANTS(:,69) = 1.66;
CONSTANTS(:,70) = 0.0249;
CONSTANTS(:,71) = 4;
CONSTANTS(:,72) = 2.83;
CONSTANTS(:,73) = 1.3;
CONSTANTS(:,74) = 2.66;
CONSTANTS(:,75) = 0.16;
CONSTANTS(:,76) = 0.00005;
CONSTANTS(:,77) = 15;
CONSTANTS(:,78) = 1.1;
CONSTANTS(:,79) = 2;
CONSTANTS(:,80) = 8.7;
CONSTANTS(:,81) = 2.7;
CONSTANTS(:,82) = 0.05125;
CONSTANTS(:,83) = 1.666667;
CONSTANTS(:,84) = 50000;
CONSTANTS(:,85) = 0.00025;
CONSTANTS(:,86) = 0.001;
CONSTANTS(:,87) = 0.0014;
CONSTANTS(:,88) = 4;
CONSTANTS(:,89) = 1.8333;
CONSTANTS(:,90) = 0.00042;
CONSTANTS(:,91) = 0.001;
CONSTANTS(:,92) = 5000;
CONSTANTS(:,93) = 0.05;
CONSTANTS(:,94) = 0.01;
CONSTANTS(:,95) = 0.4;
CONSTANTS(:,96) = 0.7;
CONSTANTS(:,97) = 0.0033333;
CONSTANTS(:,98) = 0.3333;
CONSTANTS(:,99) = 15;
CONSTANTS(:,100) = 0.037625;
CONSTANTS(:,101) = 1;
CONSTANTS(:,102) = 8;
CONSTANTS(:,103) = 12;
CONSTANTS(:,104) = 2;
CONSTANTS(:,105) = power(CONSTANTS(:,7), (CONSTANTS(:,1) - CONSTANTS(:,2))./10.0000);
CONSTANTS(:,106) = power(CONSTANTS(:,6), (CONSTANTS(:,1) - CONSTANTS(:,2))./10.0000);
CONSTANTS(:,107) = power(CONSTANTS(:,5), (CONSTANTS(:,1) - CONSTANTS(:,2))./10.0000);
CONSTANTS(:,108) =  1.10000.*(CONSTANTS(:,1) - CONSTANTS(:,2));
CONSTANTS(:,109) = CONSTANTS(:,3)./( CONSTANTS(:,4).*CONSTANTS(:,1));
CONSTANTS(:,110) = ( CONSTANTS(:,4).*CONSTANTS(:,1))./CONSTANTS(:,3);
CONSTANTS(:,111) =  CONSTANTS(:,13).*CONSTANTS(:,14);
CONSTANTS(:,112) =  CONSTANTS(:,107).*0.00100000;
CONSTANTS(:,113) =  CONSTANTS(:,107).*0.0860000;
CONSTANTS(:,114) =  CONSTANTS(:,107).*0.00200000;
CONSTANTS(:,115) =  CONSTANTS(:,107).*0.00600000;
CONSTANTS(:,116) =  CONSTANTS(:,107).*0.0400000;
CONSTANTS(:,117) =  CONSTANTS(:,110).*log(CONSTANTS(:,18)./CONSTANTS(:,11));
CONSTANTS(:,118) =  CONSTANTS(:,110).*log(CONSTANTS(:,10)./CONSTANTS(:,17));
CONSTANTS(:,119) =  CONSTANTS(:,110).*log(CONSTANTS(:,10)./CONSTANTS(:,17));
CONSTANTS(:,120) =  CONSTANTS(:,106).*0.00300000;
CONSTANTS(:,121) =  CONSTANTS(:,110).*log(CONSTANTS(:,10)./CONSTANTS(:,17));
CONSTANTS(:,122) =  CONSTANTS(:,106).*0.00500000;
CONSTANTS(:,123) =  CONSTANTS(:,106).*0.00500000;
CONSTANTS(:,124) =  CONSTANTS(:,110).*log(CONSTANTS(:,10)./CONSTANTS(:,17));
CONSTANTS(:,125) =  CONSTANTS(:,105).*0.00300000;
CONSTANTS(:,126) =  CONSTANTS(:,105).*0.00160000;
CONSTANTS(:,127) =  CONSTANTS(:,110).*log(CONSTANTS(:,9)./CONSTANTS(:,16));
CONSTANTS(:,128) =  CONSTANTS(:,110).*log((CONSTANTS(:,10)+ CONSTANTS(:,9).*CONSTANTS(:,31))./(CONSTANTS(:,17)+ CONSTANTS(:,16).*CONSTANTS(:,31)));
CONSTANTS(:,129) =  CONSTANTS(:,13).*CONSTANTS(:,33);
CONSTANTS(:,130) =  CONSTANTS(:,13).*CONSTANTS(:,32);
CONSTANTS(:,131) =  CONSTANTS(:,13).*CONSTANTS(:,34);
CONSTANTS(:,132) = CONSTANTS(:,100)./(1.00000+power(CONSTANTS(:,80)./CONSTANTS(:,101), CONSTANTS(:,81)));
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(:,21) = ( 1.00000.*(CONSTANTS(:,87) -  STATES(:,21).*(STATES(:,14)+CONSTANTS(:,87))))./CONSTANTS(:,88);
ALGEBRAIC(:,1) = 1.00000./(1.00000+exp((STATES(:,1)+17.0000)./ - 4.30000));
RATES(:,3) = (ALGEBRAIC(:,1) - STATES(:,3))./CONSTANTS(:,112);
ALGEBRAIC(:,2) = 1.00000./(1.00000+exp((STATES(:,1)+43.0000)./8.90000));
RATES(:,4) = (ALGEBRAIC(:,2) - STATES(:,4))./CONSTANTS(:,113);
ALGEBRAIC(:,3) = 1.00000 - 1.00000./(1.00000+exp(((STATES(:,2) - 0.000100000) - 0.000214000)./ - 1.31000e-05));
RATES(:,5) = (ALGEBRAIC(:,3) - STATES(:,5))./CONSTANTS(:,114);
ALGEBRAIC(:,4) = 1.00000./(1.00000+exp((STATES(:,1)+26.0000)./ - 6.00000));
RATES(:,6) = (ALGEBRAIC(:,4) - STATES(:,6))./CONSTANTS(:,115);
ALGEBRAIC(:,5) = 1.00000./(1.00000+exp((STATES(:,1)+66.0000)./6.00000));
RATES(:,7) = (ALGEBRAIC(:,5) - STATES(:,7))./CONSTANTS(:,116);
ALGEBRAIC(:,6) = 1.00000./(1.00000+power(0.000140000./STATES(:,2), 3.00000));
RATES(:,8) = (ALGEBRAIC(:,6) - STATES(:,8))./CONSTANTS(:,22);
ALGEBRAIC(:,7) = 0.200000+0.800000./(1.00000+exp((STATES(:,1)+20.0000)./ - 1.80000));
RATES(:,9) = (ALGEBRAIC(:,7) - STATES(:,9))./CONSTANTS(:,120);
ALGEBRAIC(:,8) = 1.00000./(1.00000+exp((STATES(:,1)+25.0000)./ - 7.70000));
RATES(:,10) = (ALGEBRAIC(:,8) - STATES(:,10))./CONSTANTS(:,122);
ALGEBRAIC(:,9) = 0.500000+0.500000./(1.00000+exp((STATES(:,1)+44.8000)./4.40000));
RATES(:,11) = (ALGEBRAIC(:,9) - STATES(:,11))./CONSTANTS(:,123);
ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,1)+47.0000)./ - 4.80000));
RATES(:,12) = (ALGEBRAIC(:,10) - STATES(:,12))./CONSTANTS(:,125);
ALGEBRAIC(:,11) = 1.00000./(1.00000+exp((STATES(:,1)+78.0000)./7.00000));
RATES(:,13) = (ALGEBRAIC(:,11) - STATES(:,13))./CONSTANTS(:,126);
ALGEBRAIC(:,12) = 1.00000./(1.00000+power(7.45000e-05./STATES(:,14),  - 85.0000));
RATES(:,15) = (ALGEBRAIC(:,12) - STATES(:,15))./CONSTANTS(:,29);
ALGEBRAIC(:,19) =  ( CONSTANTS(:,84).*power(CONSTANTS(:,37)./(CONSTANTS(:,37)+CONSTANTS(:,85)), 3.00000).*power(STATES(:,14)./(STATES(:,14)+CONSTANTS(:,86)), 3.00000).*power(STATES(:,21), 3.00000)+CONSTANTS(:,83)).*(STATES(:,17) - STATES(:,14));
ALGEBRAIC(:,21) = ( CONSTANTS(:,89).*power(STATES(:,14), 2.00000))./(power(CONSTANTS(:,90), 2.00000)+power(STATES(:,14), 2.00000));
RATES(:,17) =  CONSTANTS(:,35).*(ALGEBRAIC(:,21) - ALGEBRAIC(:,19));
ALGEBRAIC(:,23) = ( (( CONSTANTS(:,91).*STATES(:,14))./CONSTANTS(:,65)).*power(1.00000+STATES(:,14)./CONSTANTS(:,65), 3.00000))./(power(1.00000+STATES(:,14)./CONSTANTS(:,65), 4.00000)+CONSTANTS(:,66)./power(1.00000+STATES(:,14)./CONSTANTS(:,60), CONSTANTS(:,61)));
ALGEBRAIC(:,24) = ( CONSTANTS(:,92).*(ALGEBRAIC(:,23) -  STATES(:,16).*exp(  - 2.00000.*CONSTANTS(:,109).*(STATES(:,22) - CONSTANTS(:,62)))).*2.00000.*CONSTANTS(:,109).*(STATES(:,22) - CONSTANTS(:,62)))./(1.00000 - exp(  - 2.00000.*CONSTANTS(:,109).*(STATES(:,22) - CONSTANTS(:,62))));
ALGEBRAIC(:,26) = ( CONSTANTS(:,93).*exp( CONSTANTS(:,67).*CONSTANTS(:,109).*(STATES(:,22) - CONSTANTS(:,62))))./( (1.00000+power(CONSTANTS(:,63)./CONSTANTS(:,16), CONSTANTS(:,79))).*(1.00000+CONSTANTS(:,64)./STATES(:,16)));
RATES(:,16) =  CONSTANTS(:,36).*(ALGEBRAIC(:,24) - ALGEBRAIC(:,26));
ALGEBRAIC(:,29) =  CONSTANTS(:,94).*(STATES(:,14) - STATES(:,2));
ALGEBRAIC(:,13) =  0.500000.*CONSTANTS(:,110).*log(CONSTANTS(:,8)./STATES(:,2));
ALGEBRAIC(:,14) =  CONSTANTS(:,19).*STATES(:,4).*STATES(:,3).*STATES(:,5).*(STATES(:,1) - ALGEBRAIC(:,13));
ALGEBRAIC(:,16) =  0.500000.*CONSTANTS(:,110).*log(CONSTANTS(:,8)./STATES(:,2));
ALGEBRAIC(:,17) =  CONSTANTS(:,21).*STATES(:,7).*STATES(:,6).*(STATES(:,1) - ALGEBRAIC(:,16));
ALGEBRAIC(:,15) = ( CONSTANTS(:,20).*1.00000)./(1.00000+0.000298000./STATES(:,2));
RATES(:,2) =  CONSTANTS(:,15).*((  - 1.00000.*ALGEBRAIC(:,14)+  - 1.00000.*ALGEBRAIC(:,17))./( 2.00000.*1.00000e+06.*1.00000e+06.*CONSTANTS(:,3).*CONSTANTS(:,111))+ALGEBRAIC(:,29)+  - 1.00000.*ALGEBRAIC(:,15));
RATES(:,14) =  CONSTANTS(:,15).*(( (ALGEBRAIC(:,26) - ALGEBRAIC(:,24)).*CONSTANTS(:,129))./CONSTANTS(:,130)+( (ALGEBRAIC(:,19) - ALGEBRAIC(:,21)).*CONSTANTS(:,131))./CONSTANTS(:,130)+(  - 1.00000.*ALGEBRAIC(:,29).*CONSTANTS(:,111))./CONSTANTS(:,130));
ALGEBRAIC(:,32) =  CONSTANTS(:,28).*STATES(:,13).*STATES(:,12).*(STATES(:,1) - CONSTANTS(:,127));
ALGEBRAIC(:,30) =  CONSTANTS(:,27).*STATES(:,11).*STATES(:,10).*(STATES(:,1) - CONSTANTS(:,124));
ALGEBRAIC(:,20) = 1.00000./(1.00000+exp(STATES(:,1)./ - 17.0000 -  2.00000.*log(STATES(:,2)./0.00100000)));
ALGEBRAIC(:,22) =  (CONSTANTS(:,24)+CONSTANTS(:,108)).*ALGEBRAIC(:,20).*(STATES(:,1) - CONSTANTS(:,118));
ALGEBRAIC(:,27) =  CONSTANTS(:,26).*STATES(:,9).*(STATES(:,1) - CONSTANTS(:,121));
ALGEBRAIC(:,18) =  CONSTANTS(:,23).*STATES(:,8).*(STATES(:,1) - CONSTANTS(:,117));
ALGEBRAIC(:,34) =  CONSTANTS(:,30).*STATES(:,15).*(STATES(:,1) - CONSTANTS(:,128));
ALGEBRAIC(:,25) =  CONSTANTS(:,25).*(STATES(:,1) - CONSTANTS(:,119));
RATES(:,1) =  ((  - 1.00000.*1.00000)./CONSTANTS(:,12)).*(ALGEBRAIC(:,32)+ALGEBRAIC(:,14)+ALGEBRAIC(:,17)+ALGEBRAIC(:,30)+ALGEBRAIC(:,27)+ALGEBRAIC(:,22)+ALGEBRAIC(:,18)+ALGEBRAIC(:,34)+ALGEBRAIC(:,25)+ ALGEBRAIC(:,15).*2.00000.*1.00000e+06.*1.00000e+06.*CONSTANTS(:,3).*CONSTANTS(:,111));
ALGEBRAIC(:,46) = CONSTANTS(:,104) - STATES(:,19);
ALGEBRAIC(:,47) = ( CONSTANTS(:,68).*(1.00000+ CONSTANTS(:,69).*CONSTANTS(:,101)).*CONSTANTS(:,70).*CONSTANTS(:,101).*ALGEBRAIC(:,46))./(1.00000+ CONSTANTS(:,71).*ALGEBRAIC(:,46)+ (1.00000+ CONSTANTS(:,72).*ALGEBRAIC(:,46)).*CONSTANTS(:,73).*CONSTANTS(:,101)+ (1.00000+ CONSTANTS(:,74).*ALGEBRAIC(:,46)).*CONSTANTS(:,75).*CONSTANTS(:,101));
ALGEBRAIC(:,28) = 1.00000./(1.00000+ CONSTANTS(:,78).*(1.00000+CONSTANTS(:,77)./power(1.00000+STATES(:,16)./CONSTANTS(:,76), 2.00000)));
ALGEBRAIC(:,49) = CONSTANTS(:,98)+ 6.39440.*ALGEBRAIC(:,28).*ALGEBRAIC(:,47);
ALGEBRAIC(:,35) = CONSTANTS(:,102) - STATES(:,20);
ALGEBRAIC(:,36) =  CONSTANTS(:,110).*log(( CONSTANTS(:,40).*power(STATES(:,20), 1.0 ./ 2))./power(ALGEBRAIC(:,35), 1.0 ./ 2));
ALGEBRAIC(:,37) = ( CONSTANTS(:,95).*0.500000.*( ( CONSTANTS(:,44).*power(10.0000,  6.00000.*CONSTANTS(:,38))+ CONSTANTS(:,46).*exp( 6.00000.*CONSTANTS(:,48).*CONSTANTS(:,109))).*exp( ALGEBRAIC(:,36).*CONSTANTS(:,109))+  - 1.00000.*CONSTANTS(:,44).*exp( CONSTANTS(:,49).*6.00000.*CONSTANTS(:,109).*STATES(:,22))+ CONSTANTS(:,47).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,36)).*exp( CONSTANTS(:,109).*STATES(:,22).*6.00000.*CONSTANTS(:,49))))./( (1.00000+ CONSTANTS(:,41).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,36))).*exp( CONSTANTS(:,109).*CONSTANTS(:,48).*6.00000)+ (CONSTANTS(:,42)+ CONSTANTS(:,43).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,36))).*exp( CONSTANTS(:,109).*STATES(:,22).*CONSTANTS(:,49).*6.00000));
RATES(:,20) = ALGEBRAIC(:,49) - ALGEBRAIC(:,37);
ALGEBRAIC(:,48) = CONSTANTS(:,98)./3.00000+ 0.840000.*ALGEBRAIC(:,28).*ALGEBRAIC(:,47);
ALGEBRAIC(:,39) = CONSTANTS(:,103) - STATES(:,18);
ALGEBRAIC(:,40) =  0.800000.*STATES(:,18);
ALGEBRAIC(:,41) =  CONSTANTS(:,110).*log(( CONSTANTS(:,50).*ALGEBRAIC(:,39))./( ALGEBRAIC(:,40).*CONSTANTS(:,51)));
ALGEBRAIC(:,42) = ( CONSTANTS(:,96).* - 1.00000.*( ( CONSTANTS(:,55).*power(10.0000,  3.00000.*CONSTANTS(:,38))+ CONSTANTS(:,57).*exp( 3.00000.*CONSTANTS(:,109).*CONSTANTS(:,48))).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41))+  - 1.00000.*CONSTANTS(:,55).*exp( 3.00000.*CONSTANTS(:,109).*STATES(:,22))+ CONSTANTS(:,58).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41)).*exp( 3.00000.*CONSTANTS(:,109).*STATES(:,22))))./( (1.00000+ CONSTANTS(:,52).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41))).*exp( 3.00000.*CONSTANTS(:,109).*CONSTANTS(:,48))+ (CONSTANTS(:,53)+ CONSTANTS(:,54).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41))).*exp( 3.00000.*CONSTANTS(:,109).*STATES(:,22)));
ALGEBRAIC(:,44) =  0.450000.*ALGEBRAIC(:,40);
ALGEBRAIC(:,45) =  0.0500000.*ALGEBRAIC(:,39);
ALGEBRAIC(:,52) =  0.300000.*STATES(:,19);
ALGEBRAIC(:,54) =  0.450000.*ALGEBRAIC(:,52);
ALGEBRAIC(:,55) =  0.0500000.*ALGEBRAIC(:,46);
ALGEBRAIC(:,56) = ( CONSTANTS(:,99).*(1.00000 -  (( ALGEBRAIC(:,55).*ALGEBRAIC(:,44))./( ALGEBRAIC(:,54).*ALGEBRAIC(:,45))).*exp(  - 1.00000.*CONSTANTS(:,109).*STATES(:,22))))./( (1.00000+ (ALGEBRAIC(:,55)./ALGEBRAIC(:,54)).*exp(  - 1.00000.*CONSTANTS(:,59).*CONSTANTS(:,109).*STATES(:,22))).*(1.00000+ALGEBRAIC(:,44)./ALGEBRAIC(:,45)));
RATES(:,18) = ALGEBRAIC(:,56)+  - 1.00000.*ALGEBRAIC(:,48)+  - 1.00000.*ALGEBRAIC(:,42);
ALGEBRAIC(:,50) =  0.150000.*ALGEBRAIC(:,47);
ALGEBRAIC(:,51) =  CONSTANTS(:,82).*ALGEBRAIC(:,46)+CONSTANTS(:,132);
RATES(:,19) = (  - 1.00000.*ALGEBRAIC(:,56).*CONSTANTS(:,129))./CONSTANTS(:,111)+ALGEBRAIC(:,51)+  - 1.00000.*ALGEBRAIC(:,50);
ALGEBRAIC(:,43) = (  - 1.00000.*CONSTANTS(:,96).*3.00000.*( CONSTANTS(:,55).*power(10.0000,  3.00000.*CONSTANTS(:,38)).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41))+ CONSTANTS(:,56).*power(10.0000,  3.00000.*CONSTANTS(:,38))+  - 1.00000.*(CONSTANTS(:,55)+CONSTANTS(:,56)).*exp( 3.00000.*CONSTANTS(:,109).*STATES(:,22))))./( (1.00000+ CONSTANTS(:,52).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41))).*exp( 3.00000.*CONSTANTS(:,109).*CONSTANTS(:,48))+ (CONSTANTS(:,53)+ CONSTANTS(:,54).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41))).*exp( 3.00000.*CONSTANTS(:,109).*STATES(:,22)));
ALGEBRAIC(:,38) = ( CONSTANTS(:,95).*3.96600.*( CONSTANTS(:,44).*power(10.0000,  6.00000.*CONSTANTS(:,38)).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,36))+ CONSTANTS(:,45).*power(10.0000,  6.00000.*CONSTANTS(:,38))+  - 1.00000.*(CONSTANTS(:,44)+CONSTANTS(:,45)).*exp( CONSTANTS(:,49).*CONSTANTS(:,109).*STATES(:,22).*6.00000)))./( (1.00000+ CONSTANTS(:,41).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,36))).*exp( 6.00000.*CONSTANTS(:,109).*CONSTANTS(:,48))+ (CONSTANTS(:,42)+ CONSTANTS(:,43).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,36))).*exp( CONSTANTS(:,49).*6.00000.*CONSTANTS(:,109).*STATES(:,22)));
ALGEBRAIC(:,31) = STATES(:,22) -  2.30300.*CONSTANTS(:,110).*CONSTANTS(:,38);
ALGEBRAIC(:,33) =  CONSTANTS(:,97).*ALGEBRAIC(:,31);
RATES(:,22) =  ((  - 1.00000.*CONSTANTS(:,3).*CONSTANTS(:,129).*1.00000e+06.*1.00000)./CONSTANTS(:,39)).*(ALGEBRAIC(:,33)+  - 1.00000.*ALGEBRAIC(:,38)+ALGEBRAIC(:,56)+ALGEBRAIC(:,43)+ 2.00000.*ALGEBRAIC(:,24));
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) = 1.00000./(1.00000+exp((STATES(:,1)+17.0000)./ - 4.30000));
ALGEBRAIC(:,2) = 1.00000./(1.00000+exp((STATES(:,1)+43.0000)./8.90000));
ALGEBRAIC(:,3) = 1.00000 - 1.00000./(1.00000+exp(((STATES(:,2) - 0.000100000) - 0.000214000)./ - 1.31000e-05));
ALGEBRAIC(:,4) = 1.00000./(1.00000+exp((STATES(:,1)+26.0000)./ - 6.00000));
ALGEBRAIC(:,5) = 1.00000./(1.00000+exp((STATES(:,1)+66.0000)./6.00000));
ALGEBRAIC(:,6) = 1.00000./(1.00000+power(0.000140000./STATES(:,2), 3.00000));
ALGEBRAIC(:,7) = 0.200000+0.800000./(1.00000+exp((STATES(:,1)+20.0000)./ - 1.80000));
ALGEBRAIC(:,8) = 1.00000./(1.00000+exp((STATES(:,1)+25.0000)./ - 7.70000));
ALGEBRAIC(:,9) = 0.500000+0.500000./(1.00000+exp((STATES(:,1)+44.8000)./4.40000));
ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,1)+47.0000)./ - 4.80000));
ALGEBRAIC(:,11) = 1.00000./(1.00000+exp((STATES(:,1)+78.0000)./7.00000));
ALGEBRAIC(:,12) = 1.00000./(1.00000+power(7.45000e-05./STATES(:,14),  - 85.0000));
ALGEBRAIC(:,19) =  ( CONSTANTS(:,84).*power(CONSTANTS(:,37)./(CONSTANTS(:,37)+CONSTANTS(:,85)), 3.00000).*power(STATES(:,14)./(STATES(:,14)+CONSTANTS(:,86)), 3.00000).*power(STATES(:,21), 3.00000)+CONSTANTS(:,83)).*(STATES(:,17) - STATES(:,14));
ALGEBRAIC(:,21) = ( CONSTANTS(:,89).*power(STATES(:,14), 2.00000))./(power(CONSTANTS(:,90), 2.00000)+power(STATES(:,14), 2.00000));
ALGEBRAIC(:,23) = ( (( CONSTANTS(:,91).*STATES(:,14))./CONSTANTS(:,65)).*power(1.00000+STATES(:,14)./CONSTANTS(:,65), 3.00000))./(power(1.00000+STATES(:,14)./CONSTANTS(:,65), 4.00000)+CONSTANTS(:,66)./power(1.00000+STATES(:,14)./CONSTANTS(:,60), CONSTANTS(:,61)));
ALGEBRAIC(:,24) = ( CONSTANTS(:,92).*(ALGEBRAIC(:,23) -  STATES(:,16).*exp(  - 2.00000.*CONSTANTS(:,109).*(STATES(:,22) - CONSTANTS(:,62)))).*2.00000.*CONSTANTS(:,109).*(STATES(:,22) - CONSTANTS(:,62)))./(1.00000 - exp(  - 2.00000.*CONSTANTS(:,109).*(STATES(:,22) - CONSTANTS(:,62))));
ALGEBRAIC(:,26) = ( CONSTANTS(:,93).*exp( CONSTANTS(:,67).*CONSTANTS(:,109).*(STATES(:,22) - CONSTANTS(:,62))))./( (1.00000+power(CONSTANTS(:,63)./CONSTANTS(:,16), CONSTANTS(:,79))).*(1.00000+CONSTANTS(:,64)./STATES(:,16)));
ALGEBRAIC(:,29) =  CONSTANTS(:,94).*(STATES(:,14) - STATES(:,2));
ALGEBRAIC(:,13) =  0.500000.*CONSTANTS(:,110).*log(CONSTANTS(:,8)./STATES(:,2));
ALGEBRAIC(:,14) =  CONSTANTS(:,19).*STATES(:,4).*STATES(:,3).*STATES(:,5).*(STATES(:,1) - ALGEBRAIC(:,13));
ALGEBRAIC(:,16) =  0.500000.*CONSTANTS(:,110).*log(CONSTANTS(:,8)./STATES(:,2));
ALGEBRAIC(:,17) =  CONSTANTS(:,21).*STATES(:,7).*STATES(:,6).*(STATES(:,1) - ALGEBRAIC(:,16));
ALGEBRAIC(:,15) = ( CONSTANTS(:,20).*1.00000)./(1.00000+0.000298000./STATES(:,2));
ALGEBRAIC(:,32) =  CONSTANTS(:,28).*STATES(:,13).*STATES(:,12).*(STATES(:,1) - CONSTANTS(:,127));
ALGEBRAIC(:,30) =  CONSTANTS(:,27).*STATES(:,11).*STATES(:,10).*(STATES(:,1) - CONSTANTS(:,124));
ALGEBRAIC(:,20) = 1.00000./(1.00000+exp(STATES(:,1)./ - 17.0000 -  2.00000.*log(STATES(:,2)./0.00100000)));
ALGEBRAIC(:,22) =  (CONSTANTS(:,24)+CONSTANTS(:,108)).*ALGEBRAIC(:,20).*(STATES(:,1) - CONSTANTS(:,118));
ALGEBRAIC(:,27) =  CONSTANTS(:,26).*STATES(:,9).*(STATES(:,1) - CONSTANTS(:,121));
ALGEBRAIC(:,18) =  CONSTANTS(:,23).*STATES(:,8).*(STATES(:,1) - CONSTANTS(:,117));
ALGEBRAIC(:,34) =  CONSTANTS(:,30).*STATES(:,15).*(STATES(:,1) - CONSTANTS(:,128));
ALGEBRAIC(:,25) =  CONSTANTS(:,25).*(STATES(:,1) - CONSTANTS(:,119));
ALGEBRAIC(:,46) = CONSTANTS(:,104) - STATES(:,19);
ALGEBRAIC(:,47) = ( CONSTANTS(:,68).*(1.00000+ CONSTANTS(:,69).*CONSTANTS(:,101)).*CONSTANTS(:,70).*CONSTANTS(:,101).*ALGEBRAIC(:,46))./(1.00000+ CONSTANTS(:,71).*ALGEBRAIC(:,46)+ (1.00000+ CONSTANTS(:,72).*ALGEBRAIC(:,46)).*CONSTANTS(:,73).*CONSTANTS(:,101)+ (1.00000+ CONSTANTS(:,74).*ALGEBRAIC(:,46)).*CONSTANTS(:,75).*CONSTANTS(:,101));
ALGEBRAIC(:,28) = 1.00000./(1.00000+ CONSTANTS(:,78).*(1.00000+CONSTANTS(:,77)./power(1.00000+STATES(:,16)./CONSTANTS(:,76), 2.00000)));
ALGEBRAIC(:,49) = CONSTANTS(:,98)+ 6.39440.*ALGEBRAIC(:,28).*ALGEBRAIC(:,47);
ALGEBRAIC(:,35) = CONSTANTS(:,102) - STATES(:,20);
ALGEBRAIC(:,36) =  CONSTANTS(:,110).*log(( CONSTANTS(:,40).*power(STATES(:,20), 1.0 ./ 2))./power(ALGEBRAIC(:,35), 1.0 ./ 2));
ALGEBRAIC(:,37) = ( CONSTANTS(:,95).*0.500000.*( ( CONSTANTS(:,44).*power(10.0000,  6.00000.*CONSTANTS(:,38))+ CONSTANTS(:,46).*exp( 6.00000.*CONSTANTS(:,48).*CONSTANTS(:,109))).*exp( ALGEBRAIC(:,36).*CONSTANTS(:,109))+  - 1.00000.*CONSTANTS(:,44).*exp( CONSTANTS(:,49).*6.00000.*CONSTANTS(:,109).*STATES(:,22))+ CONSTANTS(:,47).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,36)).*exp( CONSTANTS(:,109).*STATES(:,22).*6.00000.*CONSTANTS(:,49))))./( (1.00000+ CONSTANTS(:,41).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,36))).*exp( CONSTANTS(:,109).*CONSTANTS(:,48).*6.00000)+ (CONSTANTS(:,42)+ CONSTANTS(:,43).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,36))).*exp( CONSTANTS(:,109).*STATES(:,22).*CONSTANTS(:,49).*6.00000));
ALGEBRAIC(:,48) = CONSTANTS(:,98)./3.00000+ 0.840000.*ALGEBRAIC(:,28).*ALGEBRAIC(:,47);
ALGEBRAIC(:,39) = CONSTANTS(:,103) - STATES(:,18);
ALGEBRAIC(:,40) =  0.800000.*STATES(:,18);
ALGEBRAIC(:,41) =  CONSTANTS(:,110).*log(( CONSTANTS(:,50).*ALGEBRAIC(:,39))./( ALGEBRAIC(:,40).*CONSTANTS(:,51)));
ALGEBRAIC(:,42) = ( CONSTANTS(:,96).* - 1.00000.*( ( CONSTANTS(:,55).*power(10.0000,  3.00000.*CONSTANTS(:,38))+ CONSTANTS(:,57).*exp( 3.00000.*CONSTANTS(:,109).*CONSTANTS(:,48))).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41))+  - 1.00000.*CONSTANTS(:,55).*exp( 3.00000.*CONSTANTS(:,109).*STATES(:,22))+ CONSTANTS(:,58).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41)).*exp( 3.00000.*CONSTANTS(:,109).*STATES(:,22))))./( (1.00000+ CONSTANTS(:,52).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41))).*exp( 3.00000.*CONSTANTS(:,109).*CONSTANTS(:,48))+ (CONSTANTS(:,53)+ CONSTANTS(:,54).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41))).*exp( 3.00000.*CONSTANTS(:,109).*STATES(:,22)));
ALGEBRAIC(:,44) =  0.450000.*ALGEBRAIC(:,40);
ALGEBRAIC(:,45) =  0.0500000.*ALGEBRAIC(:,39);
ALGEBRAIC(:,52) =  0.300000.*STATES(:,19);
ALGEBRAIC(:,54) =  0.450000.*ALGEBRAIC(:,52);
ALGEBRAIC(:,55) =  0.0500000.*ALGEBRAIC(:,46);
ALGEBRAIC(:,56) = ( CONSTANTS(:,99).*(1.00000 -  (( ALGEBRAIC(:,55).*ALGEBRAIC(:,44))./( ALGEBRAIC(:,54).*ALGEBRAIC(:,45))).*exp(  - 1.00000.*CONSTANTS(:,109).*STATES(:,22))))./( (1.00000+ (ALGEBRAIC(:,55)./ALGEBRAIC(:,54)).*exp(  - 1.00000.*CONSTANTS(:,59).*CONSTANTS(:,109).*STATES(:,22))).*(1.00000+ALGEBRAIC(:,44)./ALGEBRAIC(:,45)));
ALGEBRAIC(:,50) =  0.150000.*ALGEBRAIC(:,47);
ALGEBRAIC(:,51) =  CONSTANTS(:,82).*ALGEBRAIC(:,46)+CONSTANTS(:,132);
ALGEBRAIC(:,43) = (  - 1.00000.*CONSTANTS(:,96).*3.00000.*( CONSTANTS(:,55).*power(10.0000,  3.00000.*CONSTANTS(:,38)).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41))+ CONSTANTS(:,56).*power(10.0000,  3.00000.*CONSTANTS(:,38))+  - 1.00000.*(CONSTANTS(:,55)+CONSTANTS(:,56)).*exp( 3.00000.*CONSTANTS(:,109).*STATES(:,22))))./( (1.00000+ CONSTANTS(:,52).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41))).*exp( 3.00000.*CONSTANTS(:,109).*CONSTANTS(:,48))+ (CONSTANTS(:,53)+ CONSTANTS(:,54).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,41))).*exp( 3.00000.*CONSTANTS(:,109).*STATES(:,22)));
ALGEBRAIC(:,38) = ( CONSTANTS(:,95).*3.96600.*( CONSTANTS(:,44).*power(10.0000,  6.00000.*CONSTANTS(:,38)).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,36))+ CONSTANTS(:,45).*power(10.0000,  6.00000.*CONSTANTS(:,38))+  - 1.00000.*(CONSTANTS(:,44)+CONSTANTS(:,45)).*exp( CONSTANTS(:,49).*CONSTANTS(:,109).*STATES(:,22).*6.00000)))./( (1.00000+ CONSTANTS(:,41).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,36))).*exp( 6.00000.*CONSTANTS(:,109).*CONSTANTS(:,48))+ (CONSTANTS(:,42)+ CONSTANTS(:,43).*exp( CONSTANTS(:,109).*ALGEBRAIC(:,36))).*exp( CONSTANTS(:,49).*6.00000.*CONSTANTS(:,109).*STATES(:,22)));
ALGEBRAIC(:,31) = STATES(:,22) -  2.30300.*CONSTANTS(:,110).*CONSTANTS(:,38);
ALGEBRAIC(:,33) =  CONSTANTS(:,97).*ALGEBRAIC(:,31);
ALGEBRAIC(:,53) =  0.550000.*ALGEBRAIC(:,52);
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 Corrias, Buist, 2008 at changeset bcb099930f46.
Collaboration
To begin collaborating on this work, please use your git client and issue this command: