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 =67; end % There are a total of 17 entries in each of the rate and state variable arrays. % There are a total of 46 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 (millisecond)'); LEGEND_STATES(:,1) = strpad('V in component membrane (millivolt)'); LEGEND_CONSTANTS(:,1) = strpad('R in component membrane (joule_per_mole_kelvin)'); LEGEND_CONSTANTS(:,2) = strpad('T in component membrane (kelvin)'); LEGEND_CONSTANTS(:,3) = strpad('F in component membrane (coulomb_per_millimole)'); LEGEND_CONSTANTS(:,4) = strpad('Cm in component membrane (microF)'); LEGEND_CONSTANTS(:,5) = strpad('V_c in component membrane (micrometre3)'); LEGEND_ALGEBRAIC(:,51) = strpad('i_K1 in component inward_rectifier_potassium_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,58) = strpad('i_to in component transient_outward_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,52) = strpad('i_Kr in component rapid_time_dependent_potassium_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,53) = strpad('i_Ks in component slow_time_dependent_potassium_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,56) = strpad('i_CaL in component L_type_Ca_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,59) = strpad('i_NaK in component sodium_potassium_pump_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,54) = strpad('i_Na in component fast_sodium_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,55) = strpad('i_b_Na in component sodium_background_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,60) = strpad('i_NaCa in component sodium_calcium_exchanger_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,57) = strpad('i_b_Ca in component calcium_background_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,62) = strpad('i_p_K in component potassium_pump_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,61) = strpad('i_p_Ca in component calcium_pump_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,1) = strpad('i_Stim in component membrane (picoA_per_picoF)'); LEGEND_CONSTANTS(:,6) = strpad('stim_start in component membrane (millisecond)'); LEGEND_CONSTANTS(:,7) = strpad('stim_period in component membrane (millisecond)'); LEGEND_CONSTANTS(:,8) = strpad('stim_duration in component membrane (millisecond)'); LEGEND_CONSTANTS(:,9) = strpad('stim_amplitude in component membrane (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,14) = strpad('E_Na in component reversal_potentials (millivolt)'); LEGEND_ALGEBRAIC(:,27) = strpad('E_K in component reversal_potentials (millivolt)'); LEGEND_ALGEBRAIC(:,36) = strpad('E_Ks in component reversal_potentials (millivolt)'); LEGEND_ALGEBRAIC(:,45) = strpad('E_Ca in component reversal_potentials (millivolt)'); LEGEND_CONSTANTS(:,10) = strpad('P_kna in component reversal_potentials (dimensionless)'); LEGEND_CONSTANTS(:,11) = strpad('K_o in component potassium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,12) = strpad('Na_o in component sodium_dynamics (millimolar)'); LEGEND_STATES(:,2) = strpad('K_i in component potassium_dynamics (millimolar)'); LEGEND_STATES(:,3) = strpad('Na_i in component sodium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,13) = strpad('Ca_o in component calcium_dynamics (millimolar)'); LEGEND_STATES(:,4) = strpad('Ca_i in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,14) = strpad('g_K1 in component inward_rectifier_potassium_current (nanoS_per_picoF)'); LEGEND_ALGEBRAIC(:,50) = strpad('xK1_inf in component inward_rectifier_potassium_current (dimensionless)'); LEGEND_ALGEBRAIC(:,48) = strpad('alpha_K1 in component inward_rectifier_potassium_current (dimensionless)'); LEGEND_ALGEBRAIC(:,49) = strpad('beta_K1 in component inward_rectifier_potassium_current (dimensionless)'); LEGEND_CONSTANTS(:,15) = strpad('g_Kr in component rapid_time_dependent_potassium_current (nanoS_per_picoF)'); LEGEND_STATES(:,5) = strpad('Xr1 in component rapid_time_dependent_potassium_current_Xr1_gate (dimensionless)'); LEGEND_STATES(:,6) = strpad('Xr2 in component rapid_time_dependent_potassium_current_Xr2_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,2) = strpad('xr1_inf in component rapid_time_dependent_potassium_current_Xr1_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,15) = strpad('alpha_xr1 in component rapid_time_dependent_potassium_current_Xr1_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,28) = strpad('beta_xr1 in component rapid_time_dependent_potassium_current_Xr1_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,37) = strpad('tau_xr1 in component rapid_time_dependent_potassium_current_Xr1_gate (millisecond)'); LEGEND_ALGEBRAIC(:,3) = strpad('xr2_inf in component rapid_time_dependent_potassium_current_Xr2_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,16) = strpad('alpha_xr2 in component rapid_time_dependent_potassium_current_Xr2_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,29) = strpad('beta_xr2 in component rapid_time_dependent_potassium_current_Xr2_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,38) = strpad('tau_xr2 in component rapid_time_dependent_potassium_current_Xr2_gate (millisecond)'); LEGEND_CONSTANTS(:,16) = strpad('g_Ks in component slow_time_dependent_potassium_current (nanoS_per_picoF)'); LEGEND_STATES(:,7) = strpad('Xs in component slow_time_dependent_potassium_current_Xs_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,4) = strpad('xs_inf in component slow_time_dependent_potassium_current_Xs_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,17) = strpad('alpha_xs in component slow_time_dependent_potassium_current_Xs_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,30) = strpad('beta_xs in component slow_time_dependent_potassium_current_Xs_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,39) = strpad('tau_xs in component slow_time_dependent_potassium_current_Xs_gate (millisecond)'); LEGEND_CONSTANTS(:,17) = strpad('g_Na in component fast_sodium_current (nanoS_per_picoF)'); LEGEND_STATES(:,8) = strpad('m in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_STATES(:,9) = strpad('h in component fast_sodium_current_h_gate (dimensionless)'); LEGEND_STATES(:,10) = strpad('j in component fast_sodium_current_j_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,5) = strpad('m_inf in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,18) = strpad('alpha_m in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,31) = strpad('beta_m in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,40) = strpad('tau_m in component fast_sodium_current_m_gate (millisecond)'); LEGEND_ALGEBRAIC(:,6) = strpad('h_inf in component fast_sodium_current_h_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,19) = strpad('alpha_h in component fast_sodium_current_h_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,32) = strpad('beta_h in component fast_sodium_current_h_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,41) = strpad('tau_h in component fast_sodium_current_h_gate (millisecond)'); LEGEND_ALGEBRAIC(:,7) = strpad('j_inf in component fast_sodium_current_j_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,20) = strpad('alpha_j in component fast_sodium_current_j_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,33) = strpad('beta_j in component fast_sodium_current_j_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,42) = strpad('tau_j in component fast_sodium_current_j_gate (millisecond)'); LEGEND_CONSTANTS(:,18) = strpad('g_bna in component sodium_background_current (nanoS_per_picoF)'); LEGEND_CONSTANTS(:,19) = strpad('g_CaL in component L_type_Ca_current (litre_per_farad_second)'); LEGEND_STATES(:,11) = strpad('d in component L_type_Ca_current_d_gate (dimensionless)'); LEGEND_STATES(:,12) = strpad('f in component L_type_Ca_current_f_gate (dimensionless)'); LEGEND_STATES(:,13) = strpad('fCa in component L_type_Ca_current_fCa_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,8) = strpad('d_inf in component L_type_Ca_current_d_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,21) = strpad('alpha_d in component L_type_Ca_current_d_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,34) = strpad('beta_d in component L_type_Ca_current_d_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,43) = strpad('gamma_d in component L_type_Ca_current_d_gate (millisecond)'); LEGEND_ALGEBRAIC(:,46) = strpad('tau_d in component L_type_Ca_current_d_gate (millisecond)'); LEGEND_ALGEBRAIC(:,9) = strpad('f_inf in component L_type_Ca_current_f_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,22) = strpad('tau_f in component L_type_Ca_current_f_gate (millisecond)'); LEGEND_ALGEBRAIC(:,10) = strpad('alpha_fCa in component L_type_Ca_current_fCa_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,23) = strpad('beta_fCa in component L_type_Ca_current_fCa_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,35) = strpad('gama_fCa in component L_type_Ca_current_fCa_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,44) = strpad('fCa_inf in component L_type_Ca_current_fCa_gate (dimensionless)'); LEGEND_CONSTANTS(:,46) = strpad('tau_fCa in component L_type_Ca_current_fCa_gate (millisecond)'); LEGEND_ALGEBRAIC(:,47) = strpad('d_fCa in component L_type_Ca_current_fCa_gate (per_millisecond)'); LEGEND_CONSTANTS(:,20) = strpad('g_bca in component calcium_background_current (nanoS_per_picoF)'); LEGEND_CONSTANTS(:,21) = strpad('g_to in component transient_outward_current (nanoS_per_picoF)'); LEGEND_STATES(:,14) = strpad('s in component transient_outward_current_s_gate (dimensionless)'); LEGEND_STATES(:,15) = strpad('r in component transient_outward_current_r_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,11) = strpad('s_inf in component transient_outward_current_s_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,24) = strpad('tau_s in component transient_outward_current_s_gate (millisecond)'); LEGEND_ALGEBRAIC(:,12) = strpad('r_inf in component transient_outward_current_r_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,25) = strpad('tau_r in component transient_outward_current_r_gate (millisecond)'); LEGEND_CONSTANTS(:,22) = strpad('P_NaK in component sodium_potassium_pump_current (picoA_per_picoF)'); LEGEND_CONSTANTS(:,23) = strpad('K_mk in component sodium_potassium_pump_current (millimolar)'); LEGEND_CONSTANTS(:,24) = strpad('K_mNa in component sodium_potassium_pump_current (millimolar)'); LEGEND_CONSTANTS(:,25) = strpad('K_NaCa in component sodium_calcium_exchanger_current (picoA_per_picoF)'); LEGEND_CONSTANTS(:,26) = strpad('K_sat in component sodium_calcium_exchanger_current (dimensionless)'); LEGEND_CONSTANTS(:,27) = strpad('alpha in component sodium_calcium_exchanger_current (dimensionless)'); LEGEND_CONSTANTS(:,28) = strpad('gamma in component sodium_calcium_exchanger_current (dimensionless)'); LEGEND_CONSTANTS(:,29) = strpad('Km_Ca in component sodium_calcium_exchanger_current (millimolar)'); LEGEND_CONSTANTS(:,30) = strpad('Km_Nai in component sodium_calcium_exchanger_current (millimolar)'); LEGEND_CONSTANTS(:,31) = strpad('g_pCa in component calcium_pump_current (picoA_per_picoF)'); LEGEND_CONSTANTS(:,32) = strpad('K_pCa in component calcium_pump_current (millimolar)'); LEGEND_CONSTANTS(:,33) = strpad('g_pK in component potassium_pump_current (nanoS_per_picoF)'); LEGEND_STATES(:,16) = strpad('Ca_SR in component calcium_dynamics (millimolar)'); LEGEND_ALGEBRAIC(:,63) = strpad('i_rel in component calcium_dynamics (millimolar_per_millisecond)'); LEGEND_ALGEBRAIC(:,64) = strpad('i_up in component calcium_dynamics (millimolar_per_millisecond)'); LEGEND_ALGEBRAIC(:,65) = strpad('i_leak in component calcium_dynamics (millimolar_per_millisecond)'); LEGEND_STATES(:,17) = strpad('g in component calcium_dynamics (dimensionless)'); LEGEND_CONSTANTS(:,34) = strpad('tau_g in component calcium_dynamics (millisecond)'); LEGEND_ALGEBRAIC(:,13) = strpad('g_inf in component calcium_dynamics (dimensionless)'); LEGEND_CONSTANTS(:,35) = strpad('a_rel in component calcium_dynamics (millimolar_per_millisecond)'); LEGEND_CONSTANTS(:,36) = strpad('b_rel in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,37) = strpad('c_rel in component calcium_dynamics (millimolar_per_millisecond)'); LEGEND_CONSTANTS(:,38) = strpad('K_up in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,39) = strpad('V_leak in component calcium_dynamics (per_millisecond)'); LEGEND_CONSTANTS(:,40) = strpad('Vmax_up in component calcium_dynamics (millimolar_per_millisecond)'); LEGEND_ALGEBRAIC(:,66) = strpad('Ca_i_bufc in component calcium_dynamics (dimensionless)'); LEGEND_ALGEBRAIC(:,67) = strpad('Ca_sr_bufsr in component calcium_dynamics (dimensionless)'); LEGEND_CONSTANTS(:,41) = strpad('Buf_c in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,42) = strpad('K_buf_c in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,43) = strpad('Buf_sr in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,44) = strpad('K_buf_sr in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,45) = strpad('V_sr in component calcium_dynamics (micrometre3)'); LEGEND_ALGEBRAIC(:,26) = strpad('d_g in component calcium_dynamics (per_millisecond)'); LEGEND_RATES(:,1) = strpad('d/dt V in component membrane (millivolt)'); LEGEND_RATES(:,5) = strpad('d/dt Xr1 in component rapid_time_dependent_potassium_current_Xr1_gate (dimensionless)'); LEGEND_RATES(:,6) = strpad('d/dt Xr2 in component rapid_time_dependent_potassium_current_Xr2_gate (dimensionless)'); LEGEND_RATES(:,7) = strpad('d/dt Xs in component slow_time_dependent_potassium_current_Xs_gate (dimensionless)'); LEGEND_RATES(:,8) = strpad('d/dt m in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_RATES(:,9) = strpad('d/dt h in component fast_sodium_current_h_gate (dimensionless)'); LEGEND_RATES(:,10) = strpad('d/dt j in component fast_sodium_current_j_gate (dimensionless)'); LEGEND_RATES(:,11) = strpad('d/dt d in component L_type_Ca_current_d_gate (dimensionless)'); LEGEND_RATES(:,12) = strpad('d/dt f in component L_type_Ca_current_f_gate (dimensionless)'); LEGEND_RATES(:,13) = strpad('d/dt fCa in component L_type_Ca_current_fCa_gate (dimensionless)'); LEGEND_RATES(:,14) = strpad('d/dt s in component transient_outward_current_s_gate (dimensionless)'); LEGEND_RATES(:,15) = strpad('d/dt r in component transient_outward_current_r_gate (dimensionless)'); LEGEND_RATES(:,17) = strpad('d/dt g in component calcium_dynamics (dimensionless)'); LEGEND_RATES(:,4) = strpad('d/dt Ca_i in component calcium_dynamics (millimolar)'); LEGEND_RATES(:,16) = strpad('d/dt Ca_SR in component calcium_dynamics (millimolar)'); LEGEND_RATES(:,3) = strpad('d/dt Na_i in component sodium_dynamics (millimolar)'); LEGEND_RATES(:,2) = strpad('d/dt K_i in component potassium_dynamics (millimolar)'); 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) = -86.2; CONSTANTS(:,1) = 8314.472; CONSTANTS(:,2) = 310; CONSTANTS(:,3) = 96485.3415; CONSTANTS(:,4) = 0.185; CONSTANTS(:,5) = 0.016404; CONSTANTS(:,6) = 10; CONSTANTS(:,7) = 1000; CONSTANTS(:,8) = 1; CONSTANTS(:,9) = 52; CONSTANTS(:,10) = 0.03; CONSTANTS(:,11) = 5.4; CONSTANTS(:,12) = 140; STATES(:,2) = 138.3; STATES(:,3) = 11.6; CONSTANTS(:,13) = 2; STATES(:,4) = 0.0002; CONSTANTS(:,14) = 5.405; CONSTANTS(:,15) = 0.096; STATES(:,5) = 0; STATES(:,6) = 1; CONSTANTS(:,16) = 0.062; STATES(:,7) = 0; CONSTANTS(:,17) = 14.838; STATES(:,8) = 0; STATES(:,9) = 0.75; STATES(:,10) = 0.75; CONSTANTS(:,18) = 0.00029; CONSTANTS(:,19) = 0.000175; STATES(:,11) = 0; STATES(:,12) = 1; STATES(:,13) = 1; CONSTANTS(:,20) = 0.000592; CONSTANTS(:,21) = 0.294; STATES(:,14) = 1; STATES(:,15) = 0; CONSTANTS(:,22) = 1.362; CONSTANTS(:,23) = 1; CONSTANTS(:,24) = 40; CONSTANTS(:,25) = 1000; CONSTANTS(:,26) = 0.1; CONSTANTS(:,27) = 2.5; CONSTANTS(:,28) = 0.35; CONSTANTS(:,29) = 1.38; CONSTANTS(:,30) = 87.5; CONSTANTS(:,31) = 0.825; CONSTANTS(:,32) = 0.0005; CONSTANTS(:,33) = 0.0146; STATES(:,16) = 0.2; STATES(:,17) = 1; CONSTANTS(:,34) = 2; CONSTANTS(:,35) = 0.016464; CONSTANTS(:,36) = 0.25; CONSTANTS(:,37) = 0.008232; CONSTANTS(:,38) = 0.00025; CONSTANTS(:,39) = 8e-5; CONSTANTS(:,40) = 0.000425; CONSTANTS(:,41) = 0.15; CONSTANTS(:,42) = 0.001; CONSTANTS(:,43) = 10; CONSTANTS(:,44) = 0.3; CONSTANTS(:,45) = 0.001094; CONSTANTS(:,46) = 2.00000; if (isempty(STATES)), warning('Initial values for states not set');, end end function [RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS) global algebraicVariableCount; statesSize = size(STATES); statesColumnCount = statesSize(2); if ( statesColumnCount == 1) STATES = STATES'; ALGEBRAIC = zeros(1, algebraicVariableCount); utilOnes = 1; else statesRowCount = statesSize(1); ALGEBRAIC = zeros(statesRowCount, algebraicVariableCount); RATES = zeros(statesRowCount, statesColumnCount); utilOnes = ones(statesRowCount, 1); end ALGEBRAIC(:,9) = 1.00000./(1.00000+exp((STATES(:,1)+20.0000)./7.00000)); ALGEBRAIC(:,22) = 1125.00.*exp( - power(STATES(:,1)+27.0000, 2.00000)./240.000)+80.0000+165.000./(1.00000+exp((25.0000 - STATES(:,1))./10.0000)); RATES(:,12) = (ALGEBRAIC(:,9) - STATES(:,12))./ALGEBRAIC(:,22); ALGEBRAIC(:,11) = 1.00000./(1.00000+exp((STATES(:,1)+20.0000)./5.00000)); ALGEBRAIC(:,24) = 85.0000.*exp( - power(STATES(:,1)+45.0000, 2.00000)./320.000)+5.00000./(1.00000+exp((STATES(:,1) - 20.0000)./5.00000))+3.00000; RATES(:,14) = (ALGEBRAIC(:,11) - STATES(:,14))./ALGEBRAIC(:,24); ALGEBRAIC(:,12) = 1.00000./(1.00000+exp((20.0000 - STATES(:,1))./6.00000)); ALGEBRAIC(:,25) = 9.50000.*exp( - power(STATES(:,1)+40.0000, 2.00000)./1800.00)+0.800000; RATES(:,15) = (ALGEBRAIC(:,12) - STATES(:,15))./ALGEBRAIC(:,25); ALGEBRAIC(:,13) = piecewise({STATES(:,4)<0.000350000, 1.00000./(1.00000+power(STATES(:,4)./0.000350000, 6.00000)) }, 1.00000./(1.00000+power(STATES(:,4)./0.000350000, 16.0000))); ALGEBRAIC(:,26) = (ALGEBRAIC(:,13) - STATES(:,17))./CONSTANTS(:,34); RATES(:,17) = piecewise({ALGEBRAIC(:,13)>STATES(:,17)&STATES(:,1)> - 60.0000, 0.00000 }, ALGEBRAIC(:,26)); ALGEBRAIC(:,2) = 1.00000./(1.00000+exp(( - 26.0000 - STATES(:,1))./7.00000)); ALGEBRAIC(:,15) = 450.000./(1.00000+exp(( - 45.0000 - STATES(:,1))./10.0000)); ALGEBRAIC(:,28) = 6.00000./(1.00000+exp((STATES(:,1)+30.0000)./11.5000)); ALGEBRAIC(:,37) = 1.00000.*ALGEBRAIC(:,15).*ALGEBRAIC(:,28); RATES(:,5) = (ALGEBRAIC(:,2) - STATES(:,5))./ALGEBRAIC(:,37); ALGEBRAIC(:,3) = 1.00000./(1.00000+exp((STATES(:,1)+88.0000)./24.0000)); ALGEBRAIC(:,16) = 3.00000./(1.00000+exp(( - 60.0000 - STATES(:,1))./20.0000)); ALGEBRAIC(:,29) = 1.12000./(1.00000+exp((STATES(:,1) - 60.0000)./20.0000)); ALGEBRAIC(:,38) = 1.00000.*ALGEBRAIC(:,16).*ALGEBRAIC(:,29); RATES(:,6) = (ALGEBRAIC(:,3) - STATES(:,6))./ALGEBRAIC(:,38); ALGEBRAIC(:,4) = 1.00000./(1.00000+exp(( - 5.00000 - STATES(:,1))./14.0000)); ALGEBRAIC(:,17) = 1100.00./power((1.00000+exp(( - 10.0000 - STATES(:,1))./6.00000)), 1.0 ./ 2); ALGEBRAIC(:,30) = 1.00000./(1.00000+exp((STATES(:,1) - 60.0000)./20.0000)); ALGEBRAIC(:,39) = 1.00000.*ALGEBRAIC(:,17).*ALGEBRAIC(:,30); RATES(:,7) = (ALGEBRAIC(:,4) - STATES(:,7))./ALGEBRAIC(:,39); ALGEBRAIC(:,5) = 1.00000./power(1.00000+exp(( - 56.8600 - STATES(:,1))./9.03000), 2.00000); ALGEBRAIC(:,18) = 1.00000./(1.00000+exp(( - 60.0000 - STATES(:,1))./5.00000)); ALGEBRAIC(:,31) = 0.100000./(1.00000+exp((STATES(:,1)+35.0000)./5.00000))+0.100000./(1.00000+exp((STATES(:,1) - 50.0000)./200.000)); ALGEBRAIC(:,40) = 1.00000.*ALGEBRAIC(:,18).*ALGEBRAIC(:,31); RATES(:,8) = (ALGEBRAIC(:,5) - STATES(:,8))./ALGEBRAIC(:,40); ALGEBRAIC(:,6) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000); ALGEBRAIC(:,19) = piecewise({STATES(:,1)< - 40.0000, 0.0570000.*exp( - (STATES(:,1)+80.0000)./6.80000) }, 0.00000); ALGEBRAIC(:,32) = piecewise({STATES(:,1)< - 40.0000, 2.70000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.348500.*STATES(:,1)) }, 0.770000./( 0.130000.*(1.00000+exp((STATES(:,1)+10.6600)./ - 11.1000)))); ALGEBRAIC(:,41) = 1.00000./(ALGEBRAIC(:,19)+ALGEBRAIC(:,32)); RATES(:,9) = (ALGEBRAIC(:,6) - STATES(:,9))./ALGEBRAIC(:,41); ALGEBRAIC(:,7) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000); ALGEBRAIC(:,20) = piecewise({STATES(:,1)< - 40.0000, (( ( - 25428.0.*exp( 0.244400.*STATES(:,1)) - 6.94800e-06.*exp( - 0.0439100.*STATES(:,1))).*(STATES(:,1)+37.7800))./1.00000)./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300))) }, 0.00000); ALGEBRAIC(:,33) = piecewise({STATES(:,1)< - 40.0000, ( 0.0242400.*exp( - 0.0105200.*STATES(:,1)))./(1.00000+exp( - 0.137800.*(STATES(:,1)+40.1400))) }, ( 0.600000.*exp( 0.0570000.*STATES(:,1)))./(1.00000+exp( - 0.100000.*(STATES(:,1)+32.0000)))); ALGEBRAIC(:,42) = 1.00000./(ALGEBRAIC(:,20)+ALGEBRAIC(:,33)); RATES(:,10) = (ALGEBRAIC(:,7) - STATES(:,10))./ALGEBRAIC(:,42); ALGEBRAIC(:,8) = 1.00000./(1.00000+exp(( - 5.00000 - STATES(:,1))./7.50000)); ALGEBRAIC(:,21) = 1.40000./(1.00000+exp(( - 35.0000 - STATES(:,1))./13.0000))+0.250000; ALGEBRAIC(:,34) = 1.40000./(1.00000+exp((STATES(:,1)+5.00000)./5.00000)); ALGEBRAIC(:,43) = 1.00000./(1.00000+exp((50.0000 - STATES(:,1))./20.0000)); ALGEBRAIC(:,46) = 1.00000.*ALGEBRAIC(:,21).*ALGEBRAIC(:,34)+ALGEBRAIC(:,43); RATES(:,11) = (ALGEBRAIC(:,8) - STATES(:,11))./ALGEBRAIC(:,46); ALGEBRAIC(:,10) = 1.00000./(1.00000+power(STATES(:,4)./0.000325000, 8.00000)); ALGEBRAIC(:,23) = 0.100000./(1.00000+exp((STATES(:,4) - 0.000500000)./0.000100000)); ALGEBRAIC(:,35) = 0.200000./(1.00000+exp((STATES(:,4) - 0.000750000)./0.000800000)); ALGEBRAIC(:,44) = (ALGEBRAIC(:,10)+ALGEBRAIC(:,23)+ALGEBRAIC(:,35)+0.230000)./1.46000; ALGEBRAIC(:,47) = (ALGEBRAIC(:,44) - STATES(:,13))./CONSTANTS(:,46); RATES(:,13) = piecewise({ALGEBRAIC(:,44)>STATES(:,13)&STATES(:,1)> - 60.0000, 0.00000 }, ALGEBRAIC(:,47)); ALGEBRAIC(:,59) = (( (( CONSTANTS(:,22).*CONSTANTS(:,11))./(CONSTANTS(:,11)+CONSTANTS(:,23))).*STATES(:,3))./(STATES(:,3)+CONSTANTS(:,24)))./(1.00000+ 0.124500.*exp(( - 0.100000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))+ 0.0353000.*exp(( - STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,14) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,12)./STATES(:,3)); ALGEBRAIC(:,54) = CONSTANTS(:,17).*power(STATES(:,8), 3.00000).*STATES(:,9).*STATES(:,10).*(STATES(:,1) - ALGEBRAIC(:,14)); ALGEBRAIC(:,55) = CONSTANTS(:,18).*(STATES(:,1) - ALGEBRAIC(:,14)); ALGEBRAIC(:,60) = ( CONSTANTS(:,25).*( exp(( CONSTANTS(:,28).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,3), 3.00000).*CONSTANTS(:,13) - exp(( (CONSTANTS(:,28) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(CONSTANTS(:,12), 3.00000).*STATES(:,4).*CONSTANTS(:,27)))./( (power(CONSTANTS(:,30), 3.00000)+power(CONSTANTS(:,12), 3.00000)).*(CONSTANTS(:,29)+CONSTANTS(:,13)).*(1.00000+ CONSTANTS(:,26).*exp(( (CONSTANTS(:,28) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))); RATES(:,3) = ( - 1.00000.*(ALGEBRAIC(:,54)+ALGEBRAIC(:,55)+ 3.00000.*ALGEBRAIC(:,59)+ 3.00000.*ALGEBRAIC(:,60)).*CONSTANTS(:,4))./( 1.00000.*CONSTANTS(:,5).*CONSTANTS(:,3)); ALGEBRAIC(:,27) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,11)./STATES(:,2)); ALGEBRAIC(:,48) = 0.100000./(1.00000+exp( 0.0600000.*((STATES(:,1) - ALGEBRAIC(:,27)) - 200.000))); ALGEBRAIC(:,49) = ( 3.00000.*exp( 0.000200000.*((STATES(:,1) - ALGEBRAIC(:,27))+100.000))+exp( 0.100000.*((STATES(:,1) - ALGEBRAIC(:,27)) - 10.0000)))./(1.00000+exp( - 0.500000.*(STATES(:,1) - ALGEBRAIC(:,27)))); ALGEBRAIC(:,50) = ALGEBRAIC(:,48)./(ALGEBRAIC(:,48)+ALGEBRAIC(:,49)); ALGEBRAIC(:,51) = CONSTANTS(:,14).*ALGEBRAIC(:,50).*power((CONSTANTS(:,11)./5.40000), 1.0 ./ 2).*(STATES(:,1) - ALGEBRAIC(:,27)); ALGEBRAIC(:,58) = CONSTANTS(:,21).*STATES(:,15).*STATES(:,14).*(STATES(:,1) - ALGEBRAIC(:,27)); ALGEBRAIC(:,52) = CONSTANTS(:,15).*power((CONSTANTS(:,11)./5.40000), 1.0 ./ 2).*STATES(:,5).*STATES(:,6).*(STATES(:,1) - ALGEBRAIC(:,27)); ALGEBRAIC(:,36) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log((CONSTANTS(:,11)+ CONSTANTS(:,10).*CONSTANTS(:,12))./(STATES(:,2)+ CONSTANTS(:,10).*STATES(:,3))); ALGEBRAIC(:,53) = CONSTANTS(:,16).*power(STATES(:,7), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,36)); ALGEBRAIC(:,56) = ( (( CONSTANTS(:,19).*STATES(:,11).*STATES(:,12).*STATES(:,13).*4.00000.*STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( STATES(:,4).*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 0.341000.*CONSTANTS(:,13)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000); ALGEBRAIC(:,45) = (( 0.500000.*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,13)./STATES(:,4)); ALGEBRAIC(:,57) = CONSTANTS(:,20).*(STATES(:,1) - ALGEBRAIC(:,45)); ALGEBRAIC(:,62) = ( CONSTANTS(:,33).*(STATES(:,1) - ALGEBRAIC(:,27)))./(1.00000+exp((25.0000 - STATES(:,1))./5.98000)); ALGEBRAIC(:,61) = ( CONSTANTS(:,31).*STATES(:,4))./(STATES(:,4)+CONSTANTS(:,32)); ALGEBRAIC(:,1) = piecewise({VOI - floor(VOI./CONSTANTS(:,7)).*CONSTANTS(:,7)>=CONSTANTS(:,6)&VOI - floor(VOI./CONSTANTS(:,7)).*CONSTANTS(:,7)<=CONSTANTS(:,6)+CONSTANTS(:,8), - CONSTANTS(:,9) }, 0.00000); RATES(:,1) = ( - 1.00000./1.00000).*(ALGEBRAIC(:,51)+ALGEBRAIC(:,58)+ALGEBRAIC(:,52)+ALGEBRAIC(:,53)+ALGEBRAIC(:,56)+ALGEBRAIC(:,59)+ALGEBRAIC(:,54)+ALGEBRAIC(:,55)+ALGEBRAIC(:,60)+ALGEBRAIC(:,57)+ALGEBRAIC(:,62)+ALGEBRAIC(:,61)+ALGEBRAIC(:,1)); RATES(:,2) = ( - 1.00000.*((ALGEBRAIC(:,51)+ALGEBRAIC(:,58)+ALGEBRAIC(:,52)+ALGEBRAIC(:,53)+ALGEBRAIC(:,62)+ALGEBRAIC(:,1)) - 2.00000.*ALGEBRAIC(:,59)).*CONSTANTS(:,4))./( 1.00000.*CONSTANTS(:,5).*CONSTANTS(:,3)); ALGEBRAIC(:,63) = (( CONSTANTS(:,35).*power(STATES(:,16), 2.00000))./(power(CONSTANTS(:,36), 2.00000)+power(STATES(:,16), 2.00000))+CONSTANTS(:,37)).*STATES(:,11).*STATES(:,17); ALGEBRAIC(:,64) = CONSTANTS(:,40)./(1.00000+power(CONSTANTS(:,38), 2.00000)./power(STATES(:,4), 2.00000)); ALGEBRAIC(:,65) = CONSTANTS(:,39).*(STATES(:,16) - STATES(:,4)); ALGEBRAIC(:,66) = 1.00000./(1.00000+( CONSTANTS(:,41).*CONSTANTS(:,42))./power(STATES(:,4)+CONSTANTS(:,42), 2.00000)); RATES(:,4) = ALGEBRAIC(:,66).*(((ALGEBRAIC(:,65) - ALGEBRAIC(:,64))+ALGEBRAIC(:,63)) - (( 1.00000.*((ALGEBRAIC(:,56)+ALGEBRAIC(:,57)+ALGEBRAIC(:,61)) - 2.00000.*ALGEBRAIC(:,60)))./( 2.00000.*1.00000.*CONSTANTS(:,5).*CONSTANTS(:,3))).*CONSTANTS(:,4)); ALGEBRAIC(:,67) = 1.00000./(1.00000+( CONSTANTS(:,43).*CONSTANTS(:,44))./power(STATES(:,16)+CONSTANTS(:,44), 2.00000)); RATES(:,16) = (( ALGEBRAIC(:,67).*CONSTANTS(:,5))./CONSTANTS(:,45)).*(ALGEBRAIC(:,64) - (ALGEBRAIC(:,63)+ALGEBRAIC(:,65))); 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(:,9) = 1.00000./(1.00000+exp((STATES(:,1)+20.0000)./7.00000)); ALGEBRAIC(:,22) = 1125.00.*exp( - power(STATES(:,1)+27.0000, 2.00000)./240.000)+80.0000+165.000./(1.00000+exp((25.0000 - STATES(:,1))./10.0000)); ALGEBRAIC(:,11) = 1.00000./(1.00000+exp((STATES(:,1)+20.0000)./5.00000)); ALGEBRAIC(:,24) = 85.0000.*exp( - power(STATES(:,1)+45.0000, 2.00000)./320.000)+5.00000./(1.00000+exp((STATES(:,1) - 20.0000)./5.00000))+3.00000; ALGEBRAIC(:,12) = 1.00000./(1.00000+exp((20.0000 - STATES(:,1))./6.00000)); ALGEBRAIC(:,25) = 9.50000.*exp( - power(STATES(:,1)+40.0000, 2.00000)./1800.00)+0.800000; ALGEBRAIC(:,13) = piecewise({STATES(:,4)<0.000350000, 1.00000./(1.00000+power(STATES(:,4)./0.000350000, 6.00000)) }, 1.00000./(1.00000+power(STATES(:,4)./0.000350000, 16.0000))); ALGEBRAIC(:,26) = (ALGEBRAIC(:,13) - STATES(:,17))./CONSTANTS(:,34); ALGEBRAIC(:,2) = 1.00000./(1.00000+exp(( - 26.0000 - STATES(:,1))./7.00000)); ALGEBRAIC(:,15) = 450.000./(1.00000+exp(( - 45.0000 - STATES(:,1))./10.0000)); ALGEBRAIC(:,28) = 6.00000./(1.00000+exp((STATES(:,1)+30.0000)./11.5000)); ALGEBRAIC(:,37) = 1.00000.*ALGEBRAIC(:,15).*ALGEBRAIC(:,28); ALGEBRAIC(:,3) = 1.00000./(1.00000+exp((STATES(:,1)+88.0000)./24.0000)); ALGEBRAIC(:,16) = 3.00000./(1.00000+exp(( - 60.0000 - STATES(:,1))./20.0000)); ALGEBRAIC(:,29) = 1.12000./(1.00000+exp((STATES(:,1) - 60.0000)./20.0000)); ALGEBRAIC(:,38) = 1.00000.*ALGEBRAIC(:,16).*ALGEBRAIC(:,29); ALGEBRAIC(:,4) = 1.00000./(1.00000+exp(( - 5.00000 - STATES(:,1))./14.0000)); ALGEBRAIC(:,17) = 1100.00./power((1.00000+exp(( - 10.0000 - STATES(:,1))./6.00000)), 1.0 ./ 2); ALGEBRAIC(:,30) = 1.00000./(1.00000+exp((STATES(:,1) - 60.0000)./20.0000)); ALGEBRAIC(:,39) = 1.00000.*ALGEBRAIC(:,17).*ALGEBRAIC(:,30); ALGEBRAIC(:,5) = 1.00000./power(1.00000+exp(( - 56.8600 - STATES(:,1))./9.03000), 2.00000); ALGEBRAIC(:,18) = 1.00000./(1.00000+exp(( - 60.0000 - STATES(:,1))./5.00000)); ALGEBRAIC(:,31) = 0.100000./(1.00000+exp((STATES(:,1)+35.0000)./5.00000))+0.100000./(1.00000+exp((STATES(:,1) - 50.0000)./200.000)); ALGEBRAIC(:,40) = 1.00000.*ALGEBRAIC(:,18).*ALGEBRAIC(:,31); ALGEBRAIC(:,6) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000); ALGEBRAIC(:,19) = piecewise({STATES(:,1)< - 40.0000, 0.0570000.*exp( - (STATES(:,1)+80.0000)./6.80000) }, 0.00000); ALGEBRAIC(:,32) = piecewise({STATES(:,1)< - 40.0000, 2.70000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.348500.*STATES(:,1)) }, 0.770000./( 0.130000.*(1.00000+exp((STATES(:,1)+10.6600)./ - 11.1000)))); ALGEBRAIC(:,41) = 1.00000./(ALGEBRAIC(:,19)+ALGEBRAIC(:,32)); ALGEBRAIC(:,7) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000); ALGEBRAIC(:,20) = piecewise({STATES(:,1)< - 40.0000, (( ( - 25428.0.*exp( 0.244400.*STATES(:,1)) - 6.94800e-06.*exp( - 0.0439100.*STATES(:,1))).*(STATES(:,1)+37.7800))./1.00000)./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300))) }, 0.00000); ALGEBRAIC(:,33) = piecewise({STATES(:,1)< - 40.0000, ( 0.0242400.*exp( - 0.0105200.*STATES(:,1)))./(1.00000+exp( - 0.137800.*(STATES(:,1)+40.1400))) }, ( 0.600000.*exp( 0.0570000.*STATES(:,1)))./(1.00000+exp( - 0.100000.*(STATES(:,1)+32.0000)))); ALGEBRAIC(:,42) = 1.00000./(ALGEBRAIC(:,20)+ALGEBRAIC(:,33)); ALGEBRAIC(:,8) = 1.00000./(1.00000+exp(( - 5.00000 - STATES(:,1))./7.50000)); ALGEBRAIC(:,21) = 1.40000./(1.00000+exp(( - 35.0000 - STATES(:,1))./13.0000))+0.250000; ALGEBRAIC(:,34) = 1.40000./(1.00000+exp((STATES(:,1)+5.00000)./5.00000)); ALGEBRAIC(:,43) = 1.00000./(1.00000+exp((50.0000 - STATES(:,1))./20.0000)); ALGEBRAIC(:,46) = 1.00000.*ALGEBRAIC(:,21).*ALGEBRAIC(:,34)+ALGEBRAIC(:,43); ALGEBRAIC(:,10) = 1.00000./(1.00000+power(STATES(:,4)./0.000325000, 8.00000)); ALGEBRAIC(:,23) = 0.100000./(1.00000+exp((STATES(:,4) - 0.000500000)./0.000100000)); ALGEBRAIC(:,35) = 0.200000./(1.00000+exp((STATES(:,4) - 0.000750000)./0.000800000)); ALGEBRAIC(:,44) = (ALGEBRAIC(:,10)+ALGEBRAIC(:,23)+ALGEBRAIC(:,35)+0.230000)./1.46000; ALGEBRAIC(:,47) = (ALGEBRAIC(:,44) - STATES(:,13))./CONSTANTS(:,46); ALGEBRAIC(:,59) = (( (( CONSTANTS(:,22).*CONSTANTS(:,11))./(CONSTANTS(:,11)+CONSTANTS(:,23))).*STATES(:,3))./(STATES(:,3)+CONSTANTS(:,24)))./(1.00000+ 0.124500.*exp(( - 0.100000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))+ 0.0353000.*exp(( - STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))); ALGEBRAIC(:,14) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,12)./STATES(:,3)); ALGEBRAIC(:,54) = CONSTANTS(:,17).*power(STATES(:,8), 3.00000).*STATES(:,9).*STATES(:,10).*(STATES(:,1) - ALGEBRAIC(:,14)); ALGEBRAIC(:,55) = CONSTANTS(:,18).*(STATES(:,1) - ALGEBRAIC(:,14)); ALGEBRAIC(:,60) = ( CONSTANTS(:,25).*( exp(( CONSTANTS(:,28).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,3), 3.00000).*CONSTANTS(:,13) - exp(( (CONSTANTS(:,28) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(CONSTANTS(:,12), 3.00000).*STATES(:,4).*CONSTANTS(:,27)))./( (power(CONSTANTS(:,30), 3.00000)+power(CONSTANTS(:,12), 3.00000)).*(CONSTANTS(:,29)+CONSTANTS(:,13)).*(1.00000+ CONSTANTS(:,26).*exp(( (CONSTANTS(:,28) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))); ALGEBRAIC(:,27) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,11)./STATES(:,2)); ALGEBRAIC(:,48) = 0.100000./(1.00000+exp( 0.0600000.*((STATES(:,1) - ALGEBRAIC(:,27)) - 200.000))); ALGEBRAIC(:,49) = ( 3.00000.*exp( 0.000200000.*((STATES(:,1) - ALGEBRAIC(:,27))+100.000))+exp( 0.100000.*((STATES(:,1) - ALGEBRAIC(:,27)) - 10.0000)))./(1.00000+exp( - 0.500000.*(STATES(:,1) - ALGEBRAIC(:,27)))); ALGEBRAIC(:,50) = ALGEBRAIC(:,48)./(ALGEBRAIC(:,48)+ALGEBRAIC(:,49)); ALGEBRAIC(:,51) = CONSTANTS(:,14).*ALGEBRAIC(:,50).*power((CONSTANTS(:,11)./5.40000), 1.0 ./ 2).*(STATES(:,1) - ALGEBRAIC(:,27)); ALGEBRAIC(:,58) = CONSTANTS(:,21).*STATES(:,15).*STATES(:,14).*(STATES(:,1) - ALGEBRAIC(:,27)); ALGEBRAIC(:,52) = CONSTANTS(:,15).*power((CONSTANTS(:,11)./5.40000), 1.0 ./ 2).*STATES(:,5).*STATES(:,6).*(STATES(:,1) - ALGEBRAIC(:,27)); ALGEBRAIC(:,36) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log((CONSTANTS(:,11)+ CONSTANTS(:,10).*CONSTANTS(:,12))./(STATES(:,2)+ CONSTANTS(:,10).*STATES(:,3))); ALGEBRAIC(:,53) = CONSTANTS(:,16).*power(STATES(:,7), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,36)); ALGEBRAIC(:,56) = ( (( CONSTANTS(:,19).*STATES(:,11).*STATES(:,12).*STATES(:,13).*4.00000.*STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( STATES(:,4).*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 0.341000.*CONSTANTS(:,13)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000); ALGEBRAIC(:,45) = (( 0.500000.*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,13)./STATES(:,4)); ALGEBRAIC(:,57) = CONSTANTS(:,20).*(STATES(:,1) - ALGEBRAIC(:,45)); ALGEBRAIC(:,62) = ( CONSTANTS(:,33).*(STATES(:,1) - ALGEBRAIC(:,27)))./(1.00000+exp((25.0000 - STATES(:,1))./5.98000)); ALGEBRAIC(:,61) = ( CONSTANTS(:,31).*STATES(:,4))./(STATES(:,4)+CONSTANTS(:,32)); ALGEBRAIC(:,1) = piecewise({VOI - floor(VOI./CONSTANTS(:,7)).*CONSTANTS(:,7)>=CONSTANTS(:,6)&VOI - floor(VOI./CONSTANTS(:,7)).*CONSTANTS(:,7)<=CONSTANTS(:,6)+CONSTANTS(:,8), - CONSTANTS(:,9) }, 0.00000); ALGEBRAIC(:,63) = (( CONSTANTS(:,35).*power(STATES(:,16), 2.00000))./(power(CONSTANTS(:,36), 2.00000)+power(STATES(:,16), 2.00000))+CONSTANTS(:,37)).*STATES(:,11).*STATES(:,17); ALGEBRAIC(:,64) = CONSTANTS(:,40)./(1.00000+power(CONSTANTS(:,38), 2.00000)./power(STATES(:,4), 2.00000)); ALGEBRAIC(:,65) = CONSTANTS(:,39).*(STATES(:,16) - STATES(:,4)); ALGEBRAIC(:,66) = 1.00000./(1.00000+( CONSTANTS(:,41).*CONSTANTS(:,42))./power(STATES(:,4)+CONSTANTS(:,42), 2.00000)); ALGEBRAIC(:,67) = 1.00000./(1.00000+( CONSTANTS(:,43).*CONSTANTS(:,44))./power(STATES(:,16)+CONSTANTS(:,44), 2.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 function strout = strpad(strin) 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