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 =68; end % There are a total of 17 entries in each of the rate and state variable arrays. % There are a total of 47 entries in the constant variable array. % function [VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel() % Create ALGEBRAIC of correct size global algebraicVariableCount; algebraicVariableCount = getAlgebraicVariableCount(); % Initialise constants and state variables [INIT_STATES, CONSTANTS] = initConsts; % Set timespan to solve over tspan = [0, 10]; % Set numerical accuracy options for ODE solver options = odeset('RelTol', 1e-06, 'AbsTol', 1e-06, 'MaxStep', 1); % Solve model with ODE solver [VOI, STATES] = ode15s(@(VOI, STATES)computeRates(VOI, STATES, CONSTANTS), tspan, INIT_STATES, options); % Compute algebraic variables [RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS); ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI); % Plot state variables against variable of integration [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends(); figure(); plot(VOI, STATES); xlabel(LEGEND_VOI); l = legend(LEGEND_STATES); set(l,'Interpreter','none'); end function [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends() LEGEND_STATES = ''; LEGEND_ALGEBRAIC = ''; LEGEND_VOI = ''; LEGEND_CONSTANTS = ''; LEGEND_VOI = strpad('time in component environment (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_per_cm2)'); LEGEND_CONSTANTS(:,5) = strpad('V_c in component membrane (micrometre3)'); LEGEND_ALGEBRAIC(:,50) = strpad('i_K1 in component inward_rectifier_potassium_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,57) = strpad('i_to in component transient_outward_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,51) = strpad('i_Kr in component rapid_time_dependent_potassium_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,52) = strpad('i_Ks in component slow_time_dependent_potassium_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,55) = strpad('i_CaL in component L_type_Ca_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,58) = strpad('i_NaK in component sodium_potassium_pump_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,53) = strpad('i_Na in component fast_sodium_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,54) = strpad('i_b_Na in component sodium_background_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,59) = strpad('i_NaCa in component sodium_calcium_exchanger_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,56) = strpad('i_b_Ca in component calcium_background_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,61) = strpad('i_p_K in component potassium_pump_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,60) = strpad('i_p_Ca in component calcium_pump_current (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,65) = strpad('i_Stim in component membrane (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,63) = strpad('Istim in component stimulus_protocol (picoA_per_picoF)'); LEGEND_ALGEBRAIC(:,1) = strpad('E_Na in component reversal_potentials (millivolt)'); LEGEND_ALGEBRAIC(:,14) = strpad('E_K in component reversal_potentials (millivolt)'); LEGEND_ALGEBRAIC(:,27) = strpad('E_Ks in component reversal_potentials (millivolt)'); LEGEND_ALGEBRAIC(:,36) = strpad('E_Ca in component reversal_potentials (millivolt)'); LEGEND_CONSTANTS(:,6) = strpad('P_kna in component reversal_potentials (nanoA_per_millimolar)'); LEGEND_CONSTANTS(:,7) = strpad('K_o in component potassium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,8) = 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(:,9) = strpad('Ca_o in component calcium_dynamics (millimolar)'); LEGEND_STATES(:,4) = strpad('Ca_i in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,10) = strpad('g_K1 in component inward_rectifier_potassium_current (nanoS_per_picoF)'); LEGEND_ALGEBRAIC(:,49) = strpad('xK1_inf in component inward_rectifier_potassium_current (dimensionless)'); LEGEND_ALGEBRAIC(:,45) = strpad('alpha_K1 in component inward_rectifier_potassium_current (dimensionless)'); LEGEND_ALGEBRAIC(:,48) = strpad('beta_K1 in component inward_rectifier_potassium_current (dimensionless)'); LEGEND_CONSTANTS(:,11) = 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 (per_millisecond)'); LEGEND_ALGEBRAIC(:,28) = strpad('beta_xr1 in component rapid_time_dependent_potassium_current_Xr1_gate (per_millisecond)'); 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 (per_millisecond)'); LEGEND_ALGEBRAIC(:,29) = strpad('beta_xr2 in component rapid_time_dependent_potassium_current_Xr2_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,38) = strpad('tau_xr2 in component rapid_time_dependent_potassium_current_Xr2_gate (millisecond)'); LEGEND_CONSTANTS(:,12) = 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 (per_millisecond)'); LEGEND_ALGEBRAIC(:,30) = strpad('beta_xs in component slow_time_dependent_potassium_current_Xs_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,39) = strpad('tau_xs in component slow_time_dependent_potassium_current_Xs_gate (millisecond)'); LEGEND_CONSTANTS(:,13) = 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 (per_millisecond)'); LEGEND_ALGEBRAIC(:,31) = strpad('beta_m in component fast_sodium_current_m_gate (per_millisecond)'); 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(:,14) = strpad('g_bna in component sodium_background_current (nanoS_per_picoF)'); LEGEND_CONSTANTS(:,15) = strpad('g_CaL in component L_type_Ca_current (nanoS_per_picoF)'); 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 (per_millisecond)'); LEGEND_ALGEBRAIC(:,34) = strpad('beta_d in component L_type_Ca_current_d_gate (per_millisecond)'); LEGEND_ALGEBRAIC(:,43) = strpad('gamma_d in component L_type_Ca_current_d_gate (per_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(:,47) = 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 (dimensionless)'); LEGEND_CONSTANTS(:,16) = strpad('g_bca in component calcium_background_current (nanoS_per_picoF)'); LEGEND_CONSTANTS(:,17) = 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 (dimensionless)'); 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(:,18) = strpad('P_NaK in component sodium_potassium_pump_current (picoA_per_picoF)'); LEGEND_CONSTANTS(:,19) = strpad('K_mk in component sodium_potassium_pump_current (millimolar)'); LEGEND_CONSTANTS(:,20) = strpad('K_mNa in component sodium_potassium_pump_current (millimolar)'); LEGEND_CONSTANTS(:,21) = strpad('K_NaCa in component sodium_calcium_exchanger_current (picoA_per_picoF)'); LEGEND_CONSTANTS(:,22) = strpad('K_sat in component sodium_calcium_exchanger_current (dimensionless)'); LEGEND_CONSTANTS(:,23) = strpad('alpha in component sodium_calcium_exchanger_current (dimensionless)'); LEGEND_CONSTANTS(:,24) = strpad('gamma in component sodium_calcium_exchanger_current (dimensionless)'); LEGEND_CONSTANTS(:,25) = strpad('Km_Ca in component sodium_calcium_exchanger_current (millimolar)'); LEGEND_CONSTANTS(:,26) = strpad('Km_Nai in component sodium_calcium_exchanger_current (millimolar)'); LEGEND_CONSTANTS(:,27) = strpad('g_pCa in component calcium_pump_current (nanoS_per_picoF)'); LEGEND_CONSTANTS(:,28) = strpad('K_pCa in component calcium_pump_current (millimolar)'); LEGEND_CONSTANTS(:,29) = strpad('g_pK in component potassium_pump_current (nanoS_per_picoF)'); LEGEND_STATES(:,16) = strpad('Ca_SR in component calcium_dynamics (millimolar)'); LEGEND_ALGEBRAIC(:,62) = 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(:,66) = strpad('i_leak in component calcium_dynamics (millimolar_per_millisecond)'); LEGEND_STATES(:,17) = strpad('g in component calcium_dynamics (dimensionless)'); LEGEND_CONSTANTS(:,30) = strpad('tau_g in component calcium_dynamics (millisecond)'); LEGEND_ALGEBRAIC(:,13) = strpad('g_inf in component calcium_dynamics (dimensionless)'); LEGEND_CONSTANTS(:,31) = strpad('a_rel in component calcium_dynamics (millimolar_per_millisecond)'); LEGEND_CONSTANTS(:,32) = strpad('b_rel in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,33) = strpad('c_rel in component calcium_dynamics (millimolar_per_millisecond)'); LEGEND_CONSTANTS(:,34) = strpad('K_up in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,35) = strpad('V_leak in component calcium_dynamics (per_millisecond)'); LEGEND_CONSTANTS(:,36) = strpad('Vmax_up in component calcium_dynamics (millimolar_per_millisecond)'); LEGEND_ALGEBRAIC(:,67) = strpad('Ca_i_bufc in component calcium_dynamics (millimolar)'); LEGEND_ALGEBRAIC(:,68) = strpad('Ca_sr_bufsr in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,37) = strpad('Buf_c in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,38) = strpad('K_buf_c in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,39) = strpad('Buf_sr in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,40) = strpad('K_buf_sr in component calcium_dynamics (millimolar)'); LEGEND_CONSTANTS(:,41) = strpad('V_sr in component calcium_dynamics (micrometre3)'); LEGEND_ALGEBRAIC(:,26) = strpad('d_g in component calcium_dynamics (dimensionless)'); LEGEND_CONSTANTS(:,42) = strpad('IstimStart in component stimulus_protocol (millisecond)'); LEGEND_CONSTANTS(:,43) = strpad('IstimEnd in component stimulus_protocol (millisecond)'); LEGEND_CONSTANTS(:,44) = strpad('IstimAmplitude in component stimulus_protocol (picoA_per_picoF)'); LEGEND_CONSTANTS(:,45) = strpad('IstimPeriod in component stimulus_protocol (millisecond)'); LEGEND_CONSTANTS(:,46) = strpad('IstimPulseDuration in component stimulus_protocol (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) = 0.03; CONSTANTS(:,7) = 5.4; CONSTANTS(:,8) = 140; STATES(:,2) = 138.3; STATES(:,3) = 11.6; CONSTANTS(:,9) = 2; STATES(:,4) = 0.0002; CONSTANTS(:,10) = 5.405; CONSTANTS(:,11) = 0.096; STATES(:,5) = 0; STATES(:,6) = 1; CONSTANTS(:,12) = 0.245; STATES(:,7) = 0; CONSTANTS(:,13) = 14.838; STATES(:,8) = 0; STATES(:,9) = 0.75; STATES(:,10) = 0.75; CONSTANTS(:,14) = 0.00029; CONSTANTS(:,15) = 0.000175; STATES(:,11) = 0; STATES(:,12) = 1; STATES(:,13) = 1; CONSTANTS(:,16) = 0.000592; CONSTANTS(:,17) = 0.073; STATES(:,14) = 1; STATES(:,15) = 0; CONSTANTS(:,18) = 1.362; CONSTANTS(:,19) = 1; CONSTANTS(:,20) = 40; CONSTANTS(:,21) = 1000; CONSTANTS(:,22) = 0.1; CONSTANTS(:,23) = 2.5; CONSTANTS(:,24) = 0.35; CONSTANTS(:,25) = 1.38; CONSTANTS(:,26) = 87.5; CONSTANTS(:,27) = 0.825; CONSTANTS(:,28) = 0.0005; CONSTANTS(:,29) = 0.0146; STATES(:,16) = 0.2; STATES(:,17) = 1; CONSTANTS(:,30) = 2; CONSTANTS(:,31) = 0.016464; CONSTANTS(:,32) = 0.25; CONSTANTS(:,33) = 0.008232; CONSTANTS(:,34) = 0.00025; CONSTANTS(:,35) = 8e-5; CONSTANTS(:,36) = 0.000425; CONSTANTS(:,37) = 0.15; CONSTANTS(:,38) = 0.001; CONSTANTS(:,39) = 10; CONSTANTS(:,40) = 0.3; CONSTANTS(:,41) = 0.001094; CONSTANTS(:,42) = 100; CONSTANTS(:,43) = 50000; CONSTANTS(:,44) = -52; CONSTANTS(:,45) = 1000; CONSTANTS(:,46) = 1; CONSTANTS(:,47) = 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)+28.0000)./5.00000)); ALGEBRAIC(:,24) = 1000.00.*exp( - power(STATES(:,1)+67.0000, 2.00000)./1000.00)+8.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(:,30); RATES(:,17) = piecewise({ 0.0100000.*ALGEBRAIC(:,26)>0.00000&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) = 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) = 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) = 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) = 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+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) = 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(:,47); RATES(:,13) = piecewise({ 0.0100000.*ALGEBRAIC(:,47)>0.00000&STATES(:,1)> - 60.0000, 0.00000 }, ALGEBRAIC(:,47)); ALGEBRAIC(:,58) = (( (( CONSTANTS(:,18).*CONSTANTS(:,7))./(CONSTANTS(:,7)+CONSTANTS(:,19))).*STATES(:,3))./(STATES(:,3)+CONSTANTS(:,20)))./(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(:,1) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,8)./STATES(:,3)); ALGEBRAIC(:,53) = CONSTANTS(:,13).*power(STATES(:,8), 3.00000).*STATES(:,9).*STATES(:,10).*(STATES(:,1) - ALGEBRAIC(:,1)); ALGEBRAIC(:,54) = CONSTANTS(:,14).*(STATES(:,1) - ALGEBRAIC(:,1)); ALGEBRAIC(:,59) = ( CONSTANTS(:,21).*( exp(( CONSTANTS(:,24).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,3), 3.00000).*CONSTANTS(:,9) - exp(( (CONSTANTS(:,24) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(CONSTANTS(:,8), 3.00000).*STATES(:,4).*CONSTANTS(:,23)))./( (power(CONSTANTS(:,26), 3.00000)+power(CONSTANTS(:,8), 3.00000)).*(CONSTANTS(:,25)+CONSTANTS(:,9)).*(1.00000+ CONSTANTS(:,22).*exp(( (CONSTANTS(:,24) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))); RATES(:,3) = ( - (ALGEBRAIC(:,53)+ALGEBRAIC(:,54)+ 3.00000.*ALGEBRAIC(:,58)+ 3.00000.*ALGEBRAIC(:,59))./( CONSTANTS(:,5).*CONSTANTS(:,3))).*CONSTANTS(:,4); ALGEBRAIC(:,14) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,7)./STATES(:,2)); ALGEBRAIC(:,45) = 0.100000./(1.00000+exp( 0.0600000.*((STATES(:,1) - ALGEBRAIC(:,14)) - 200.000))); ALGEBRAIC(:,48) = ( 3.00000.*exp( 0.000200000.*((STATES(:,1) - ALGEBRAIC(:,14))+100.000))+exp( 0.100000.*((STATES(:,1) - ALGEBRAIC(:,14)) - 10.0000)))./(1.00000+exp( - 0.500000.*(STATES(:,1) - ALGEBRAIC(:,14)))); ALGEBRAIC(:,49) = ALGEBRAIC(:,45)./(ALGEBRAIC(:,45)+ALGEBRAIC(:,48)); ALGEBRAIC(:,50) = CONSTANTS(:,10).*ALGEBRAIC(:,49).*(STATES(:,1) - ALGEBRAIC(:,14)); ALGEBRAIC(:,57) = CONSTANTS(:,17).*STATES(:,15).*STATES(:,14).*(STATES(:,1) - ALGEBRAIC(:,14)); ALGEBRAIC(:,51) = CONSTANTS(:,11).*power((CONSTANTS(:,7)./5.40000), 1.0 ./ 2).*STATES(:,5).*STATES(:,6).*(STATES(:,1) - ALGEBRAIC(:,14)); ALGEBRAIC(:,27) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log((CONSTANTS(:,7)+ CONSTANTS(:,6).*CONSTANTS(:,8))./(STATES(:,2)+ CONSTANTS(:,6).*STATES(:,3))); ALGEBRAIC(:,52) = CONSTANTS(:,12).*power(STATES(:,7), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,27)); ALGEBRAIC(:,55) = ( (( CONSTANTS(:,15).*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(:,9)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000); ALGEBRAIC(:,36) = (( 0.500000.*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,9)./STATES(:,4)); ALGEBRAIC(:,56) = CONSTANTS(:,16).*(STATES(:,1) - ALGEBRAIC(:,36)); ALGEBRAIC(:,61) = ( CONSTANTS(:,29).*(STATES(:,1) - ALGEBRAIC(:,14)))./(1.00000+exp((25.0000 - STATES(:,1))./5.98000)); ALGEBRAIC(:,60) = ( CONSTANTS(:,27).*STATES(:,4))./(STATES(:,4)+CONSTANTS(:,28)); ALGEBRAIC(:,63) = piecewise({VOI>=CONSTANTS(:,42)&VOI<=CONSTANTS(:,43)&(VOI - CONSTANTS(:,42)) - floor((VOI - CONSTANTS(:,42))./CONSTANTS(:,45)).*CONSTANTS(:,45)<=CONSTANTS(:,46), CONSTANTS(:,44) }, 0.00000); ALGEBRAIC(:,65) = ALGEBRAIC(:,63); RATES(:,1) = ( - 1.00000./1.00000).*(ALGEBRAIC(:,50)+ALGEBRAIC(:,57)+ALGEBRAIC(:,51)+ALGEBRAIC(:,52)+ALGEBRAIC(:,55)+ALGEBRAIC(:,58)+ALGEBRAIC(:,53)+ALGEBRAIC(:,54)+ALGEBRAIC(:,59)+ALGEBRAIC(:,56)+ALGEBRAIC(:,61)+ALGEBRAIC(:,60)+ALGEBRAIC(:,65)); RATES(:,2) = ( - ((ALGEBRAIC(:,50)+ALGEBRAIC(:,57)+ALGEBRAIC(:,51)+ALGEBRAIC(:,52)+ALGEBRAIC(:,61)+ALGEBRAIC(:,65)) - 2.00000.*ALGEBRAIC(:,58))./( CONSTANTS(:,5).*CONSTANTS(:,3))).*CONSTANTS(:,4); ALGEBRAIC(:,62) = (( CONSTANTS(:,31).*power(STATES(:,16), 2.00000))./(power(CONSTANTS(:,32), 2.00000)+power(STATES(:,16), 2.00000))+CONSTANTS(:,33)).*STATES(:,11).*STATES(:,17); ALGEBRAIC(:,64) = CONSTANTS(:,36)./(1.00000+power(CONSTANTS(:,34), 2.00000)./power(STATES(:,4), 2.00000)); ALGEBRAIC(:,66) = CONSTANTS(:,35).*(STATES(:,16) - STATES(:,4)); ALGEBRAIC(:,67) = 1.00000./(1.00000+( CONSTANTS(:,37).*CONSTANTS(:,38))./power(STATES(:,4)+CONSTANTS(:,38), 2.00000)); RATES(:,4) = ALGEBRAIC(:,67).*(((ALGEBRAIC(:,66) - ALGEBRAIC(:,64))+ALGEBRAIC(:,62)) - (((ALGEBRAIC(:,55)+ALGEBRAIC(:,56)+ALGEBRAIC(:,60)) - 2.00000.*ALGEBRAIC(:,59))./( 2.00000.*CONSTANTS(:,5).*CONSTANTS(:,3))).*CONSTANTS(:,4)); ALGEBRAIC(:,68) = 1.00000./(1.00000+( CONSTANTS(:,39).*CONSTANTS(:,40))./power(STATES(:,16)+CONSTANTS(:,40), 2.00000)); RATES(:,16) = (( ALGEBRAIC(:,68).*CONSTANTS(:,5))./CONSTANTS(:,41)).*(ALGEBRAIC(:,64) - (ALGEBRAIC(:,62)+ALGEBRAIC(:,66))); 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)+28.0000)./5.00000)); ALGEBRAIC(:,24) = 1000.00.*exp( - power(STATES(:,1)+67.0000, 2.00000)./1000.00)+8.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(:,30); 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) = 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) = 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) = 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) = 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+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) = 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(:,47); ALGEBRAIC(:,58) = (( (( CONSTANTS(:,18).*CONSTANTS(:,7))./(CONSTANTS(:,7)+CONSTANTS(:,19))).*STATES(:,3))./(STATES(:,3)+CONSTANTS(:,20)))./(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(:,1) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,8)./STATES(:,3)); ALGEBRAIC(:,53) = CONSTANTS(:,13).*power(STATES(:,8), 3.00000).*STATES(:,9).*STATES(:,10).*(STATES(:,1) - ALGEBRAIC(:,1)); ALGEBRAIC(:,54) = CONSTANTS(:,14).*(STATES(:,1) - ALGEBRAIC(:,1)); ALGEBRAIC(:,59) = ( CONSTANTS(:,21).*( exp(( CONSTANTS(:,24).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,3), 3.00000).*CONSTANTS(:,9) - exp(( (CONSTANTS(:,24) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(CONSTANTS(:,8), 3.00000).*STATES(:,4).*CONSTANTS(:,23)))./( (power(CONSTANTS(:,26), 3.00000)+power(CONSTANTS(:,8), 3.00000)).*(CONSTANTS(:,25)+CONSTANTS(:,9)).*(1.00000+ CONSTANTS(:,22).*exp(( (CONSTANTS(:,24) - 1.00000).*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))); ALGEBRAIC(:,14) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,7)./STATES(:,2)); ALGEBRAIC(:,45) = 0.100000./(1.00000+exp( 0.0600000.*((STATES(:,1) - ALGEBRAIC(:,14)) - 200.000))); ALGEBRAIC(:,48) = ( 3.00000.*exp( 0.000200000.*((STATES(:,1) - ALGEBRAIC(:,14))+100.000))+exp( 0.100000.*((STATES(:,1) - ALGEBRAIC(:,14)) - 10.0000)))./(1.00000+exp( - 0.500000.*(STATES(:,1) - ALGEBRAIC(:,14)))); ALGEBRAIC(:,49) = ALGEBRAIC(:,45)./(ALGEBRAIC(:,45)+ALGEBRAIC(:,48)); ALGEBRAIC(:,50) = CONSTANTS(:,10).*ALGEBRAIC(:,49).*(STATES(:,1) - ALGEBRAIC(:,14)); ALGEBRAIC(:,57) = CONSTANTS(:,17).*STATES(:,15).*STATES(:,14).*(STATES(:,1) - ALGEBRAIC(:,14)); ALGEBRAIC(:,51) = CONSTANTS(:,11).*power((CONSTANTS(:,7)./5.40000), 1.0 ./ 2).*STATES(:,5).*STATES(:,6).*(STATES(:,1) - ALGEBRAIC(:,14)); ALGEBRAIC(:,27) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log((CONSTANTS(:,7)+ CONSTANTS(:,6).*CONSTANTS(:,8))./(STATES(:,2)+ CONSTANTS(:,6).*STATES(:,3))); ALGEBRAIC(:,52) = CONSTANTS(:,12).*power(STATES(:,7), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,27)); ALGEBRAIC(:,55) = ( (( CONSTANTS(:,15).*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(:,9)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000); ALGEBRAIC(:,36) = (( 0.500000.*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,9)./STATES(:,4)); ALGEBRAIC(:,56) = CONSTANTS(:,16).*(STATES(:,1) - ALGEBRAIC(:,36)); ALGEBRAIC(:,61) = ( CONSTANTS(:,29).*(STATES(:,1) - ALGEBRAIC(:,14)))./(1.00000+exp((25.0000 - STATES(:,1))./5.98000)); ALGEBRAIC(:,60) = ( CONSTANTS(:,27).*STATES(:,4))./(STATES(:,4)+CONSTANTS(:,28)); ALGEBRAIC(:,63) = piecewise({VOI>=CONSTANTS(:,42)&VOI<=CONSTANTS(:,43)&(VOI - CONSTANTS(:,42)) - floor((VOI - CONSTANTS(:,42))./CONSTANTS(:,45)).*CONSTANTS(:,45)<=CONSTANTS(:,46), CONSTANTS(:,44) }, 0.00000); ALGEBRAIC(:,65) = ALGEBRAIC(:,63); ALGEBRAIC(:,62) = (( CONSTANTS(:,31).*power(STATES(:,16), 2.00000))./(power(CONSTANTS(:,32), 2.00000)+power(STATES(:,16), 2.00000))+CONSTANTS(:,33)).*STATES(:,11).*STATES(:,17); ALGEBRAIC(:,64) = CONSTANTS(:,36)./(1.00000+power(CONSTANTS(:,34), 2.00000)./power(STATES(:,4), 2.00000)); ALGEBRAIC(:,66) = CONSTANTS(:,35).*(STATES(:,16) - STATES(:,4)); ALGEBRAIC(:,67) = 1.00000./(1.00000+( CONSTANTS(:,37).*CONSTANTS(:,38))./power(STATES(:,4)+CONSTANTS(:,38), 2.00000)); ALGEBRAIC(:,68) = 1.00000./(1.00000+( CONSTANTS(:,39).*CONSTANTS(:,40))./power(STATES(:,16)+CONSTANTS(:,40), 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