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 =80; end % There are a total of 25 entries in each of the rate and state variable arrays. % There are a total of 160 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_ALGEBRAIC(:,1) = strpad('sum_g_syn_e_s_1 in component synaptic_coupling (nanoS)'); LEGEND_ALGEBRAIC(:,6) = strpad('sum_g_syn_e_s_2 in component synaptic_coupling (nanoS)'); LEGEND_ALGEBRAIC(:,11) = strpad('sum_g_syn_e_s_3 in component synaptic_coupling (nanoS)'); LEGEND_ALGEBRAIC(:,16) = strpad('sum_g_syn_e_s_4 in component synaptic_coupling (nanoS)'); LEGEND_ALGEBRAIC(:,21) = strpad('sum_g_syn_e_s_5 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,1) = strpad('g_syn_e_1_2 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,2) = strpad('g_syn_e_1_3 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,3) = strpad('g_syn_e_1_4 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,4) = strpad('g_syn_e_1_5 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,5) = strpad('g_syn_e_2_1 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,6) = strpad('g_syn_e_2_3 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,7) = strpad('g_syn_e_2_4 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,8) = strpad('g_syn_e_2_5 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,9) = strpad('g_syn_e_3_1 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,10) = strpad('g_syn_e_3_2 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,11) = strpad('g_syn_e_3_4 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,12) = strpad('g_syn_e_3_5 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,13) = strpad('g_syn_e_4_1 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,14) = strpad('g_syn_e_4_2 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,15) = strpad('g_syn_e_4_3 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,16) = strpad('g_syn_e_4_5 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,17) = strpad('g_syn_e_5_1 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,18) = strpad('g_syn_e_5_2 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,19) = strpad('g_syn_e_5_3 in component synaptic_coupling (nanoS)'); LEGEND_CONSTANTS(:,20) = strpad('g_syn_e_5_4 in component synaptic_coupling (nanoS)'); LEGEND_STATES(:,1) = strpad('s in component synaptic_input (dimensionless)'); LEGEND_STATES(:,2) = strpad('s in component synaptic_input (dimensionless)'); LEGEND_STATES(:,3) = strpad('s in component synaptic_input (dimensionless)'); LEGEND_STATES(:,4) = strpad('s in component synaptic_input (dimensionless)'); LEGEND_STATES(:,5) = strpad('s in component synaptic_input (dimensionless)'); LEGEND_VOI = strpad('time in component environment (millisecond)'); LEGEND_STATES(:,6) = strpad('V in component membrane (millivolt)'); LEGEND_CONSTANTS(:,21) = strpad('C in component membrane (picoF)'); LEGEND_CONSTANTS(:,22) = strpad('i_app in component membrane (picoA)'); LEGEND_ALGEBRAIC(:,61) = strpad('i_NaP in component persistent_sodium_current (picoA)'); LEGEND_ALGEBRAIC(:,46) = strpad('i_Na in component fast_sodium_current (picoA)'); LEGEND_ALGEBRAIC(:,51) = strpad('i_K in component potassium_current (picoA)'); LEGEND_ALGEBRAIC(:,66) = strpad('i_L in component leakage_current (picoA)'); LEGEND_ALGEBRAIC(:,71) = strpad('i_tonic_e in component tonic_current (picoA)'); LEGEND_ALGEBRAIC(:,76) = strpad('i_syn_e in component synaptic_input (picoA)'); LEGEND_CONSTANTS(:,23) = strpad('E_Na in component fast_sodium_current (millivolt)'); LEGEND_CONSTANTS(:,24) = strpad('g_Na in component fast_sodium_current (nanoS)'); LEGEND_ALGEBRAIC(:,26) = strpad('m_infinity in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_STATES(:,7) = strpad('n in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_CONSTANTS(:,25) = strpad('theta_m in component fast_sodium_current_m_gate (millivolt)'); LEGEND_CONSTANTS(:,26) = strpad('sigma_m in component fast_sodium_current_m_gate (millivolt)'); LEGEND_ALGEBRAIC(:,2) = strpad('n_infinity in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,27) = strpad('tau_n in component fast_sodium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,27) = strpad('tau_n_max in component fast_sodium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,28) = strpad('theta_n in component fast_sodium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,29) = strpad('sigma_n in component fast_sodium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,30) = strpad('g_K in component potassium_current (nanoS)'); LEGEND_CONSTANTS(:,31) = strpad('E_K in component potassium_current (millivolt)'); LEGEND_STATES(:,8) = strpad('n in component potassium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,3) = strpad('n_infinity in component potassium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,28) = strpad('tau_n in component potassium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,32) = strpad('tau_n_max in component potassium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,33) = strpad('theta_n in component potassium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,34) = strpad('sigma_n in component potassium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,35) = strpad('g_NaP in component persistent_sodium_current (nanoS)'); LEGEND_ALGEBRAIC(:,56) = strpad('m_infinity in component persistent_sodium_current_m_gate (dimensionless)'); LEGEND_STATES(:,9) = strpad('h in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_CONSTANTS(:,36) = strpad('theta_m in component persistent_sodium_current_m_gate (millivolt)'); LEGEND_CONSTANTS(:,37) = strpad('sigma_m in component persistent_sodium_current_m_gate (millivolt)'); LEGEND_ALGEBRAIC(:,4) = strpad('h_infinity in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,29) = strpad('tau_h in component persistent_sodium_current_h_gate (millisecond)'); LEGEND_CONSTANTS(:,38) = strpad('tau_h_max in component persistent_sodium_current_h_gate (millisecond)'); LEGEND_CONSTANTS(:,39) = strpad('theta_h in component persistent_sodium_current_h_gate (millivolt)'); LEGEND_CONSTANTS(:,40) = strpad('sigma_h in component persistent_sodium_current_h_gate (millivolt)'); LEGEND_CONSTANTS(:,41) = strpad('g_L in component leakage_current (nanoS)'); LEGEND_CONSTANTS(:,42) = strpad('E_L in component leakage_current (millivolt)'); LEGEND_CONSTANTS(:,43) = strpad('E_syn_e in component tonic_current (millivolt)'); LEGEND_CONSTANTS(:,44) = strpad('g_tonic_e in component tonic_current (nanoS)'); LEGEND_ALGEBRAIC(:,5) = strpad('s_infinity in component synaptic_input (dimensionless)'); LEGEND_CONSTANTS(:,45) = strpad('kr in component synaptic_input (dimensionless)'); LEGEND_CONSTANTS(:,46) = strpad('tau_s in component synaptic_input (millisecond)'); LEGEND_CONSTANTS(:,47) = strpad('sigma_s in component synaptic_input (millivolt)'); LEGEND_CONSTANTS(:,48) = strpad('theta_s in component synaptic_input (millivolt)'); LEGEND_VOI = strpad('time in component environment (millisecond)'); LEGEND_STATES(:,10) = strpad('V in component membrane (millivolt)'); LEGEND_CONSTANTS(:,49) = strpad('C in component membrane (picoF)'); LEGEND_CONSTANTS(:,50) = strpad('i_app in component membrane (picoA)'); LEGEND_ALGEBRAIC(:,62) = strpad('i_NaP in component persistent_sodium_current (picoA)'); LEGEND_ALGEBRAIC(:,47) = strpad('i_Na in component fast_sodium_current (picoA)'); LEGEND_ALGEBRAIC(:,52) = strpad('i_K in component potassium_current (picoA)'); LEGEND_ALGEBRAIC(:,67) = strpad('i_L in component leakage_current (picoA)'); LEGEND_ALGEBRAIC(:,72) = strpad('i_tonic_e in component tonic_current (picoA)'); LEGEND_ALGEBRAIC(:,77) = strpad('i_syn_e in component synaptic_input (picoA)'); LEGEND_CONSTANTS(:,51) = strpad('E_Na in component fast_sodium_current (millivolt)'); LEGEND_CONSTANTS(:,52) = strpad('g_Na in component fast_sodium_current (nanoS)'); LEGEND_ALGEBRAIC(:,30) = strpad('m_infinity in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_STATES(:,11) = strpad('n in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_CONSTANTS(:,53) = strpad('theta_m in component fast_sodium_current_m_gate (millivolt)'); LEGEND_CONSTANTS(:,54) = strpad('sigma_m in component fast_sodium_current_m_gate (millivolt)'); LEGEND_ALGEBRAIC(:,7) = strpad('n_infinity in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,31) = strpad('tau_n in component fast_sodium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,55) = strpad('tau_n_max in component fast_sodium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,56) = strpad('theta_n in component fast_sodium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,57) = strpad('sigma_n in component fast_sodium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,58) = strpad('g_K in component potassium_current (nanoS)'); LEGEND_CONSTANTS(:,59) = strpad('E_K in component potassium_current (millivolt)'); LEGEND_STATES(:,12) = strpad('n in component potassium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,8) = strpad('n_infinity in component potassium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,32) = strpad('tau_n in component potassium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,60) = strpad('tau_n_max in component potassium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,61) = strpad('theta_n in component potassium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,62) = strpad('sigma_n in component potassium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,63) = strpad('g_NaP in component persistent_sodium_current (nanoS)'); LEGEND_ALGEBRAIC(:,57) = strpad('m_infinity in component persistent_sodium_current_m_gate (dimensionless)'); LEGEND_STATES(:,13) = strpad('h in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_CONSTANTS(:,64) = strpad('theta_m in component persistent_sodium_current_m_gate (millivolt)'); LEGEND_CONSTANTS(:,65) = strpad('sigma_m in component persistent_sodium_current_m_gate (millivolt)'); LEGEND_ALGEBRAIC(:,9) = strpad('h_infinity in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,33) = strpad('tau_h in component persistent_sodium_current_h_gate (millisecond)'); LEGEND_CONSTANTS(:,66) = strpad('tau_h_max in component persistent_sodium_current_h_gate (millisecond)'); LEGEND_CONSTANTS(:,67) = strpad('theta_h in component persistent_sodium_current_h_gate (millivolt)'); LEGEND_CONSTANTS(:,68) = strpad('sigma_h in component persistent_sodium_current_h_gate (millivolt)'); LEGEND_CONSTANTS(:,69) = strpad('g_L in component leakage_current (nanoS)'); LEGEND_CONSTANTS(:,70) = strpad('E_L in component leakage_current (millivolt)'); LEGEND_CONSTANTS(:,71) = strpad('E_syn_e in component tonic_current (millivolt)'); LEGEND_CONSTANTS(:,72) = strpad('g_tonic_e in component tonic_current (nanoS)'); LEGEND_ALGEBRAIC(:,10) = strpad('s_infinity in component synaptic_input (dimensionless)'); LEGEND_CONSTANTS(:,73) = strpad('kr in component synaptic_input (dimensionless)'); LEGEND_CONSTANTS(:,74) = strpad('tau_s in component synaptic_input (millisecond)'); LEGEND_CONSTANTS(:,75) = strpad('sigma_s in component synaptic_input (millivolt)'); LEGEND_CONSTANTS(:,76) = strpad('theta_s in component synaptic_input (millivolt)'); LEGEND_VOI = strpad('time in component environment (millisecond)'); LEGEND_STATES(:,14) = strpad('V in component membrane (millivolt)'); LEGEND_CONSTANTS(:,77) = strpad('C in component membrane (picoF)'); LEGEND_CONSTANTS(:,78) = strpad('i_app in component membrane (picoA)'); LEGEND_ALGEBRAIC(:,63) = strpad('i_NaP in component persistent_sodium_current (picoA)'); LEGEND_ALGEBRAIC(:,48) = strpad('i_Na in component fast_sodium_current (picoA)'); LEGEND_ALGEBRAIC(:,53) = strpad('i_K in component potassium_current (picoA)'); LEGEND_ALGEBRAIC(:,68) = strpad('i_L in component leakage_current (picoA)'); LEGEND_ALGEBRAIC(:,73) = strpad('i_tonic_e in component tonic_current (picoA)'); LEGEND_ALGEBRAIC(:,78) = strpad('i_syn_e in component synaptic_input (picoA)'); LEGEND_CONSTANTS(:,79) = strpad('E_Na in component fast_sodium_current (millivolt)'); LEGEND_CONSTANTS(:,80) = strpad('g_Na in component fast_sodium_current (nanoS)'); LEGEND_ALGEBRAIC(:,34) = strpad('m_infinity in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_STATES(:,15) = strpad('n in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_CONSTANTS(:,81) = strpad('theta_m in component fast_sodium_current_m_gate (millivolt)'); LEGEND_CONSTANTS(:,82) = strpad('sigma_m in component fast_sodium_current_m_gate (millivolt)'); LEGEND_ALGEBRAIC(:,12) = strpad('n_infinity in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,35) = strpad('tau_n in component fast_sodium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,83) = strpad('tau_n_max in component fast_sodium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,84) = strpad('theta_n in component fast_sodium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,85) = strpad('sigma_n in component fast_sodium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,86) = strpad('g_K in component potassium_current (nanoS)'); LEGEND_CONSTANTS(:,87) = strpad('E_K in component potassium_current (millivolt)'); LEGEND_STATES(:,16) = strpad('n in component potassium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,13) = strpad('n_infinity in component potassium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,36) = strpad('tau_n in component potassium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,88) = strpad('tau_n_max in component potassium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,89) = strpad('theta_n in component potassium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,90) = strpad('sigma_n in component potassium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,91) = strpad('g_NaP in component persistent_sodium_current (nanoS)'); LEGEND_ALGEBRAIC(:,58) = strpad('m_infinity in component persistent_sodium_current_m_gate (dimensionless)'); LEGEND_STATES(:,17) = strpad('h in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_CONSTANTS(:,92) = strpad('theta_m in component persistent_sodium_current_m_gate (millivolt)'); LEGEND_CONSTANTS(:,93) = strpad('sigma_m in component persistent_sodium_current_m_gate (millivolt)'); LEGEND_ALGEBRAIC(:,14) = strpad('h_infinity in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,37) = strpad('tau_h in component persistent_sodium_current_h_gate (millisecond)'); LEGEND_CONSTANTS(:,94) = strpad('tau_h_max in component persistent_sodium_current_h_gate (millisecond)'); LEGEND_CONSTANTS(:,95) = strpad('theta_h in component persistent_sodium_current_h_gate (millivolt)'); LEGEND_CONSTANTS(:,96) = strpad('sigma_h in component persistent_sodium_current_h_gate (millivolt)'); LEGEND_CONSTANTS(:,97) = strpad('g_L in component leakage_current (nanoS)'); LEGEND_CONSTANTS(:,98) = strpad('E_L in component leakage_current (millivolt)'); LEGEND_CONSTANTS(:,99) = strpad('E_syn_e in component tonic_current (millivolt)'); LEGEND_CONSTANTS(:,100) = strpad('g_tonic_e in component tonic_current (nanoS)'); LEGEND_ALGEBRAIC(:,15) = strpad('s_infinity in component synaptic_input (dimensionless)'); LEGEND_CONSTANTS(:,101) = strpad('kr in component synaptic_input (dimensionless)'); LEGEND_CONSTANTS(:,102) = strpad('tau_s in component synaptic_input (millisecond)'); LEGEND_CONSTANTS(:,103) = strpad('sigma_s in component synaptic_input (millivolt)'); LEGEND_CONSTANTS(:,104) = strpad('theta_s in component synaptic_input (millivolt)'); LEGEND_VOI = strpad('time in component environment (millisecond)'); LEGEND_STATES(:,18) = strpad('V in component membrane (millivolt)'); LEGEND_CONSTANTS(:,105) = strpad('C in component membrane (picoF)'); LEGEND_CONSTANTS(:,106) = strpad('i_app in component membrane (picoA)'); LEGEND_ALGEBRAIC(:,64) = strpad('i_NaP in component persistent_sodium_current (picoA)'); LEGEND_ALGEBRAIC(:,49) = strpad('i_Na in component fast_sodium_current (picoA)'); LEGEND_ALGEBRAIC(:,54) = strpad('i_K in component potassium_current (picoA)'); LEGEND_ALGEBRAIC(:,69) = strpad('i_L in component leakage_current (picoA)'); LEGEND_ALGEBRAIC(:,74) = strpad('i_tonic_e in component tonic_current (picoA)'); LEGEND_ALGEBRAIC(:,79) = strpad('i_syn_e in component synaptic_input (picoA)'); LEGEND_CONSTANTS(:,107) = strpad('E_Na in component fast_sodium_current (millivolt)'); LEGEND_CONSTANTS(:,108) = strpad('g_Na in component fast_sodium_current (nanoS)'); LEGEND_ALGEBRAIC(:,38) = strpad('m_infinity in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_STATES(:,19) = strpad('n in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_CONSTANTS(:,109) = strpad('theta_m in component fast_sodium_current_m_gate (millivolt)'); LEGEND_CONSTANTS(:,110) = strpad('sigma_m in component fast_sodium_current_m_gate (millivolt)'); LEGEND_ALGEBRAIC(:,17) = strpad('n_infinity in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,39) = strpad('tau_n in component fast_sodium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,111) = strpad('tau_n_max in component fast_sodium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,112) = strpad('theta_n in component fast_sodium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,113) = strpad('sigma_n in component fast_sodium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,114) = strpad('g_K in component potassium_current (nanoS)'); LEGEND_CONSTANTS(:,115) = strpad('E_K in component potassium_current (millivolt)'); LEGEND_STATES(:,20) = strpad('n in component potassium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,18) = strpad('n_infinity in component potassium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,40) = strpad('tau_n in component potassium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,116) = strpad('tau_n_max in component potassium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,117) = strpad('theta_n in component potassium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,118) = strpad('sigma_n in component potassium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,119) = strpad('g_NaP in component persistent_sodium_current (nanoS)'); LEGEND_ALGEBRAIC(:,59) = strpad('m_infinity in component persistent_sodium_current_m_gate (dimensionless)'); LEGEND_STATES(:,21) = strpad('h in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_CONSTANTS(:,120) = strpad('theta_m in component persistent_sodium_current_m_gate (millivolt)'); LEGEND_CONSTANTS(:,121) = strpad('sigma_m in component persistent_sodium_current_m_gate (millivolt)'); LEGEND_ALGEBRAIC(:,19) = strpad('h_infinity in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,41) = strpad('tau_h in component persistent_sodium_current_h_gate (millisecond)'); LEGEND_CONSTANTS(:,122) = strpad('tau_h_max in component persistent_sodium_current_h_gate (millisecond)'); LEGEND_CONSTANTS(:,123) = strpad('theta_h in component persistent_sodium_current_h_gate (millivolt)'); LEGEND_CONSTANTS(:,124) = strpad('sigma_h in component persistent_sodium_current_h_gate (millivolt)'); LEGEND_CONSTANTS(:,125) = strpad('g_L in component leakage_current (nanoS)'); LEGEND_CONSTANTS(:,126) = strpad('E_L in component leakage_current (millivolt)'); LEGEND_CONSTANTS(:,127) = strpad('E_syn_e in component tonic_current (millivolt)'); LEGEND_CONSTANTS(:,128) = strpad('g_tonic_e in component tonic_current (nanoS)'); LEGEND_ALGEBRAIC(:,20) = strpad('s_infinity in component synaptic_input (dimensionless)'); LEGEND_CONSTANTS(:,129) = strpad('kr in component synaptic_input (dimensionless)'); LEGEND_CONSTANTS(:,130) = strpad('tau_s in component synaptic_input (millisecond)'); LEGEND_CONSTANTS(:,131) = strpad('sigma_s in component synaptic_input (millivolt)'); LEGEND_CONSTANTS(:,132) = strpad('theta_s in component synaptic_input (millivolt)'); LEGEND_VOI = strpad('time in component environment (millisecond)'); LEGEND_STATES(:,22) = strpad('V in component membrane (millivolt)'); LEGEND_CONSTANTS(:,133) = strpad('C in component membrane (picoF)'); LEGEND_CONSTANTS(:,134) = strpad('i_app in component membrane (picoA)'); LEGEND_ALGEBRAIC(:,65) = strpad('i_NaP in component persistent_sodium_current (picoA)'); LEGEND_ALGEBRAIC(:,50) = strpad('i_Na in component fast_sodium_current (picoA)'); LEGEND_ALGEBRAIC(:,55) = strpad('i_K in component potassium_current (picoA)'); LEGEND_ALGEBRAIC(:,70) = strpad('i_L in component leakage_current (picoA)'); LEGEND_ALGEBRAIC(:,75) = strpad('i_tonic_e in component tonic_current (picoA)'); LEGEND_ALGEBRAIC(:,80) = strpad('i_syn_e in component synaptic_input (picoA)'); LEGEND_CONSTANTS(:,135) = strpad('E_Na in component fast_sodium_current (millivolt)'); LEGEND_CONSTANTS(:,136) = strpad('g_Na in component fast_sodium_current (nanoS)'); LEGEND_ALGEBRAIC(:,42) = strpad('m_infinity in component fast_sodium_current_m_gate (dimensionless)'); LEGEND_STATES(:,23) = strpad('n in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_CONSTANTS(:,137) = strpad('theta_m in component fast_sodium_current_m_gate (millivolt)'); LEGEND_CONSTANTS(:,138) = strpad('sigma_m in component fast_sodium_current_m_gate (millivolt)'); LEGEND_ALGEBRAIC(:,22) = strpad('n_infinity in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,43) = strpad('tau_n in component fast_sodium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,139) = strpad('tau_n_max in component fast_sodium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,140) = strpad('theta_n in component fast_sodium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,141) = strpad('sigma_n in component fast_sodium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,142) = strpad('g_K in component potassium_current (nanoS)'); LEGEND_CONSTANTS(:,143) = strpad('E_K in component potassium_current (millivolt)'); LEGEND_STATES(:,24) = strpad('n in component potassium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,23) = strpad('n_infinity in component potassium_current_n_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,44) = strpad('tau_n in component potassium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,144) = strpad('tau_n_max in component potassium_current_n_gate (millisecond)'); LEGEND_CONSTANTS(:,145) = strpad('theta_n in component potassium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,146) = strpad('sigma_n in component potassium_current_n_gate (millivolt)'); LEGEND_CONSTANTS(:,147) = strpad('g_NaP in component persistent_sodium_current (nanoS)'); LEGEND_ALGEBRAIC(:,60) = strpad('m_infinity in component persistent_sodium_current_m_gate (dimensionless)'); LEGEND_STATES(:,25) = strpad('h in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_CONSTANTS(:,148) = strpad('theta_m in component persistent_sodium_current_m_gate (millivolt)'); LEGEND_CONSTANTS(:,149) = strpad('sigma_m in component persistent_sodium_current_m_gate (millivolt)'); LEGEND_ALGEBRAIC(:,24) = strpad('h_infinity in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_ALGEBRAIC(:,45) = strpad('tau_h in component persistent_sodium_current_h_gate (millisecond)'); LEGEND_CONSTANTS(:,150) = strpad('tau_h_max in component persistent_sodium_current_h_gate (millisecond)'); LEGEND_CONSTANTS(:,151) = strpad('theta_h in component persistent_sodium_current_h_gate (millivolt)'); LEGEND_CONSTANTS(:,152) = strpad('sigma_h in component persistent_sodium_current_h_gate (millivolt)'); LEGEND_CONSTANTS(:,153) = strpad('g_L in component leakage_current (nanoS)'); LEGEND_CONSTANTS(:,154) = strpad('E_L in component leakage_current (millivolt)'); LEGEND_CONSTANTS(:,155) = strpad('E_syn_e in component tonic_current (millivolt)'); LEGEND_CONSTANTS(:,156) = strpad('g_tonic_e in component tonic_current (nanoS)'); LEGEND_ALGEBRAIC(:,25) = strpad('s_infinity in component synaptic_input (dimensionless)'); LEGEND_CONSTANTS(:,157) = strpad('kr in component synaptic_input (dimensionless)'); LEGEND_CONSTANTS(:,158) = strpad('tau_s in component synaptic_input (millisecond)'); LEGEND_CONSTANTS(:,159) = strpad('sigma_s in component synaptic_input (millivolt)'); LEGEND_CONSTANTS(:,160) = strpad('theta_s in component synaptic_input (millivolt)'); LEGEND_RATES(:,6) = strpad('d/dt V in component membrane (millivolt)'); LEGEND_RATES(:,7) = strpad('d/dt n in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_RATES(:,8) = strpad('d/dt n in component potassium_current_n_gate (dimensionless)'); LEGEND_RATES(:,9) = strpad('d/dt h in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_RATES(:,1) = strpad('d/dt s in component synaptic_input (dimensionless)'); LEGEND_RATES(:,10) = strpad('d/dt V in component membrane (millivolt)'); LEGEND_RATES(:,11) = strpad('d/dt n in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_RATES(:,12) = strpad('d/dt n in component potassium_current_n_gate (dimensionless)'); LEGEND_RATES(:,13) = strpad('d/dt h in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_RATES(:,2) = strpad('d/dt s in component synaptic_input (dimensionless)'); LEGEND_RATES(:,14) = strpad('d/dt V in component membrane (millivolt)'); LEGEND_RATES(:,15) = strpad('d/dt n in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_RATES(:,16) = strpad('d/dt n in component potassium_current_n_gate (dimensionless)'); LEGEND_RATES(:,17) = strpad('d/dt h in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_RATES(:,3) = strpad('d/dt s in component synaptic_input (dimensionless)'); LEGEND_RATES(:,18) = strpad('d/dt V in component membrane (millivolt)'); LEGEND_RATES(:,19) = strpad('d/dt n in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_RATES(:,20) = strpad('d/dt n in component potassium_current_n_gate (dimensionless)'); LEGEND_RATES(:,21) = strpad('d/dt h in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_RATES(:,4) = strpad('d/dt s in component synaptic_input (dimensionless)'); LEGEND_RATES(:,22) = strpad('d/dt V in component membrane (millivolt)'); LEGEND_RATES(:,23) = strpad('d/dt n in component fast_sodium_current_n_gate (dimensionless)'); LEGEND_RATES(:,24) = strpad('d/dt n in component potassium_current_n_gate (dimensionless)'); LEGEND_RATES(:,25) = strpad('d/dt h in component persistent_sodium_current_h_gate (dimensionless)'); LEGEND_RATES(:,5) = strpad('d/dt s in component synaptic_input (dimensionless)'); LEGEND_STATES = LEGEND_STATES'; LEGEND_ALGEBRAIC = LEGEND_ALGEBRAIC'; LEGEND_RATES = LEGEND_RATES'; LEGEND_CONSTANTS = LEGEND_CONSTANTS'; end function [STATES, CONSTANTS] = initConsts() VOI = 0; CONSTANTS = []; STATES = []; ALGEBRAIC = []; CONSTANTS(:,1) = 0.10; CONSTANTS(:,2) = 0.10; CONSTANTS(:,3) = 0.10; CONSTANTS(:,4) = 0.10; CONSTANTS(:,5) = 0.10; CONSTANTS(:,6) = 0.10; CONSTANTS(:,7) = 0.10; CONSTANTS(:,8) = 0.10; CONSTANTS(:,9) = 0.10; CONSTANTS(:,10) = 0.10; CONSTANTS(:,11) = 0.10; CONSTANTS(:,12) = 0.10; CONSTANTS(:,13) = 0.10; CONSTANTS(:,14) = 0.10; CONSTANTS(:,15) = 0.10; CONSTANTS(:,16) = 0.10; CONSTANTS(:,17) = 0.10; CONSTANTS(:,18) = 0.10; CONSTANTS(:,19) = 0.10; CONSTANTS(:,20) = 0.10; STATES(:,1) = 1; STATES(:,2) = 1; STATES(:,3) = 1; STATES(:,4) = 1; STATES(:,5) = 1; STATES(:,6) = -50.0; CONSTANTS(:,21) = 21.0; CONSTANTS(:,22) = 0.0; CONSTANTS(:,23) = 50.0; CONSTANTS(:,24) = 28.0; STATES(:,7) = 0.01; CONSTANTS(:,25) = -34.0; CONSTANTS(:,26) = -5.0; CONSTANTS(:,27) = 10.0; CONSTANTS(:,28) = -29.0; CONSTANTS(:,29) = -4.0; CONSTANTS(:,30) = 11.2; CONSTANTS(:,31) = -85.0; STATES(:,8) = 0.01; CONSTANTS(:,32) = 10.0; CONSTANTS(:,33) = -29.0; CONSTANTS(:,34) = -4.0; CONSTANTS(:,35) = 2.8; STATES(:,9) = 0.46; CONSTANTS(:,36) = -40.0; CONSTANTS(:,37) = -6.0; CONSTANTS(:,38) = 10000.0; CONSTANTS(:,39) = -48.0; CONSTANTS(:,40) = 6.0; CONSTANTS(:,41) = 2.8; CONSTANTS(:,42) = -57.5; CONSTANTS(:,43) = 0.0; CONSTANTS(:,44) = 0.0; CONSTANTS(:,45) = 1.0; CONSTANTS(:,46) = 5.0; CONSTANTS(:,47) = -5.0; CONSTANTS(:,48) = -10.0; STATES(:,10) = -50.0; CONSTANTS(:,49) = 21.0; CONSTANTS(:,50) = 0.0; CONSTANTS(:,51) = 50.0; CONSTANTS(:,52) = 28.0; STATES(:,11) = 0.01; CONSTANTS(:,53) = -34.0; CONSTANTS(:,54) = -5.0; CONSTANTS(:,55) = 10.0; CONSTANTS(:,56) = -29.0; CONSTANTS(:,57) = -4.0; CONSTANTS(:,58) = 11.2; CONSTANTS(:,59) = -85.0; STATES(:,12) = 0.01; CONSTANTS(:,60) = 10.0; CONSTANTS(:,61) = -29.0; CONSTANTS(:,62) = -4.0; CONSTANTS(:,63) = 2.8; STATES(:,13) = 0.46; CONSTANTS(:,64) = -40.0; CONSTANTS(:,65) = -6.0; CONSTANTS(:,66) = 10000.0; CONSTANTS(:,67) = -48.0; CONSTANTS(:,68) = 6.0; CONSTANTS(:,69) = 2.8; CONSTANTS(:,70) = -57.5; CONSTANTS(:,71) = 0.0; CONSTANTS(:,72) = 0.0; CONSTANTS(:,73) = 1.0; CONSTANTS(:,74) = 5.0; CONSTANTS(:,75) = -5.0; CONSTANTS(:,76) = -10.0; STATES(:,14) = -50.0; CONSTANTS(:,77) = 21.0; CONSTANTS(:,78) = 0.0; CONSTANTS(:,79) = 50.0; CONSTANTS(:,80) = 28.0; STATES(:,15) = 0.01; CONSTANTS(:,81) = -34.0; CONSTANTS(:,82) = -5.0; CONSTANTS(:,83) = 10.0; CONSTANTS(:,84) = -29.0; CONSTANTS(:,85) = -4.0; CONSTANTS(:,86) = 11.2; CONSTANTS(:,87) = -85.0; STATES(:,16) = 0.01; CONSTANTS(:,88) = 10.0; CONSTANTS(:,89) = -29.0; CONSTANTS(:,90) = -4.0; CONSTANTS(:,91) = 2.8; STATES(:,17) = 0.46; CONSTANTS(:,92) = -40.0; CONSTANTS(:,93) = -6.0; CONSTANTS(:,94) = 10000.0; CONSTANTS(:,95) = -48.0; CONSTANTS(:,96) = 6.0; CONSTANTS(:,97) = 2.8; CONSTANTS(:,98) = -57.5; CONSTANTS(:,99) = 0.0; CONSTANTS(:,100) = 0.0; CONSTANTS(:,101) = 1.0; CONSTANTS(:,102) = 5.0; CONSTANTS(:,103) = -5.0; CONSTANTS(:,104) = -10.0; STATES(:,18) = -50.0; CONSTANTS(:,105) = 21.0; CONSTANTS(:,106) = 0.0; CONSTANTS(:,107) = 50.0; CONSTANTS(:,108) = 28.0; STATES(:,19) = 0.01; CONSTANTS(:,109) = -34.0; CONSTANTS(:,110) = -5.0; CONSTANTS(:,111) = 10.0; CONSTANTS(:,112) = -29.0; CONSTANTS(:,113) = -4.0; CONSTANTS(:,114) = 11.2; CONSTANTS(:,115) = -85.0; STATES(:,20) = 0.01; CONSTANTS(:,116) = 10.0; CONSTANTS(:,117) = -29.0; CONSTANTS(:,118) = -4.0; CONSTANTS(:,119) = 2.8; STATES(:,21) = 0.46; CONSTANTS(:,120) = -40.0; CONSTANTS(:,121) = -6.0; CONSTANTS(:,122) = 10000.0; CONSTANTS(:,123) = -48.0; CONSTANTS(:,124) = 6.0; CONSTANTS(:,125) = 2.8; CONSTANTS(:,126) = -57.5; CONSTANTS(:,127) = 0.0; CONSTANTS(:,128) = 0.0; CONSTANTS(:,129) = 1.0; CONSTANTS(:,130) = 5.0; CONSTANTS(:,131) = -5.0; CONSTANTS(:,132) = -10.0; STATES(:,22) = -50.0; CONSTANTS(:,133) = 21.0; CONSTANTS(:,134) = 0.0; CONSTANTS(:,135) = 50.0; CONSTANTS(:,136) = 28.0; STATES(:,23) = 0.01; CONSTANTS(:,137) = -34.0; CONSTANTS(:,138) = -5.0; CONSTANTS(:,139) = 10.0; CONSTANTS(:,140) = -29.0; CONSTANTS(:,141) = -4.0; CONSTANTS(:,142) = 11.2; CONSTANTS(:,143) = -85.0; STATES(:,24) = 0.01; CONSTANTS(:,144) = 10.0; CONSTANTS(:,145) = -29.0; CONSTANTS(:,146) = -4.0; CONSTANTS(:,147) = 2.8; STATES(:,25) = 0.46; CONSTANTS(:,148) = -40.0; CONSTANTS(:,149) = -6.0; CONSTANTS(:,150) = 10000.0; CONSTANTS(:,151) = -48.0; CONSTANTS(:,152) = 6.0; CONSTANTS(:,153) = 2.8; CONSTANTS(:,154) = -57.5; CONSTANTS(:,155) = 0.0; CONSTANTS(:,156) = 0.0; CONSTANTS(:,157) = 1.0; CONSTANTS(:,158) = 5.0; CONSTANTS(:,159) = -5.0; CONSTANTS(:,160) = -10.0; 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(:,5) = 1.00000./(1.00000+exp((STATES(:,6) - CONSTANTS(:,48))./CONSTANTS(:,47))); RATES(:,1) = ( (1.00000 - STATES(:,1)).*ALGEBRAIC(:,5) - - ( CONSTANTS(:,45).*STATES(:,1)))./CONSTANTS(:,46); ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,10) - CONSTANTS(:,76))./CONSTANTS(:,75))); RATES(:,2) = ( (1.00000 - STATES(:,2)).*ALGEBRAIC(:,10) - - ( CONSTANTS(:,73).*STATES(:,2)))./CONSTANTS(:,74); ALGEBRAIC(:,15) = 1.00000./(1.00000+exp((STATES(:,14) - CONSTANTS(:,104))./CONSTANTS(:,103))); RATES(:,3) = ( (1.00000 - STATES(:,3)).*ALGEBRAIC(:,15) - - ( CONSTANTS(:,101).*STATES(:,3)))./CONSTANTS(:,102); ALGEBRAIC(:,20) = 1.00000./(1.00000+exp((STATES(:,18) - CONSTANTS(:,132))./CONSTANTS(:,131))); RATES(:,4) = ( (1.00000 - STATES(:,4)).*ALGEBRAIC(:,20) - - ( CONSTANTS(:,129).*STATES(:,4)))./CONSTANTS(:,130); ALGEBRAIC(:,25) = 1.00000./(1.00000+exp((STATES(:,22) - CONSTANTS(:,160))./CONSTANTS(:,159))); RATES(:,5) = ( (1.00000 - STATES(:,5)).*ALGEBRAIC(:,25) - - ( CONSTANTS(:,157).*STATES(:,5)))./CONSTANTS(:,158); ALGEBRAIC(:,2) = 1.00000./(1.00000+exp((STATES(:,6) - CONSTANTS(:,28))./CONSTANTS(:,29))); ALGEBRAIC(:,27) = CONSTANTS(:,27)./cosh((STATES(:,6) - CONSTANTS(:,28))./( 2.00000.*CONSTANTS(:,29))); RATES(:,7) = (ALGEBRAIC(:,2) - STATES(:,7))./ALGEBRAIC(:,27); ALGEBRAIC(:,3) = 1.00000./(1.00000+exp((STATES(:,6) - CONSTANTS(:,33))./CONSTANTS(:,34))); ALGEBRAIC(:,28) = CONSTANTS(:,32)./cosh((STATES(:,6) - CONSTANTS(:,33))./( 2.00000.*CONSTANTS(:,34))); RATES(:,8) = (ALGEBRAIC(:,3) - STATES(:,8))./ALGEBRAIC(:,28); ALGEBRAIC(:,4) = 1.00000./(1.00000+exp((STATES(:,6) - CONSTANTS(:,39))./CONSTANTS(:,40))); ALGEBRAIC(:,29) = CONSTANTS(:,38)./cosh((STATES(:,6) - CONSTANTS(:,39))./( 2.00000.*CONSTANTS(:,40))); RATES(:,9) = (ALGEBRAIC(:,4) - STATES(:,9))./ALGEBRAIC(:,29); ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,10) - CONSTANTS(:,56))./CONSTANTS(:,57))); ALGEBRAIC(:,31) = CONSTANTS(:,55)./cosh((STATES(:,10) - CONSTANTS(:,56))./( 2.00000.*CONSTANTS(:,57))); RATES(:,11) = (ALGEBRAIC(:,7) - STATES(:,11))./ALGEBRAIC(:,31); ALGEBRAIC(:,8) = 1.00000./(1.00000+exp((STATES(:,10) - CONSTANTS(:,61))./CONSTANTS(:,62))); ALGEBRAIC(:,32) = CONSTANTS(:,60)./cosh((STATES(:,10) - CONSTANTS(:,61))./( 2.00000.*CONSTANTS(:,62))); RATES(:,12) = (ALGEBRAIC(:,8) - STATES(:,12))./ALGEBRAIC(:,32); ALGEBRAIC(:,9) = 1.00000./(1.00000+exp((STATES(:,10) - CONSTANTS(:,67))./CONSTANTS(:,68))); ALGEBRAIC(:,33) = CONSTANTS(:,66)./cosh((STATES(:,10) - CONSTANTS(:,67))./( 2.00000.*CONSTANTS(:,68))); RATES(:,13) = (ALGEBRAIC(:,9) - STATES(:,13))./ALGEBRAIC(:,33); ALGEBRAIC(:,12) = 1.00000./(1.00000+exp((STATES(:,14) - CONSTANTS(:,84))./CONSTANTS(:,85))); ALGEBRAIC(:,35) = CONSTANTS(:,83)./cosh((STATES(:,14) - CONSTANTS(:,84))./( 2.00000.*CONSTANTS(:,85))); RATES(:,15) = (ALGEBRAIC(:,12) - STATES(:,15))./ALGEBRAIC(:,35); ALGEBRAIC(:,13) = 1.00000./(1.00000+exp((STATES(:,14) - CONSTANTS(:,89))./CONSTANTS(:,90))); ALGEBRAIC(:,36) = CONSTANTS(:,88)./cosh((STATES(:,14) - CONSTANTS(:,89))./( 2.00000.*CONSTANTS(:,90))); RATES(:,16) = (ALGEBRAIC(:,13) - STATES(:,16))./ALGEBRAIC(:,36); ALGEBRAIC(:,14) = 1.00000./(1.00000+exp((STATES(:,14) - CONSTANTS(:,95))./CONSTANTS(:,96))); ALGEBRAIC(:,37) = CONSTANTS(:,94)./cosh((STATES(:,14) - CONSTANTS(:,95))./( 2.00000.*CONSTANTS(:,96))); RATES(:,17) = (ALGEBRAIC(:,14) - STATES(:,17))./ALGEBRAIC(:,37); ALGEBRAIC(:,17) = 1.00000./(1.00000+exp((STATES(:,18) - CONSTANTS(:,112))./CONSTANTS(:,113))); ALGEBRAIC(:,39) = CONSTANTS(:,111)./cosh((STATES(:,18) - CONSTANTS(:,112))./( 2.00000.*CONSTANTS(:,113))); RATES(:,19) = (ALGEBRAIC(:,17) - STATES(:,19))./ALGEBRAIC(:,39); ALGEBRAIC(:,18) = 1.00000./(1.00000+exp((STATES(:,18) - CONSTANTS(:,117))./CONSTANTS(:,118))); ALGEBRAIC(:,40) = CONSTANTS(:,116)./cosh((STATES(:,18) - CONSTANTS(:,117))./( 2.00000.*CONSTANTS(:,118))); RATES(:,20) = (ALGEBRAIC(:,18) - STATES(:,20))./ALGEBRAIC(:,40); ALGEBRAIC(:,19) = 1.00000./(1.00000+exp((STATES(:,18) - CONSTANTS(:,123))./CONSTANTS(:,124))); ALGEBRAIC(:,41) = CONSTANTS(:,122)./cosh((STATES(:,18) - CONSTANTS(:,123))./( 2.00000.*CONSTANTS(:,124))); RATES(:,21) = (ALGEBRAIC(:,19) - STATES(:,21))./ALGEBRAIC(:,41); ALGEBRAIC(:,22) = 1.00000./(1.00000+exp((STATES(:,22) - CONSTANTS(:,140))./CONSTANTS(:,141))); ALGEBRAIC(:,43) = CONSTANTS(:,139)./cosh((STATES(:,22) - CONSTANTS(:,140))./( 2.00000.*CONSTANTS(:,141))); RATES(:,23) = (ALGEBRAIC(:,22) - STATES(:,23))./ALGEBRAIC(:,43); ALGEBRAIC(:,23) = 1.00000./(1.00000+exp((STATES(:,22) - CONSTANTS(:,145))./CONSTANTS(:,146))); ALGEBRAIC(:,44) = CONSTANTS(:,144)./cosh((STATES(:,22) - CONSTANTS(:,145))./( 2.00000.*CONSTANTS(:,146))); RATES(:,24) = (ALGEBRAIC(:,23) - STATES(:,24))./ALGEBRAIC(:,44); ALGEBRAIC(:,24) = 1.00000./(1.00000+exp((STATES(:,22) - CONSTANTS(:,151))./CONSTANTS(:,152))); ALGEBRAIC(:,45) = CONSTANTS(:,150)./cosh((STATES(:,22) - CONSTANTS(:,151))./( 2.00000.*CONSTANTS(:,152))); RATES(:,25) = (ALGEBRAIC(:,24) - STATES(:,25))./ALGEBRAIC(:,45); ALGEBRAIC(:,56) = 1.00000./(1.00000+exp((STATES(:,6) - CONSTANTS(:,36))./CONSTANTS(:,37))); ALGEBRAIC(:,61) = CONSTANTS(:,35).*ALGEBRAIC(:,56).*STATES(:,9).*(STATES(:,6) - CONSTANTS(:,23)); ALGEBRAIC(:,26) = 1.00000./(1.00000+exp((STATES(:,6) - CONSTANTS(:,25))./CONSTANTS(:,26))); ALGEBRAIC(:,46) = CONSTANTS(:,24).*power(ALGEBRAIC(:,26), 3.00000).*(1.00000 - STATES(:,7)).*(STATES(:,6) - CONSTANTS(:,23)); ALGEBRAIC(:,51) = CONSTANTS(:,30).*power(STATES(:,8), 4.00000).*(STATES(:,6) - CONSTANTS(:,31)); ALGEBRAIC(:,66) = CONSTANTS(:,41).*(STATES(:,6) - CONSTANTS(:,42)); ALGEBRAIC(:,71) = CONSTANTS(:,44).*(STATES(:,6) - CONSTANTS(:,43)); ALGEBRAIC(:,1) = CONSTANTS(:,1).*STATES(:,1)+ CONSTANTS(:,2).*STATES(:,1)+ CONSTANTS(:,3).*STATES(:,1)+ CONSTANTS(:,4).*STATES(:,1); ALGEBRAIC(:,76) = ALGEBRAIC(:,1).*(STATES(:,6) - CONSTANTS(:,43)); RATES(:,6) = ( - (ALGEBRAIC(:,61)+ALGEBRAIC(:,46)+ALGEBRAIC(:,51)+ALGEBRAIC(:,66)+ALGEBRAIC(:,71)+ALGEBRAIC(:,76))+CONSTANTS(:,22))./CONSTANTS(:,21); ALGEBRAIC(:,57) = 1.00000./(1.00000+exp((STATES(:,10) - CONSTANTS(:,64))./CONSTANTS(:,65))); ALGEBRAIC(:,62) = CONSTANTS(:,63).*ALGEBRAIC(:,57).*STATES(:,13).*(STATES(:,10) - CONSTANTS(:,51)); ALGEBRAIC(:,30) = 1.00000./(1.00000+exp((STATES(:,10) - CONSTANTS(:,53))./CONSTANTS(:,54))); ALGEBRAIC(:,47) = CONSTANTS(:,52).*power(ALGEBRAIC(:,30), 3.00000).*(1.00000 - STATES(:,11)).*(STATES(:,10) - CONSTANTS(:,51)); ALGEBRAIC(:,52) = CONSTANTS(:,58).*power(STATES(:,12), 4.00000).*(STATES(:,10) - CONSTANTS(:,59)); ALGEBRAIC(:,67) = CONSTANTS(:,69).*(STATES(:,10) - CONSTANTS(:,70)); ALGEBRAIC(:,72) = CONSTANTS(:,72).*(STATES(:,10) - CONSTANTS(:,71)); ALGEBRAIC(:,6) = CONSTANTS(:,5).*STATES(:,2)+ CONSTANTS(:,6).*STATES(:,2)+ CONSTANTS(:,7).*STATES(:,2)+ CONSTANTS(:,8).*STATES(:,2); ALGEBRAIC(:,77) = ALGEBRAIC(:,6).*(STATES(:,10) - CONSTANTS(:,71)); RATES(:,10) = ( - (ALGEBRAIC(:,62)+ALGEBRAIC(:,47)+ALGEBRAIC(:,52)+ALGEBRAIC(:,67)+ALGEBRAIC(:,72)+ALGEBRAIC(:,77))+CONSTANTS(:,50))./CONSTANTS(:,49); ALGEBRAIC(:,58) = 1.00000./(1.00000+exp((STATES(:,14) - CONSTANTS(:,92))./CONSTANTS(:,93))); ALGEBRAIC(:,63) = CONSTANTS(:,91).*ALGEBRAIC(:,58).*STATES(:,17).*(STATES(:,14) - CONSTANTS(:,79)); ALGEBRAIC(:,34) = 1.00000./(1.00000+exp((STATES(:,14) - CONSTANTS(:,81))./CONSTANTS(:,82))); ALGEBRAIC(:,48) = CONSTANTS(:,80).*power(ALGEBRAIC(:,34), 3.00000).*(1.00000 - STATES(:,15)).*(STATES(:,14) - CONSTANTS(:,79)); ALGEBRAIC(:,53) = CONSTANTS(:,86).*power(STATES(:,16), 4.00000).*(STATES(:,14) - CONSTANTS(:,87)); ALGEBRAIC(:,68) = CONSTANTS(:,97).*(STATES(:,14) - CONSTANTS(:,98)); ALGEBRAIC(:,73) = CONSTANTS(:,100).*(STATES(:,14) - CONSTANTS(:,99)); ALGEBRAIC(:,11) = CONSTANTS(:,9).*STATES(:,3)+ CONSTANTS(:,10).*STATES(:,3)+ CONSTANTS(:,11).*STATES(:,3)+ CONSTANTS(:,12).*STATES(:,3); ALGEBRAIC(:,78) = ALGEBRAIC(:,11).*(STATES(:,14) - CONSTANTS(:,99)); RATES(:,14) = ( - (ALGEBRAIC(:,63)+ALGEBRAIC(:,48)+ALGEBRAIC(:,53)+ALGEBRAIC(:,68)+ALGEBRAIC(:,73)+ALGEBRAIC(:,78))+CONSTANTS(:,78))./CONSTANTS(:,77); ALGEBRAIC(:,59) = 1.00000./(1.00000+exp((STATES(:,18) - CONSTANTS(:,120))./CONSTANTS(:,121))); ALGEBRAIC(:,64) = CONSTANTS(:,119).*ALGEBRAIC(:,59).*STATES(:,21).*(STATES(:,18) - CONSTANTS(:,107)); ALGEBRAIC(:,38) = 1.00000./(1.00000+exp((STATES(:,18) - CONSTANTS(:,109))./CONSTANTS(:,110))); ALGEBRAIC(:,49) = CONSTANTS(:,108).*power(ALGEBRAIC(:,38), 3.00000).*(1.00000 - STATES(:,19)).*(STATES(:,18) - CONSTANTS(:,107)); ALGEBRAIC(:,54) = CONSTANTS(:,114).*power(STATES(:,20), 4.00000).*(STATES(:,18) - CONSTANTS(:,115)); ALGEBRAIC(:,69) = CONSTANTS(:,125).*(STATES(:,18) - CONSTANTS(:,126)); ALGEBRAIC(:,74) = CONSTANTS(:,128).*(STATES(:,18) - CONSTANTS(:,127)); ALGEBRAIC(:,16) = CONSTANTS(:,13).*STATES(:,4)+ CONSTANTS(:,14).*STATES(:,4)+ CONSTANTS(:,15).*STATES(:,4)+ CONSTANTS(:,16).*STATES(:,4); ALGEBRAIC(:,79) = ALGEBRAIC(:,16).*(STATES(:,18) - CONSTANTS(:,127)); RATES(:,18) = ( - (ALGEBRAIC(:,64)+ALGEBRAIC(:,49)+ALGEBRAIC(:,54)+ALGEBRAIC(:,69)+ALGEBRAIC(:,74)+ALGEBRAIC(:,79))+CONSTANTS(:,106))./CONSTANTS(:,105); ALGEBRAIC(:,60) = 1.00000./(1.00000+exp((STATES(:,22) - CONSTANTS(:,148))./CONSTANTS(:,149))); ALGEBRAIC(:,65) = CONSTANTS(:,147).*ALGEBRAIC(:,60).*STATES(:,25).*(STATES(:,22) - CONSTANTS(:,135)); ALGEBRAIC(:,42) = 1.00000./(1.00000+exp((STATES(:,22) - CONSTANTS(:,137))./CONSTANTS(:,138))); ALGEBRAIC(:,50) = CONSTANTS(:,136).*power(ALGEBRAIC(:,42), 3.00000).*(1.00000 - STATES(:,23)).*(STATES(:,22) - CONSTANTS(:,135)); ALGEBRAIC(:,55) = CONSTANTS(:,142).*power(STATES(:,24), 4.00000).*(STATES(:,22) - CONSTANTS(:,143)); ALGEBRAIC(:,70) = CONSTANTS(:,153).*(STATES(:,22) - CONSTANTS(:,154)); ALGEBRAIC(:,75) = CONSTANTS(:,156).*(STATES(:,22) - CONSTANTS(:,155)); ALGEBRAIC(:,21) = CONSTANTS(:,17).*STATES(:,5)+ CONSTANTS(:,18).*STATES(:,5)+ CONSTANTS(:,19).*STATES(:,5)+ CONSTANTS(:,20).*STATES(:,5); ALGEBRAIC(:,80) = ALGEBRAIC(:,21).*(STATES(:,22) - CONSTANTS(:,155)); RATES(:,22) = ( - (ALGEBRAIC(:,65)+ALGEBRAIC(:,50)+ALGEBRAIC(:,55)+ALGEBRAIC(:,70)+ALGEBRAIC(:,75)+ALGEBRAIC(:,80))+CONSTANTS(:,134))./CONSTANTS(:,133); 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(:,5) = 1.00000./(1.00000+exp((STATES(:,6) - CONSTANTS(:,48))./CONSTANTS(:,47))); ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,10) - CONSTANTS(:,76))./CONSTANTS(:,75))); ALGEBRAIC(:,15) = 1.00000./(1.00000+exp((STATES(:,14) - CONSTANTS(:,104))./CONSTANTS(:,103))); ALGEBRAIC(:,20) = 1.00000./(1.00000+exp((STATES(:,18) - CONSTANTS(:,132))./CONSTANTS(:,131))); ALGEBRAIC(:,25) = 1.00000./(1.00000+exp((STATES(:,22) - CONSTANTS(:,160))./CONSTANTS(:,159))); ALGEBRAIC(:,2) = 1.00000./(1.00000+exp((STATES(:,6) - CONSTANTS(:,28))./CONSTANTS(:,29))); ALGEBRAIC(:,27) = CONSTANTS(:,27)./cosh((STATES(:,6) - CONSTANTS(:,28))./( 2.00000.*CONSTANTS(:,29))); ALGEBRAIC(:,3) = 1.00000./(1.00000+exp((STATES(:,6) - CONSTANTS(:,33))./CONSTANTS(:,34))); ALGEBRAIC(:,28) = CONSTANTS(:,32)./cosh((STATES(:,6) - CONSTANTS(:,33))./( 2.00000.*CONSTANTS(:,34))); ALGEBRAIC(:,4) = 1.00000./(1.00000+exp((STATES(:,6) - CONSTANTS(:,39))./CONSTANTS(:,40))); ALGEBRAIC(:,29) = CONSTANTS(:,38)./cosh((STATES(:,6) - CONSTANTS(:,39))./( 2.00000.*CONSTANTS(:,40))); ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,10) - CONSTANTS(:,56))./CONSTANTS(:,57))); ALGEBRAIC(:,31) = CONSTANTS(:,55)./cosh((STATES(:,10) - CONSTANTS(:,56))./( 2.00000.*CONSTANTS(:,57))); ALGEBRAIC(:,8) = 1.00000./(1.00000+exp((STATES(:,10) - CONSTANTS(:,61))./CONSTANTS(:,62))); ALGEBRAIC(:,32) = CONSTANTS(:,60)./cosh((STATES(:,10) - CONSTANTS(:,61))./( 2.00000.*CONSTANTS(:,62))); ALGEBRAIC(:,9) = 1.00000./(1.00000+exp((STATES(:,10) - CONSTANTS(:,67))./CONSTANTS(:,68))); ALGEBRAIC(:,33) = CONSTANTS(:,66)./cosh((STATES(:,10) - CONSTANTS(:,67))./( 2.00000.*CONSTANTS(:,68))); ALGEBRAIC(:,12) = 1.00000./(1.00000+exp((STATES(:,14) - CONSTANTS(:,84))./CONSTANTS(:,85))); ALGEBRAIC(:,35) = CONSTANTS(:,83)./cosh((STATES(:,14) - CONSTANTS(:,84))./( 2.00000.*CONSTANTS(:,85))); ALGEBRAIC(:,13) = 1.00000./(1.00000+exp((STATES(:,14) - CONSTANTS(:,89))./CONSTANTS(:,90))); ALGEBRAIC(:,36) = CONSTANTS(:,88)./cosh((STATES(:,14) - CONSTANTS(:,89))./( 2.00000.*CONSTANTS(:,90))); ALGEBRAIC(:,14) = 1.00000./(1.00000+exp((STATES(:,14) - CONSTANTS(:,95))./CONSTANTS(:,96))); ALGEBRAIC(:,37) = CONSTANTS(:,94)./cosh((STATES(:,14) - CONSTANTS(:,95))./( 2.00000.*CONSTANTS(:,96))); ALGEBRAIC(:,17) = 1.00000./(1.00000+exp((STATES(:,18) - CONSTANTS(:,112))./CONSTANTS(:,113))); ALGEBRAIC(:,39) = CONSTANTS(:,111)./cosh((STATES(:,18) - CONSTANTS(:,112))./( 2.00000.*CONSTANTS(:,113))); ALGEBRAIC(:,18) = 1.00000./(1.00000+exp((STATES(:,18) - CONSTANTS(:,117))./CONSTANTS(:,118))); ALGEBRAIC(:,40) = CONSTANTS(:,116)./cosh((STATES(:,18) - CONSTANTS(:,117))./( 2.00000.*CONSTANTS(:,118))); ALGEBRAIC(:,19) = 1.00000./(1.00000+exp((STATES(:,18) - CONSTANTS(:,123))./CONSTANTS(:,124))); ALGEBRAIC(:,41) = CONSTANTS(:,122)./cosh((STATES(:,18) - CONSTANTS(:,123))./( 2.00000.*CONSTANTS(:,124))); ALGEBRAIC(:,22) = 1.00000./(1.00000+exp((STATES(:,22) - CONSTANTS(:,140))./CONSTANTS(:,141))); ALGEBRAIC(:,43) = CONSTANTS(:,139)./cosh((STATES(:,22) - CONSTANTS(:,140))./( 2.00000.*CONSTANTS(:,141))); ALGEBRAIC(:,23) = 1.00000./(1.00000+exp((STATES(:,22) - CONSTANTS(:,145))./CONSTANTS(:,146))); ALGEBRAIC(:,44) = CONSTANTS(:,144)./cosh((STATES(:,22) - CONSTANTS(:,145))./( 2.00000.*CONSTANTS(:,146))); ALGEBRAIC(:,24) = 1.00000./(1.00000+exp((STATES(:,22) - CONSTANTS(:,151))./CONSTANTS(:,152))); ALGEBRAIC(:,45) = CONSTANTS(:,150)./cosh((STATES(:,22) - CONSTANTS(:,151))./( 2.00000.*CONSTANTS(:,152))); ALGEBRAIC(:,56) = 1.00000./(1.00000+exp((STATES(:,6) - CONSTANTS(:,36))./CONSTANTS(:,37))); ALGEBRAIC(:,61) = CONSTANTS(:,35).*ALGEBRAIC(:,56).*STATES(:,9).*(STATES(:,6) - CONSTANTS(:,23)); ALGEBRAIC(:,26) = 1.00000./(1.00000+exp((STATES(:,6) - CONSTANTS(:,25))./CONSTANTS(:,26))); ALGEBRAIC(:,46) = CONSTANTS(:,24).*power(ALGEBRAIC(:,26), 3.00000).*(1.00000 - STATES(:,7)).*(STATES(:,6) - CONSTANTS(:,23)); ALGEBRAIC(:,51) = CONSTANTS(:,30).*power(STATES(:,8), 4.00000).*(STATES(:,6) - CONSTANTS(:,31)); ALGEBRAIC(:,66) = CONSTANTS(:,41).*(STATES(:,6) - CONSTANTS(:,42)); ALGEBRAIC(:,71) = CONSTANTS(:,44).*(STATES(:,6) - CONSTANTS(:,43)); ALGEBRAIC(:,1) = CONSTANTS(:,1).*STATES(:,1)+ CONSTANTS(:,2).*STATES(:,1)+ CONSTANTS(:,3).*STATES(:,1)+ CONSTANTS(:,4).*STATES(:,1); ALGEBRAIC(:,76) = ALGEBRAIC(:,1).*(STATES(:,6) - CONSTANTS(:,43)); ALGEBRAIC(:,57) = 1.00000./(1.00000+exp((STATES(:,10) - CONSTANTS(:,64))./CONSTANTS(:,65))); ALGEBRAIC(:,62) = CONSTANTS(:,63).*ALGEBRAIC(:,57).*STATES(:,13).*(STATES(:,10) - CONSTANTS(:,51)); ALGEBRAIC(:,30) = 1.00000./(1.00000+exp((STATES(:,10) - CONSTANTS(:,53))./CONSTANTS(:,54))); ALGEBRAIC(:,47) = CONSTANTS(:,52).*power(ALGEBRAIC(:,30), 3.00000).*(1.00000 - STATES(:,11)).*(STATES(:,10) - CONSTANTS(:,51)); ALGEBRAIC(:,52) = CONSTANTS(:,58).*power(STATES(:,12), 4.00000).*(STATES(:,10) - CONSTANTS(:,59)); ALGEBRAIC(:,67) = CONSTANTS(:,69).*(STATES(:,10) - CONSTANTS(:,70)); ALGEBRAIC(:,72) = CONSTANTS(:,72).*(STATES(:,10) - CONSTANTS(:,71)); ALGEBRAIC(:,6) = CONSTANTS(:,5).*STATES(:,2)+ CONSTANTS(:,6).*STATES(:,2)+ CONSTANTS(:,7).*STATES(:,2)+ CONSTANTS(:,8).*STATES(:,2); ALGEBRAIC(:,77) = ALGEBRAIC(:,6).*(STATES(:,10) - CONSTANTS(:,71)); ALGEBRAIC(:,58) = 1.00000./(1.00000+exp((STATES(:,14) - CONSTANTS(:,92))./CONSTANTS(:,93))); ALGEBRAIC(:,63) = CONSTANTS(:,91).*ALGEBRAIC(:,58).*STATES(:,17).*(STATES(:,14) - CONSTANTS(:,79)); ALGEBRAIC(:,34) = 1.00000./(1.00000+exp((STATES(:,14) - CONSTANTS(:,81))./CONSTANTS(:,82))); ALGEBRAIC(:,48) = CONSTANTS(:,80).*power(ALGEBRAIC(:,34), 3.00000).*(1.00000 - STATES(:,15)).*(STATES(:,14) - CONSTANTS(:,79)); ALGEBRAIC(:,53) = CONSTANTS(:,86).*power(STATES(:,16), 4.00000).*(STATES(:,14) - CONSTANTS(:,87)); ALGEBRAIC(:,68) = CONSTANTS(:,97).*(STATES(:,14) - CONSTANTS(:,98)); ALGEBRAIC(:,73) = CONSTANTS(:,100).*(STATES(:,14) - CONSTANTS(:,99)); ALGEBRAIC(:,11) = CONSTANTS(:,9).*STATES(:,3)+ CONSTANTS(:,10).*STATES(:,3)+ CONSTANTS(:,11).*STATES(:,3)+ CONSTANTS(:,12).*STATES(:,3); ALGEBRAIC(:,78) = ALGEBRAIC(:,11).*(STATES(:,14) - CONSTANTS(:,99)); ALGEBRAIC(:,59) = 1.00000./(1.00000+exp((STATES(:,18) - CONSTANTS(:,120))./CONSTANTS(:,121))); ALGEBRAIC(:,64) = CONSTANTS(:,119).*ALGEBRAIC(:,59).*STATES(:,21).*(STATES(:,18) - CONSTANTS(:,107)); ALGEBRAIC(:,38) = 1.00000./(1.00000+exp((STATES(:,18) - CONSTANTS(:,109))./CONSTANTS(:,110))); ALGEBRAIC(:,49) = CONSTANTS(:,108).*power(ALGEBRAIC(:,38), 3.00000).*(1.00000 - STATES(:,19)).*(STATES(:,18) - CONSTANTS(:,107)); ALGEBRAIC(:,54) = CONSTANTS(:,114).*power(STATES(:,20), 4.00000).*(STATES(:,18) - CONSTANTS(:,115)); ALGEBRAIC(:,69) = CONSTANTS(:,125).*(STATES(:,18) - CONSTANTS(:,126)); ALGEBRAIC(:,74) = CONSTANTS(:,128).*(STATES(:,18) - CONSTANTS(:,127)); ALGEBRAIC(:,16) = CONSTANTS(:,13).*STATES(:,4)+ CONSTANTS(:,14).*STATES(:,4)+ CONSTANTS(:,15).*STATES(:,4)+ CONSTANTS(:,16).*STATES(:,4); ALGEBRAIC(:,79) = ALGEBRAIC(:,16).*(STATES(:,18) - CONSTANTS(:,127)); ALGEBRAIC(:,60) = 1.00000./(1.00000+exp((STATES(:,22) - CONSTANTS(:,148))./CONSTANTS(:,149))); ALGEBRAIC(:,65) = CONSTANTS(:,147).*ALGEBRAIC(:,60).*STATES(:,25).*(STATES(:,22) - CONSTANTS(:,135)); ALGEBRAIC(:,42) = 1.00000./(1.00000+exp((STATES(:,22) - CONSTANTS(:,137))./CONSTANTS(:,138))); ALGEBRAIC(:,50) = CONSTANTS(:,136).*power(ALGEBRAIC(:,42), 3.00000).*(1.00000 - STATES(:,23)).*(STATES(:,22) - CONSTANTS(:,135)); ALGEBRAIC(:,55) = CONSTANTS(:,142).*power(STATES(:,24), 4.00000).*(STATES(:,22) - CONSTANTS(:,143)); ALGEBRAIC(:,70) = CONSTANTS(:,153).*(STATES(:,22) - CONSTANTS(:,154)); ALGEBRAIC(:,75) = CONSTANTS(:,156).*(STATES(:,22) - CONSTANTS(:,155)); ALGEBRAIC(:,21) = CONSTANTS(:,17).*STATES(:,5)+ CONSTANTS(:,18).*STATES(:,5)+ CONSTANTS(:,19).*STATES(:,5)+ CONSTANTS(:,20).*STATES(:,5); ALGEBRAIC(:,80) = ALGEBRAIC(:,21).*(STATES(:,22) - CONSTANTS(:,155)); 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