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 =58; end % There are a total of 12 entries in each of the rate and state variable arrays. % There are a total of 60 entries in the constant variable array. % function [VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel() % Create ALGEBRAIC of correct size global algebraicVariableCount; algebraicVariableCount = getAlgebraicVariableCount(); % Initialise constants and state variables [INIT_STATES, CONSTANTS] = initConsts; % Set timespan to solve over tspan = [0, 10]; % Set numerical accuracy options for ODE solver options = odeset('RelTol', 1e-06, 'AbsTol', 1e-06, 'MaxStep', 1); % Solve model with ODE solver [VOI, STATES] = ode15s(@(VOI, STATES)computeRates(VOI, STATES, CONSTANTS), tspan, INIT_STATES, options); % Compute algebraic variables [RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS); ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI); % Plot state variables against variable of integration [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends(); figure(); plot(VOI, STATES); xlabel(LEGEND_VOI); l = legend(LEGEND_STATES); set(l,'Interpreter','none'); end function [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends() LEGEND_STATES = ''; LEGEND_ALGEBRAIC = ''; LEGEND_VOI = ''; LEGEND_CONSTANTS = ''; LEGEND_VOI = strpad('time in component environment (ms)'); LEGEND_STATES(:,1) = strpad('V in component membrane (mV)'); LEGEND_CONSTANTS(:,1) = strpad('R in component membrane (gas_constant_units)'); LEGEND_CONSTANTS(:,2) = strpad('T in component membrane (kelvin)'); LEGEND_CONSTANTS(:,3) = strpad('F in component membrane (faradays_constant_units)'); LEGEND_ALGEBRAIC(:,54) = strpad('dV_dt in component membrane (mV_per_ms)'); LEGEND_CONSTANTS(:,4) = strpad('Cm in component membrane (uF_per_mm2)'); LEGEND_ALGEBRAIC(:,4) = strpad('I_st in component membrane (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,15) = strpad('i_Na in component fast_sodium_current (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,27) = strpad('i_Ca_L in component L_type_Ca_channel (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,30) = strpad('i_K in component time_dependent_potassium_current (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,53) = strpad('i_NaCa in component Na_Ca_exchanger (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,35) = strpad('i_K1 in component time_independent_potassium_current (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,38) = strpad('i_Kp in component plateau_potassium_current (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,39) = strpad('i_p_Ca in component sarcolemmal_calcium_pump (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,41) = strpad('i_Na_b in component sodium_background_current (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,43) = strpad('i_Ca_b in component calcium_background_current (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,45) = strpad('i_NaK in component sodium_potassium_pump (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,52) = strpad('i_ns_Ca in component non_specific_calcium_activated_current (uA_per_mm2)'); LEGEND_CONSTANTS(:,5) = strpad('stimPeriod in component membrane (dimensionless)'); LEGEND_CONSTANTS(:,6) = strpad('stimDuration in component membrane (dimensionless)'); LEGEND_CONSTANTS(:,7) = strpad('stimCurrent in component membrane (dimensionless)'); LEGEND_ALGEBRAIC(:,11) = strpad('E_Na in component fast_sodium_current (mV)'); LEGEND_CONSTANTS(:,8) = strpad('g_Na in component fast_sodium_current (mS_per_mm2)'); LEGEND_STATES(:,2) = strpad('Nai in component ionic_concentrations (mM)'); LEGEND_CONSTANTS(:,9) = strpad('Nao in component ionic_concentrations (mM)'); LEGEND_STATES(:,3) = strpad('m in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_STATES(:,4) = strpad('h in component fast_sodium_current_h_gate (dimensionless)'); LEGEND_STATES(:,5) = strpad('j in component fast_sodium_current_j_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,1) = strpad('alpha_m in component fast_sodium_current_m_gate (per_ms)'); LEGEND_ALGEBRAIC(:,8) = strpad('beta_m in component fast_sodium_current_m_gate (per_ms)'); LEGEND_ALGEBRAIC(:,2) = strpad('alpha_h in component fast_sodium_current_h_gate (per_ms)'); LEGEND_ALGEBRAIC(:,9) = strpad('beta_h in component fast_sodium_current_h_gate (per_ms)'); LEGEND_ALGEBRAIC(:,3) = strpad('alpha_j in component fast_sodium_current_j_gate (per_ms)'); LEGEND_ALGEBRAIC(:,10) = strpad('beta_j in component fast_sodium_current_j_gate (per_ms)'); LEGEND_ALGEBRAIC(:,24) = strpad('i_CaCa in component L_type_Ca_channel (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,26) = strpad('i_CaK in component L_type_Ca_channel (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,25) = strpad('i_CaNa in component L_type_Ca_channel (uA_per_mm2)'); LEGEND_CONSTANTS(:,10) = strpad('gamma_Nai in component L_type_Ca_channel (dimensionless)'); LEGEND_CONSTANTS(:,11) = strpad('gamma_Nao in component L_type_Ca_channel (dimensionless)'); LEGEND_CONSTANTS(:,12) = strpad('gamma_Ki in component L_type_Ca_channel (dimensionless)'); LEGEND_CONSTANTS(:,13) = strpad('gamma_Ko in component L_type_Ca_channel (dimensionless)'); LEGEND_ALGEBRAIC(:,18) = strpad('I_CaCa in component L_type_Ca_channel (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,22) = strpad('I_CaK in component L_type_Ca_channel (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,21) = strpad('I_CaNa in component L_type_Ca_channel (uA_per_mm2)'); LEGEND_CONSTANTS(:,14) = strpad('P_Ca in component L_type_Ca_channel (mm_per_ms)'); LEGEND_CONSTANTS(:,15) = strpad('P_Na in component L_type_Ca_channel (mm_per_ms)'); LEGEND_CONSTANTS(:,16) = strpad('P_K in component L_type_Ca_channel (mm_per_ms)'); LEGEND_CONSTANTS(:,17) = strpad('gamma_Cai in component L_type_Ca_channel (dimensionless)'); LEGEND_CONSTANTS(:,18) = strpad('gamma_Cao in component L_type_Ca_channel (dimensionless)'); LEGEND_STATES(:,6) = strpad('Cai in component ionic_concentrations (mM)'); LEGEND_CONSTANTS(:,19) = strpad('Cao in component ionic_concentrations (mM)'); LEGEND_CONSTANTS(:,20) = strpad('Ko in component ionic_concentrations (mM)'); LEGEND_STATES(:,7) = strpad('Ki in component ionic_concentrations (mM)'); LEGEND_STATES(:,8) = strpad('d in component L_type_Ca_channel_d_gate (dimensionless)'); LEGEND_STATES(:,9) = strpad('f in component L_type_Ca_channel_f_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,23) = strpad('f_Ca in component L_type_Ca_channel_f_Ca_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,16) = strpad('alpha_d in component L_type_Ca_channel_d_gate (per_ms)'); LEGEND_ALGEBRAIC(:,19) = strpad('beta_d in component L_type_Ca_channel_d_gate (per_ms)'); LEGEND_ALGEBRAIC(:,5) = strpad('d_infinity in component L_type_Ca_channel_d_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,12) = strpad('tau_d in component L_type_Ca_channel_d_gate (ms)'); LEGEND_ALGEBRAIC(:,17) = strpad('alpha_f in component L_type_Ca_channel_f_gate (per_ms)'); LEGEND_ALGEBRAIC(:,20) = strpad('beta_f in component L_type_Ca_channel_f_gate (per_ms)'); LEGEND_ALGEBRAIC(:,6) = strpad('f_infinity in component L_type_Ca_channel_f_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,13) = strpad('tau_f in component L_type_Ca_channel_f_gate (ms)'); LEGEND_CONSTANTS(:,21) = strpad('Km_Ca in component L_type_Ca_channel_f_Ca_gate (mM)'); LEGEND_CONSTANTS(:,22) = strpad('g_K_max in component time_dependent_potassium_current (mS_per_mm2)'); LEGEND_CONSTANTS(:,55) = strpad('g_K in component time_dependent_potassium_current (mS_per_mm2)'); LEGEND_ALGEBRAIC(:,28) = strpad('E_K in component time_dependent_potassium_current (mV)'); LEGEND_CONSTANTS(:,23) = strpad('PR_NaK in component time_dependent_potassium_current (dimensionless)'); LEGEND_STATES(:,10) = strpad('X in component time_dependent_potassium_current_X_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,29) = strpad('Xi in component time_dependent_potassium_current_Xi_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,7) = strpad('alpha_X in component time_dependent_potassium_current_X_gate (per_ms)'); LEGEND_ALGEBRAIC(:,14) = strpad('beta_X in component time_dependent_potassium_current_X_gate (per_ms)'); LEGEND_ALGEBRAIC(:,31) = strpad('E_K1 in component time_independent_potassium_current (mV)'); LEGEND_CONSTANTS(:,24) = strpad('g_K1_max in component time_independent_potassium_current (mS_per_mm2)'); LEGEND_CONSTANTS(:,56) = strpad('g_K1 in component time_independent_potassium_current (mS_per_mm2)'); LEGEND_ALGEBRAIC(:,34) = strpad('K1_infinity in component time_independent_potassium_current_K1_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,32) = strpad('alpha_K1 in component time_independent_potassium_current_K1_gate (per_ms)'); LEGEND_ALGEBRAIC(:,33) = strpad('beta_K1 in component time_independent_potassium_current_K1_gate (per_ms)'); LEGEND_ALGEBRAIC(:,36) = strpad('E_Kp in component plateau_potassium_current (mV)'); LEGEND_CONSTANTS(:,25) = strpad('g_Kp in component plateau_potassium_current (mS_per_mm2)'); LEGEND_ALGEBRAIC(:,37) = strpad('Kp in component plateau_potassium_current (dimensionless)'); LEGEND_CONSTANTS(:,26) = strpad('K_mpCa in component sarcolemmal_calcium_pump (mM)'); LEGEND_CONSTANTS(:,27) = strpad('I_pCa in component sarcolemmal_calcium_pump (uA_per_mm2)'); LEGEND_CONSTANTS(:,28) = strpad('g_Nab in component sodium_background_current (mS_per_mm2)'); LEGEND_ALGEBRAIC(:,40) = strpad('E_NaN in component sodium_background_current (mV)'); LEGEND_CONSTANTS(:,29) = strpad('g_Cab in component calcium_background_current (mS_per_mm2)'); LEGEND_ALGEBRAIC(:,42) = strpad('E_CaN in component calcium_background_current (mV)'); LEGEND_CONSTANTS(:,30) = strpad('I_NaK in component sodium_potassium_pump (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,44) = strpad('f_NaK in component sodium_potassium_pump (dimensionless)'); LEGEND_CONSTANTS(:,31) = strpad('K_mNai in component sodium_potassium_pump (mM)'); LEGEND_CONSTANTS(:,32) = strpad('K_mKo in component sodium_potassium_pump (mM)'); LEGEND_CONSTANTS(:,57) = strpad('sigma in component sodium_potassium_pump (dimensionless)'); LEGEND_ALGEBRAIC(:,49) = strpad('i_ns_Na in component non_specific_calcium_activated_current (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,51) = strpad('i_ns_K in component non_specific_calcium_activated_current (uA_per_mm2)'); LEGEND_CONSTANTS(:,33) = strpad('P_ns_Ca in component non_specific_calcium_activated_current (mm_per_ms)'); LEGEND_ALGEBRAIC(:,48) = strpad('I_ns_Na in component non_specific_calcium_activated_current (uA_per_mm2)'); LEGEND_ALGEBRAIC(:,50) = strpad('I_ns_K in component non_specific_calcium_activated_current (uA_per_mm2)'); LEGEND_CONSTANTS(:,34) = strpad('K_m_ns_Ca in component non_specific_calcium_activated_current (mM)'); LEGEND_ALGEBRAIC(:,47) = strpad('Vns in component non_specific_calcium_activated_current (mV)'); LEGEND_ALGEBRAIC(:,46) = strpad('EnsCa in component non_specific_calcium_activated_current (mV)'); LEGEND_CONSTANTS(:,35) = strpad('K_NaCa in component Na_Ca_exchanger (uA_per_mm2)'); LEGEND_CONSTANTS(:,36) = strpad('K_mNa in component Na_Ca_exchanger (mM)'); LEGEND_CONSTANTS(:,37) = strpad('K_mCa in component Na_Ca_exchanger (mM)'); LEGEND_CONSTANTS(:,38) = strpad('K_sat in component Na_Ca_exchanger (dimensionless)'); LEGEND_CONSTANTS(:,39) = strpad('eta in component Na_Ca_exchanger (dimensionless)'); LEGEND_ALGEBRAIC(:,55) = strpad('i_rel in component calcium_fluxes_in_the_SR (mM_per_ms)'); LEGEND_ALGEBRAIC(:,56) = strpad('i_up in component calcium_fluxes_in_the_SR (mM_per_ms)'); LEGEND_ALGEBRAIC(:,57) = strpad('i_leak in component calcium_fluxes_in_the_SR (mM_per_ms)'); LEGEND_ALGEBRAIC(:,58) = strpad('i_tr in component calcium_fluxes_in_the_SR (mM_per_ms)'); LEGEND_CONSTANTS(:,60) = strpad('G_rel in component calcium_fluxes_in_the_SR (per_ms)'); LEGEND_CONSTANTS(:,58) = strpad('G_rel_peak in component calcium_fluxes_in_the_SR (per_ms)'); LEGEND_CONSTANTS(:,40) = strpad('G_rel_max in component calcium_fluxes_in_the_SR (per_ms)'); LEGEND_CONSTANTS(:,41) = strpad('tau_on in component calcium_fluxes_in_the_SR (ms)'); LEGEND_CONSTANTS(:,42) = strpad('tau_off in component calcium_fluxes_in_the_SR (ms)'); LEGEND_CONSTANTS(:,43) = strpad('t_CICR in component calcium_fluxes_in_the_SR (ms)'); LEGEND_CONSTANTS(:,44) = strpad('tau_tr in component calcium_fluxes_in_the_SR (ms)'); LEGEND_CONSTANTS(:,45) = strpad('K_mrel in component calcium_fluxes_in_the_SR (mM)'); LEGEND_CONSTANTS(:,46) = strpad('K_mup in component calcium_fluxes_in_the_SR (mM)'); LEGEND_CONSTANTS(:,59) = strpad('K_leak in component calcium_fluxes_in_the_SR (per_ms)'); LEGEND_CONSTANTS(:,47) = strpad('I_up in component calcium_fluxes_in_the_SR (mM_per_ms)'); LEGEND_CONSTANTS(:,48) = strpad('Ca_NSR_max in component calcium_fluxes_in_the_SR (mM)'); LEGEND_CONSTANTS(:,49) = strpad('delta_Ca_i2 in component calcium_fluxes_in_the_SR (mM)'); LEGEND_CONSTANTS(:,50) = strpad('delta_Ca_ith in component calcium_fluxes_in_the_SR (mM)'); LEGEND_STATES(:,11) = strpad('Ca_JSR in component ionic_concentrations (mM)'); LEGEND_STATES(:,12) = strpad('Ca_NSR in component ionic_concentrations (mM)'); LEGEND_CONSTANTS(:,51) = strpad('Am in component ionic_concentrations (per_mm)'); LEGEND_CONSTANTS(:,52) = strpad('V_myo in component ionic_concentrations (dimensionless)'); LEGEND_CONSTANTS(:,53) = strpad('V_JSR in component ionic_concentrations (dimensionless)'); LEGEND_CONSTANTS(:,54) = strpad('V_NSR in component ionic_concentrations (dimensionless)'); LEGEND_RATES(:,1) = strpad('d/dt V in component membrane (mV)'); LEGEND_RATES(:,3) = strpad('d/dt m in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_RATES(:,4) = strpad('d/dt h in component fast_sodium_current_h_gate (dimensionless)'); LEGEND_RATES(:,5) = strpad('d/dt j in component fast_sodium_current_j_gate (dimensionless)'); LEGEND_RATES(:,8) = strpad('d/dt d in component L_type_Ca_channel_d_gate (dimensionless)'); LEGEND_RATES(:,9) = strpad('d/dt f in component L_type_Ca_channel_f_gate (dimensionless)'); LEGEND_RATES(:,10) = strpad('d/dt X in component time_dependent_potassium_current_X_gate (dimensionless)'); LEGEND_RATES(:,2) = strpad('d/dt Nai in component ionic_concentrations (mM)'); LEGEND_RATES(:,6) = strpad('d/dt Cai in component ionic_concentrations (mM)'); LEGEND_RATES(:,7) = strpad('d/dt Ki in component ionic_concentrations (mM)'); LEGEND_RATES(:,11) = strpad('d/dt Ca_JSR in component ionic_concentrations (mM)'); LEGEND_RATES(:,12) = strpad('d/dt Ca_NSR in component ionic_concentrations (mM)'); 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) = -84.624; CONSTANTS(:,1) = 8.3145e3; CONSTANTS(:,2) = 310.0; CONSTANTS(:,3) = 96845.0; CONSTANTS(:,4) = 0.01; CONSTANTS(:,5) = 1e3; CONSTANTS(:,6) = 0.5; CONSTANTS(:,7) = 0.5; CONSTANTS(:,8) = 0.16; STATES(:,2) = 10.0; CONSTANTS(:,9) = 140.0; STATES(:,3) = 0.0; STATES(:,4) = 1.0; STATES(:,5) = 1.0; CONSTANTS(:,10) = 0.75; CONSTANTS(:,11) = 0.75; CONSTANTS(:,12) = 0.75; CONSTANTS(:,13) = 0.75; CONSTANTS(:,14) = 5.4e-6; CONSTANTS(:,15) = 6.75e-9; CONSTANTS(:,16) = 1.93e-9; CONSTANTS(:,17) = 1.0; CONSTANTS(:,18) = 0.34; STATES(:,6) = 0.12e-3; CONSTANTS(:,19) = 1.8; CONSTANTS(:,20) = 5.4; STATES(:,7) = 145.0; STATES(:,8) = 0.0; STATES(:,9) = 1.0; CONSTANTS(:,21) = 0.6e-3; CONSTANTS(:,22) = 2.82e-3; CONSTANTS(:,23) = 0.01833; STATES(:,10) = 0.0; CONSTANTS(:,24) = 7.5e-3; CONSTANTS(:,25) = 1.83e-4; CONSTANTS(:,26) = 0.5e-3; CONSTANTS(:,27) = 1.15e-2; CONSTANTS(:,28) = 1.41e-5; CONSTANTS(:,29) = 3.016e-5; CONSTANTS(:,30) = 1.5e-2; CONSTANTS(:,31) = 10.0; CONSTANTS(:,32) = 1.5; CONSTANTS(:,33) = 1.75e-9; CONSTANTS(:,34) = 1.2e-3; CONSTANTS(:,35) = 20.0; CONSTANTS(:,36) = 87.5; CONSTANTS(:,37) = 1.38; CONSTANTS(:,38) = 0.1; CONSTANTS(:,39) = 0.35; CONSTANTS(:,40) = 60.0; CONSTANTS(:,41) = 2.0; CONSTANTS(:,42) = 2.0; CONSTANTS(:,43) = 0.0; CONSTANTS(:,44) = 180.0; CONSTANTS(:,45) = 0.8e-3; CONSTANTS(:,46) = 0.92e-3; CONSTANTS(:,47) = 0.005; CONSTANTS(:,48) = 15.0; CONSTANTS(:,49) = 0.0; CONSTANTS(:,50) = 0.18e-3; STATES(:,11) = 1.8; STATES(:,12) = 1.8; CONSTANTS(:,51) = 200; CONSTANTS(:,52) = 0.68; CONSTANTS(:,53) = 0.0048; CONSTANTS(:,54) = 0.0552; CONSTANTS(:,55) = CONSTANTS(:,22).*power((CONSTANTS(:,20)./5.40000), 1.0 ./ 2); CONSTANTS(:,56) = CONSTANTS(:,24).*power((CONSTANTS(:,20)./5.40000), 1.0 ./ 2); CONSTANTS(:,57) = (1.00000./7.00000).*(exp(CONSTANTS(:,9)./67.3000) - 1.00000); CONSTANTS(:,58) = piecewise({CONSTANTS(:,49)<CONSTANTS(:,50), 0.00000 }, CONSTANTS(:,40)); CONSTANTS(:,59) = CONSTANTS(:,47)./CONSTANTS(:,48); CONSTANTS(:,60) = CONSTANTS(:,58).*((CONSTANTS(:,49) - CONSTANTS(:,50))./((CONSTANTS(:,45)+CONSTANTS(:,49)) - CONSTANTS(:,50))).*(1.00000 - exp( - (CONSTANTS(:,43)./CONSTANTS(:,41)))).*exp( - (CONSTANTS(:,43)./CONSTANTS(:,42))); 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(:,1) = ( 0.320000.*(STATES(:,1)+47.1300))./(1.00000 - exp( -0.100000.*(STATES(:,1)+47.1300))); ALGEBRAIC(:,8) = 0.0800000.*exp( - STATES(:,1)./11.0000); RATES(:,3) = ALGEBRAIC(:,1).*(1.00000 - STATES(:,3)) - ALGEBRAIC(:,8).*STATES(:,3); ALGEBRAIC(:,2) = piecewise({STATES(:,1)<-40.0000, 0.135000.*exp((80.0000+STATES(:,1))./-6.80000) }, 0.00000); ALGEBRAIC(:,9) = piecewise({STATES(:,1)<-40.0000, 3.56000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.350000.*STATES(:,1)) }, 1.00000./( 0.130000.*(1.00000+exp((STATES(:,1)+10.6600)./-11.1000)))); RATES(:,4) = ALGEBRAIC(:,2).*(1.00000 - STATES(:,4)) - ALGEBRAIC(:,9).*STATES(:,4); ALGEBRAIC(:,3) = piecewise({STATES(:,1)<-40.0000, ( -127140..*exp( 0.244400.*STATES(:,1)) - 3.47400e-05.*exp( -0.0439100.*STATES(:,1))).*((STATES(:,1)+37.7800)./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300)))) }, 0.00000); ALGEBRAIC(:,10) = piecewise({STATES(:,1)<-40.0000, ( 0.121200.*exp( -0.0105200.*STATES(:,1)))./(1.00000+exp( -0.137800.*(STATES(:,1)+40.1400))) }, ( 0.300000.*exp( -2.53500e-07.*STATES(:,1)))./(1.00000+exp( -0.100000.*(STATES(:,1)+32.0000)))); RATES(:,5) = ALGEBRAIC(:,3).*(1.00000 - STATES(:,5)) - ALGEBRAIC(:,10).*STATES(:,5); ALGEBRAIC(:,7) = ( 7.19000e-05.*(STATES(:,1)+30.0000))./(1.00000 - exp( -0.148000.*(STATES(:,1)+30.0000))); ALGEBRAIC(:,14) = ( 0.000131000.*(STATES(:,1)+30.0000))./(-1.00000+exp( 0.0687000.*(STATES(:,1)+30.0000))); RATES(:,10) = ALGEBRAIC(:,7).*(1.00000 - STATES(:,10)) - ALGEBRAIC(:,14).*STATES(:,10); ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - ((STATES(:,1)+10.0000)./6.24000))); ALGEBRAIC(:,12) = ALGEBRAIC(:,5).*((1.00000 - exp( - ((STATES(:,1)+10.0000)./6.24000)))./( 0.0350000.*(STATES(:,1)+10.0000))); ALGEBRAIC(:,16) = ALGEBRAIC(:,5)./ALGEBRAIC(:,12); ALGEBRAIC(:,19) = (1.00000 - ALGEBRAIC(:,5))./ALGEBRAIC(:,12); RATES(:,8) = ALGEBRAIC(:,16).*(1.00000 - STATES(:,8)) - ALGEBRAIC(:,19).*STATES(:,8); ALGEBRAIC(:,6) = 1.00000./(1.00000+exp((STATES(:,1)+35.0600)./8.60000))+0.600000./(1.00000+exp((50.0000 - STATES(:,1))./20.0000)); ALGEBRAIC(:,13) = 1.00000./( 0.0197000.*exp( - power( 0.0337000.*(STATES(:,1)+10.0000), 2.00000))+0.0200000); ALGEBRAIC(:,17) = ALGEBRAIC(:,6)./ALGEBRAIC(:,13); ALGEBRAIC(:,20) = (1.00000 - ALGEBRAIC(:,6))./ALGEBRAIC(:,13); RATES(:,9) = ALGEBRAIC(:,17).*(1.00000 - STATES(:,9)) - ALGEBRAIC(:,20).*STATES(:,9); ALGEBRAIC(:,28) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log((CONSTANTS(:,20)+ CONSTANTS(:,23).*CONSTANTS(:,9))./(STATES(:,7)+ CONSTANTS(:,23).*STATES(:,2))); ALGEBRAIC(:,29) = 1.00000./(1.00000+exp((STATES(:,1) - 56.2600)./32.1000)); ALGEBRAIC(:,30) = CONSTANTS(:,55).*power(STATES(:,10), 2.00000).*ALGEBRAIC(:,29).*(STATES(:,1) - ALGEBRAIC(:,28)); ALGEBRAIC(:,31) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,20)./STATES(:,7)); ALGEBRAIC(:,32) = 1.02000./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,31)) - 59.2150))); ALGEBRAIC(:,33) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1)+5.47600) - ALGEBRAIC(:,31)))+exp( 0.0617500.*(STATES(:,1) - (ALGEBRAIC(:,31)+594.310))))./(1.00000+exp( -0.514300.*((STATES(:,1) - ALGEBRAIC(:,31))+4.75300))); ALGEBRAIC(:,34) = ALGEBRAIC(:,32)./(ALGEBRAIC(:,32)+ALGEBRAIC(:,33)); ALGEBRAIC(:,35) = CONSTANTS(:,56).*ALGEBRAIC(:,34).*(STATES(:,1) - ALGEBRAIC(:,31)); ALGEBRAIC(:,36) = ALGEBRAIC(:,31); ALGEBRAIC(:,37) = 1.00000./(1.00000+exp((7.48800 - STATES(:,1))./5.98000)); ALGEBRAIC(:,38) = CONSTANTS(:,25).*ALGEBRAIC(:,37).*(STATES(:,1) - ALGEBRAIC(:,36)); ALGEBRAIC(:,44) = 1.00000./((1.00000+ 0.124500.*exp( -0.100000.*(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))))+ 0.0365000.*CONSTANTS(:,57).*exp( - (( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))); ALGEBRAIC(:,45) = CONSTANTS(:,30).*ALGEBRAIC(:,44).*(1.00000./(1.00000+power(CONSTANTS(:,31)./STATES(:,2), 1.50000))).*(CONSTANTS(:,20)./(CONSTANTS(:,20)+CONSTANTS(:,32))); ALGEBRAIC(:,22) = CONSTANTS(:,16).*power(1.00000, 2.00000).*(( STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(( CONSTANTS(:,12).*STATES(:,7).*exp(( 1.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - CONSTANTS(:,13).*CONSTANTS(:,20))./(exp(( 1.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000)); ALGEBRAIC(:,23) = 1.00000./(1.00000+power(STATES(:,6)./CONSTANTS(:,21), 2.00000)); ALGEBRAIC(:,26) = STATES(:,8).*STATES(:,9).*ALGEBRAIC(:,23).*ALGEBRAIC(:,22); ALGEBRAIC(:,46) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log((CONSTANTS(:,20)+CONSTANTS(:,9))./(STATES(:,7)+STATES(:,2))); ALGEBRAIC(:,47) = STATES(:,1) - ALGEBRAIC(:,46); ALGEBRAIC(:,50) = CONSTANTS(:,33).*power(1.00000, 2.00000).*(( ALGEBRAIC(:,47).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(( CONSTANTS(:,12).*STATES(:,7).*exp(( 1.00000.*ALGEBRAIC(:,47).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - CONSTANTS(:,13).*CONSTANTS(:,20))./(exp(( 1.00000.*ALGEBRAIC(:,47).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000)); ALGEBRAIC(:,51) = ALGEBRAIC(:,50).*(1.00000./(1.00000+power(CONSTANTS(:,34)./STATES(:,6), 3.00000))); RATES(:,7) = - (ALGEBRAIC(:,26)+ALGEBRAIC(:,30)+ALGEBRAIC(:,35)+ALGEBRAIC(:,38)+ALGEBRAIC(:,51)+ - ( ALGEBRAIC(:,45).*2.00000)).*(CONSTANTS(:,51)./( CONSTANTS(:,52).*CONSTANTS(:,3))); ALGEBRAIC(:,11) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,9)./STATES(:,2)); ALGEBRAIC(:,15) = CONSTANTS(:,8).*power(STATES(:,3), 3.00000).*STATES(:,4).*STATES(:,5).*(STATES(:,1) - ALGEBRAIC(:,11)); ALGEBRAIC(:,53) = CONSTANTS(:,35).*(1.00000./(power(CONSTANTS(:,36), 3.00000)+power(CONSTANTS(:,9), 3.00000))).*(1.00000./(CONSTANTS(:,37)+CONSTANTS(:,19))).*(1.00000./(1.00000+ CONSTANTS(:,38).*exp( (CONSTANTS(:,39) - 1.00000).*STATES(:,1).*(CONSTANTS(:,3)./( CONSTANTS(:,1).*CONSTANTS(:,2)))))).*( exp( CONSTANTS(:,39).*STATES(:,1).*(CONSTANTS(:,3)./( CONSTANTS(:,1).*CONSTANTS(:,2)))).*power(STATES(:,2), 3.00000).*CONSTANTS(:,19) - exp( (CONSTANTS(:,39) - 1.00000).*STATES(:,1).*(CONSTANTS(:,3)./( CONSTANTS(:,1).*CONSTANTS(:,2)))).*power(CONSTANTS(:,9), 3.00000).*STATES(:,6)); ALGEBRAIC(:,40) = ALGEBRAIC(:,11); ALGEBRAIC(:,41) = CONSTANTS(:,28).*(STATES(:,1) - ALGEBRAIC(:,40)); ALGEBRAIC(:,21) = CONSTANTS(:,15).*power(1.00000, 2.00000).*(( STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(( CONSTANTS(:,10).*STATES(:,2).*exp(( 1.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - CONSTANTS(:,11).*CONSTANTS(:,9))./(exp(( 1.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000)); ALGEBRAIC(:,25) = STATES(:,8).*STATES(:,9).*ALGEBRAIC(:,23).*ALGEBRAIC(:,21); ALGEBRAIC(:,48) = CONSTANTS(:,33).*power(1.00000, 2.00000).*(( ALGEBRAIC(:,47).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(( CONSTANTS(:,10).*STATES(:,2).*exp(( 1.00000.*ALGEBRAIC(:,47).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - CONSTANTS(:,11).*CONSTANTS(:,9))./(exp(( 1.00000.*ALGEBRAIC(:,47).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000)); ALGEBRAIC(:,49) = ALGEBRAIC(:,48).*(1.00000./(1.00000+power(CONSTANTS(:,34)./STATES(:,6), 3.00000))); RATES(:,2) = - (ALGEBRAIC(:,15)+ALGEBRAIC(:,25)+ALGEBRAIC(:,41)+ALGEBRAIC(:,49)+ ALGEBRAIC(:,53).*3.00000+ ALGEBRAIC(:,45).*3.00000).*(CONSTANTS(:,51)./( CONSTANTS(:,52).*CONSTANTS(:,3))); ALGEBRAIC(:,4) = piecewise({ rem(VOI, CONSTANTS(:,5))<CONSTANTS(:,6), CONSTANTS(:,7) }, 0.00000); ALGEBRAIC(:,18) = CONSTANTS(:,14).*power(2.00000, 2.00000).*(( STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(( CONSTANTS(:,17).*STATES(:,6).*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - CONSTANTS(:,18).*CONSTANTS(:,19))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000)); ALGEBRAIC(:,24) = STATES(:,8).*STATES(:,9).*ALGEBRAIC(:,23).*ALGEBRAIC(:,18); ALGEBRAIC(:,27) = ALGEBRAIC(:,24)+ALGEBRAIC(:,26)+ALGEBRAIC(:,25); ALGEBRAIC(:,39) = CONSTANTS(:,27).*(STATES(:,6)./(CONSTANTS(:,26)+STATES(:,6))); ALGEBRAIC(:,42) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./( 2.00000.*CONSTANTS(:,3))).*log(CONSTANTS(:,19)./STATES(:,6)); ALGEBRAIC(:,43) = CONSTANTS(:,29).*(STATES(:,1) - ALGEBRAIC(:,42)); ALGEBRAIC(:,52) = ALGEBRAIC(:,49)+ALGEBRAIC(:,51); ALGEBRAIC(:,54) = (ALGEBRAIC(:,4) - (ALGEBRAIC(:,15)+ALGEBRAIC(:,27)+ALGEBRAIC(:,30)+ALGEBRAIC(:,35)+ALGEBRAIC(:,38)+ALGEBRAIC(:,53)+ALGEBRAIC(:,39)+ALGEBRAIC(:,41)+ALGEBRAIC(:,43)+ALGEBRAIC(:,45)+ALGEBRAIC(:,52)))./CONSTANTS(:,4); RATES(:,1) = ALGEBRAIC(:,54); ALGEBRAIC(:,55) = CONSTANTS(:,60).*(STATES(:,11) - STATES(:,6)); ALGEBRAIC(:,56) = CONSTANTS(:,47).*(STATES(:,6)./(STATES(:,6)+CONSTANTS(:,46))); ALGEBRAIC(:,57) = CONSTANTS(:,59).*STATES(:,12); RATES(:,6) = - ((ALGEBRAIC(:,24)+ALGEBRAIC(:,39)+ALGEBRAIC(:,43)) - ALGEBRAIC(:,53)).*(CONSTANTS(:,51)./( 2.00000.*CONSTANTS(:,52).*CONSTANTS(:,3)))+ ALGEBRAIC(:,55).*(CONSTANTS(:,53)./CONSTANTS(:,52))+ (ALGEBRAIC(:,57) - ALGEBRAIC(:,56)).*(CONSTANTS(:,54)./CONSTANTS(:,52)); ALGEBRAIC(:,58) = (STATES(:,12) - STATES(:,11))./CONSTANTS(:,44); RATES(:,11) = - (ALGEBRAIC(:,55) - ALGEBRAIC(:,58).*(CONSTANTS(:,54)./CONSTANTS(:,53))); RATES(:,12) = - ((ALGEBRAIC(:,57)+ALGEBRAIC(:,58)) - ALGEBRAIC(:,56)); 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) = ( 0.320000.*(STATES(:,1)+47.1300))./(1.00000 - exp( -0.100000.*(STATES(:,1)+47.1300))); ALGEBRAIC(:,8) = 0.0800000.*exp( - STATES(:,1)./11.0000); ALGEBRAIC(:,2) = piecewise({STATES(:,1)<-40.0000, 0.135000.*exp((80.0000+STATES(:,1))./-6.80000) }, 0.00000); ALGEBRAIC(:,9) = piecewise({STATES(:,1)<-40.0000, 3.56000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.350000.*STATES(:,1)) }, 1.00000./( 0.130000.*(1.00000+exp((STATES(:,1)+10.6600)./-11.1000)))); ALGEBRAIC(:,3) = piecewise({STATES(:,1)<-40.0000, ( -127140..*exp( 0.244400.*STATES(:,1)) - 3.47400e-05.*exp( -0.0439100.*STATES(:,1))).*((STATES(:,1)+37.7800)./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300)))) }, 0.00000); ALGEBRAIC(:,10) = piecewise({STATES(:,1)<-40.0000, ( 0.121200.*exp( -0.0105200.*STATES(:,1)))./(1.00000+exp( -0.137800.*(STATES(:,1)+40.1400))) }, ( 0.300000.*exp( -2.53500e-07.*STATES(:,1)))./(1.00000+exp( -0.100000.*(STATES(:,1)+32.0000)))); ALGEBRAIC(:,7) = ( 7.19000e-05.*(STATES(:,1)+30.0000))./(1.00000 - exp( -0.148000.*(STATES(:,1)+30.0000))); ALGEBRAIC(:,14) = ( 0.000131000.*(STATES(:,1)+30.0000))./(-1.00000+exp( 0.0687000.*(STATES(:,1)+30.0000))); ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - ((STATES(:,1)+10.0000)./6.24000))); ALGEBRAIC(:,12) = ALGEBRAIC(:,5).*((1.00000 - exp( - ((STATES(:,1)+10.0000)./6.24000)))./( 0.0350000.*(STATES(:,1)+10.0000))); ALGEBRAIC(:,16) = ALGEBRAIC(:,5)./ALGEBRAIC(:,12); ALGEBRAIC(:,19) = (1.00000 - ALGEBRAIC(:,5))./ALGEBRAIC(:,12); ALGEBRAIC(:,6) = 1.00000./(1.00000+exp((STATES(:,1)+35.0600)./8.60000))+0.600000./(1.00000+exp((50.0000 - STATES(:,1))./20.0000)); ALGEBRAIC(:,13) = 1.00000./( 0.0197000.*exp( - power( 0.0337000.*(STATES(:,1)+10.0000), 2.00000))+0.0200000); ALGEBRAIC(:,17) = ALGEBRAIC(:,6)./ALGEBRAIC(:,13); ALGEBRAIC(:,20) = (1.00000 - ALGEBRAIC(:,6))./ALGEBRAIC(:,13); ALGEBRAIC(:,28) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log((CONSTANTS(:,20)+ CONSTANTS(:,23).*CONSTANTS(:,9))./(STATES(:,7)+ CONSTANTS(:,23).*STATES(:,2))); ALGEBRAIC(:,29) = 1.00000./(1.00000+exp((STATES(:,1) - 56.2600)./32.1000)); ALGEBRAIC(:,30) = CONSTANTS(:,55).*power(STATES(:,10), 2.00000).*ALGEBRAIC(:,29).*(STATES(:,1) - ALGEBRAIC(:,28)); ALGEBRAIC(:,31) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,20)./STATES(:,7)); ALGEBRAIC(:,32) = 1.02000./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,31)) - 59.2150))); ALGEBRAIC(:,33) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1)+5.47600) - ALGEBRAIC(:,31)))+exp( 0.0617500.*(STATES(:,1) - (ALGEBRAIC(:,31)+594.310))))./(1.00000+exp( -0.514300.*((STATES(:,1) - ALGEBRAIC(:,31))+4.75300))); ALGEBRAIC(:,34) = ALGEBRAIC(:,32)./(ALGEBRAIC(:,32)+ALGEBRAIC(:,33)); ALGEBRAIC(:,35) = CONSTANTS(:,56).*ALGEBRAIC(:,34).*(STATES(:,1) - ALGEBRAIC(:,31)); ALGEBRAIC(:,36) = ALGEBRAIC(:,31); ALGEBRAIC(:,37) = 1.00000./(1.00000+exp((7.48800 - STATES(:,1))./5.98000)); ALGEBRAIC(:,38) = CONSTANTS(:,25).*ALGEBRAIC(:,37).*(STATES(:,1) - ALGEBRAIC(:,36)); ALGEBRAIC(:,44) = 1.00000./((1.00000+ 0.124500.*exp( -0.100000.*(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))))+ 0.0365000.*CONSTANTS(:,57).*exp( - (( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))); ALGEBRAIC(:,45) = CONSTANTS(:,30).*ALGEBRAIC(:,44).*(1.00000./(1.00000+power(CONSTANTS(:,31)./STATES(:,2), 1.50000))).*(CONSTANTS(:,20)./(CONSTANTS(:,20)+CONSTANTS(:,32))); ALGEBRAIC(:,22) = CONSTANTS(:,16).*power(1.00000, 2.00000).*(( STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(( CONSTANTS(:,12).*STATES(:,7).*exp(( 1.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - CONSTANTS(:,13).*CONSTANTS(:,20))./(exp(( 1.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000)); ALGEBRAIC(:,23) = 1.00000./(1.00000+power(STATES(:,6)./CONSTANTS(:,21), 2.00000)); ALGEBRAIC(:,26) = STATES(:,8).*STATES(:,9).*ALGEBRAIC(:,23).*ALGEBRAIC(:,22); ALGEBRAIC(:,46) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log((CONSTANTS(:,20)+CONSTANTS(:,9))./(STATES(:,7)+STATES(:,2))); ALGEBRAIC(:,47) = STATES(:,1) - ALGEBRAIC(:,46); ALGEBRAIC(:,50) = CONSTANTS(:,33).*power(1.00000, 2.00000).*(( ALGEBRAIC(:,47).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(( CONSTANTS(:,12).*STATES(:,7).*exp(( 1.00000.*ALGEBRAIC(:,47).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - CONSTANTS(:,13).*CONSTANTS(:,20))./(exp(( 1.00000.*ALGEBRAIC(:,47).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000)); ALGEBRAIC(:,51) = ALGEBRAIC(:,50).*(1.00000./(1.00000+power(CONSTANTS(:,34)./STATES(:,6), 3.00000))); ALGEBRAIC(:,11) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3)).*log(CONSTANTS(:,9)./STATES(:,2)); ALGEBRAIC(:,15) = CONSTANTS(:,8).*power(STATES(:,3), 3.00000).*STATES(:,4).*STATES(:,5).*(STATES(:,1) - ALGEBRAIC(:,11)); ALGEBRAIC(:,53) = CONSTANTS(:,35).*(1.00000./(power(CONSTANTS(:,36), 3.00000)+power(CONSTANTS(:,9), 3.00000))).*(1.00000./(CONSTANTS(:,37)+CONSTANTS(:,19))).*(1.00000./(1.00000+ CONSTANTS(:,38).*exp( (CONSTANTS(:,39) - 1.00000).*STATES(:,1).*(CONSTANTS(:,3)./( CONSTANTS(:,1).*CONSTANTS(:,2)))))).*( exp( CONSTANTS(:,39).*STATES(:,1).*(CONSTANTS(:,3)./( CONSTANTS(:,1).*CONSTANTS(:,2)))).*power(STATES(:,2), 3.00000).*CONSTANTS(:,19) - exp( (CONSTANTS(:,39) - 1.00000).*STATES(:,1).*(CONSTANTS(:,3)./( CONSTANTS(:,1).*CONSTANTS(:,2)))).*power(CONSTANTS(:,9), 3.00000).*STATES(:,6)); ALGEBRAIC(:,40) = ALGEBRAIC(:,11); ALGEBRAIC(:,41) = CONSTANTS(:,28).*(STATES(:,1) - ALGEBRAIC(:,40)); ALGEBRAIC(:,21) = CONSTANTS(:,15).*power(1.00000, 2.00000).*(( STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(( CONSTANTS(:,10).*STATES(:,2).*exp(( 1.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - CONSTANTS(:,11).*CONSTANTS(:,9))./(exp(( 1.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000)); ALGEBRAIC(:,25) = STATES(:,8).*STATES(:,9).*ALGEBRAIC(:,23).*ALGEBRAIC(:,21); ALGEBRAIC(:,48) = CONSTANTS(:,33).*power(1.00000, 2.00000).*(( ALGEBRAIC(:,47).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(( CONSTANTS(:,10).*STATES(:,2).*exp(( 1.00000.*ALGEBRAIC(:,47).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - CONSTANTS(:,11).*CONSTANTS(:,9))./(exp(( 1.00000.*ALGEBRAIC(:,47).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000)); ALGEBRAIC(:,49) = ALGEBRAIC(:,48).*(1.00000./(1.00000+power(CONSTANTS(:,34)./STATES(:,6), 3.00000))); ALGEBRAIC(:,4) = piecewise({ rem(VOI, CONSTANTS(:,5))<CONSTANTS(:,6), CONSTANTS(:,7) }, 0.00000); ALGEBRAIC(:,18) = CONSTANTS(:,14).*power(2.00000, 2.00000).*(( STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*(( CONSTANTS(:,17).*STATES(:,6).*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - CONSTANTS(:,18).*CONSTANTS(:,19))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000)); ALGEBRAIC(:,24) = STATES(:,8).*STATES(:,9).*ALGEBRAIC(:,23).*ALGEBRAIC(:,18); ALGEBRAIC(:,27) = ALGEBRAIC(:,24)+ALGEBRAIC(:,26)+ALGEBRAIC(:,25); ALGEBRAIC(:,39) = CONSTANTS(:,27).*(STATES(:,6)./(CONSTANTS(:,26)+STATES(:,6))); ALGEBRAIC(:,42) = (( CONSTANTS(:,1).*CONSTANTS(:,2))./( 2.00000.*CONSTANTS(:,3))).*log(CONSTANTS(:,19)./STATES(:,6)); ALGEBRAIC(:,43) = CONSTANTS(:,29).*(STATES(:,1) - ALGEBRAIC(:,42)); ALGEBRAIC(:,52) = ALGEBRAIC(:,49)+ALGEBRAIC(:,51); ALGEBRAIC(:,54) = (ALGEBRAIC(:,4) - (ALGEBRAIC(:,15)+ALGEBRAIC(:,27)+ALGEBRAIC(:,30)+ALGEBRAIC(:,35)+ALGEBRAIC(:,38)+ALGEBRAIC(:,53)+ALGEBRAIC(:,39)+ALGEBRAIC(:,41)+ALGEBRAIC(:,43)+ALGEBRAIC(:,45)+ALGEBRAIC(:,52)))./CONSTANTS(:,4); ALGEBRAIC(:,55) = CONSTANTS(:,60).*(STATES(:,11) - STATES(:,6)); ALGEBRAIC(:,56) = CONSTANTS(:,47).*(STATES(:,6)./(STATES(:,6)+CONSTANTS(:,46))); ALGEBRAIC(:,57) = CONSTANTS(:,59).*STATES(:,12); ALGEBRAIC(:,58) = (STATES(:,12) - STATES(:,11))./CONSTANTS(:,44); 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