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 =26; end % There are a total of 12 entries in each of the rate and state variable arrays. % There are a total of 37 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 (second)'); LEGEND_STATES(:,1) = strpad('V_s in component soma_compartment (mV)'); LEGEND_CONSTANTS(:,1) = strpad('V_Na in component soma_compartment (mV)'); LEGEND_ALGEBRAIC(:,26) = strpad('I_Na_s in component soma_compartment (uA_per_cm2)'); LEGEND_ALGEBRAIC(:,1) = strpad('I_K_DR_s in component soma_compartment (uA_per_cm2)'); LEGEND_ALGEBRAIC(:,11) = strpad('I_Ca_T in component soma_compartment (uA_per_cm2)'); LEGEND_ALGEBRAIC(:,16) = strpad('I_K_Ca in component soma_compartment (uA_per_cm2)'); LEGEND_ALGEBRAIC(:,18) = strpad('I_A in component soma_compartment (uA_per_cm2)'); LEGEND_ALGEBRAIC(:,21) = strpad('I_h in component soma_compartment (uA_per_cm2)'); LEGEND_CONSTANTS(:,2) = strpad('g_Na_s in component soma_compartment (mS_per_cm2)'); LEGEND_CONSTANTS(:,3) = strpad('g_K_DR_s in component soma_compartment (mS_per_cm2)'); LEGEND_CONSTANTS(:,4) = strpad('g_Ca_T in component soma_compartment (mS_per_cm2)'); LEGEND_CONSTANTS(:,5) = strpad('g_K_Ca in component soma_compartment (mS_per_cm2)'); LEGEND_CONSTANTS(:,6) = strpad('g_A in component soma_compartment (mS_per_cm2)'); LEGEND_CONSTANTS(:,7) = strpad('g_h in component soma_compartment (mS_per_cm2)'); LEGEND_STATES(:,2) = strpad('Ca in component soma_compartment (mM)'); LEGEND_CONSTANTS(:,8) = strpad('k_Ca in component soma_compartment (per_second)'); LEGEND_CONSTANTS(:,9) = strpad('K_Ca in component soma_compartment (mM)'); LEGEND_CONSTANTS(:,10) = strpad('V_h in component soma_compartment (mV)'); LEGEND_CONSTANTS(:,11) = strpad('beta in component soma_compartment (mMcm2_per_uAs)'); LEGEND_CONSTANTS(:,12) = strpad('I_APP in component soma_compartment (uA_per_cm2)'); LEGEND_CONSTANTS(:,13) = strpad('V_Ca in component general_variables (mV)'); LEGEND_CONSTANTS(:,14) = strpad('V_K in component general_variables (mV)'); LEGEND_STATES(:,3) = strpad('n in component gating_variables (dimensionless)'); LEGEND_STATES(:,4) = strpad('h in component gating_variables (dimensionless)'); LEGEND_ALGEBRAIC(:,23) = strpad('m_infinity in component gating_variables (dimensionless)'); LEGEND_CONSTANTS(:,15) = strpad('g_c in component general_variables (mS_per_cm2)'); LEGEND_CONSTANTS(:,16) = strpad('p in component general_variables (dimensionless)'); LEGEND_STATES(:,5) = strpad('V_D in component dendritic_compartment (mV)'); LEGEND_CONSTANTS(:,17) = strpad('C_m in component general_variables (uF_per_cm2)'); LEGEND_STATES(:,6) = strpad('m_T in component gating_variables (dimensionless)'); LEGEND_STATES(:,7) = strpad('h_T in component gating_variables (dimensionless)'); LEGEND_STATES(:,8) = strpad('a in component gating_variables (dimensionless)'); LEGEND_STATES(:,9) = strpad('b in component gating_variables (dimensionless)'); LEGEND_STATES(:,10) = strpad('m_h in component gating_variables (dimensionless)'); LEGEND_STATES(:,11) = strpad('Na in component dendritic_compartment (mM)'); LEGEND_CONSTANTS(:,18) = strpad('K_p in component dendritic_compartment (mM)'); LEGEND_ALGEBRAIC(:,19) = strpad('I_L in component dendritic_compartment (uA_per_cm2)'); LEGEND_ALGEBRAIC(:,17) = strpad('I_pump in component dendritic_compartment (uA_per_cm2)'); LEGEND_CONSTANTS(:,19) = strpad('R_pump in component dendritic_compartment (uA_per_cm2)'); LEGEND_CONSTANTS(:,20) = strpad('Na_eq in component dendritic_compartment (mM)'); LEGEND_ALGEBRAIC(:,12) = strpad('phi_Na in component dendritic_compartment (dimensionless)'); LEGEND_CONSTANTS(:,32) = strpad('phi_Na_eq in component dendritic_compartment (dimensionless)'); LEGEND_CONSTANTS(:,21) = strpad('alpha in component dendritic_compartment (mMcm2_per_uAs)'); LEGEND_ALGEBRAIC(:,22) = strpad('I_NMDA in component dendritic_compartment (uA_per_cm2)'); LEGEND_ALGEBRAIC(:,20) = strpad('I_Na_NMDA in component dendritic_compartment (uA_per_cm2)'); LEGEND_CONSTANTS(:,22) = strpad('g_NMDA in component dendritic_compartment (mS_per_cm2)'); LEGEND_CONSTANTS(:,23) = strpad('g_Na_NMDA in component dendritic_compartment (mS_per_cm2)'); LEGEND_CONSTANTS(:,24) = strpad('g_L in component dendritic_compartment (mS_per_cm2)'); LEGEND_CONSTANTS(:,25) = strpad('Mg_o in component dendritic_compartment (mM)'); LEGEND_CONSTANTS(:,26) = strpad('K_Mg in component dendritic_compartment (mM)'); LEGEND_CONSTANTS(:,27) = strpad('q in component dendritic_compartment (mV)'); LEGEND_CONSTANTS(:,28) = strpad('V_NMDA in component dendritic_compartment (mV)'); LEGEND_CONSTANTS(:,29) = strpad('V_L in component dendritic_compartment (mV)'); LEGEND_ALGEBRAIC(:,24) = strpad('I_D in component dendritic_compartment (uA_per_cm2)'); LEGEND_ALGEBRAIC(:,25) = strpad('I_Ca_L in component dendritic_compartment (uA_per_cm2)'); LEGEND_CONSTANTS(:,30) = strpad('g_Ca_L in component dendritic_compartment (mS_per_cm2)'); LEGEND_CONSTANTS(:,31) = strpad('g_K_DR_D in component dendritic_compartment (mS_per_cm2)'); LEGEND_ALGEBRAIC(:,2) = strpad('I_K_DR_D in component dendritic_compartment (uA_per_cm2)'); LEGEND_STATES(:,12) = strpad('m_L in component gating_variables (dimensionless)'); LEGEND_ALGEBRAIC(:,3) = strpad('m_T_infinity in component gating_variables (dimensionless)'); LEGEND_ALGEBRAIC(:,4) = strpad('h_T_infinity in component gating_variables (dimensionless)'); LEGEND_ALGEBRAIC(:,5) = strpad('a_infinity in component gating_variables (dimensionless)'); LEGEND_ALGEBRAIC(:,6) = strpad('b_infinity in component gating_variables (dimensionless)'); LEGEND_ALGEBRAIC(:,7) = strpad('m_h_infinity in component gating_variables (dimensionless)'); LEGEND_ALGEBRAIC(:,8) = strpad('m_L_infinity in component gating_variables (dimensionless)'); LEGEND_ALGEBRAIC(:,9) = strpad('n_infinity in component gating_variables (dimensionless)'); LEGEND_ALGEBRAIC(:,10) = strpad('h_infinity in component gating_variables (dimensionless)'); LEGEND_ALGEBRAIC(:,13) = strpad('tau_h in component gating_variables (second)'); LEGEND_ALGEBRAIC(:,14) = strpad('tau_n in component gating_variables (second)'); LEGEND_CONSTANTS(:,33) = strpad('tau_m_T in component gating_variables (second)'); LEGEND_CONSTANTS(:,34) = strpad('tau_h_T in component gating_variables (second)'); LEGEND_ALGEBRAIC(:,15) = strpad('tau_m_L in component gating_variables (second)'); LEGEND_CONSTANTS(:,35) = strpad('tau_a in component gating_variables (second)'); LEGEND_CONSTANTS(:,36) = strpad('tau_b in component gating_variables (second)'); LEGEND_CONSTANTS(:,37) = strpad('tau_m_h in component gating_variables (second)'); LEGEND_RATES(:,1) = strpad('d/dt V_s in component soma_compartment (mV)'); LEGEND_RATES(:,2) = strpad('d/dt Ca in component soma_compartment (mM)'); LEGEND_RATES(:,5) = strpad('d/dt V_D in component dendritic_compartment (mV)'); LEGEND_RATES(:,11) = strpad('d/dt Na in component dendritic_compartment (mM)'); LEGEND_RATES(:,4) = strpad('d/dt h in component gating_variables (dimensionless)'); LEGEND_RATES(:,3) = strpad('d/dt n in component gating_variables (dimensionless)'); LEGEND_RATES(:,6) = strpad('d/dt m_T in component gating_variables (dimensionless)'); LEGEND_RATES(:,12) = strpad('d/dt m_L in component gating_variables (dimensionless)'); LEGEND_RATES(:,10) = strpad('d/dt m_h in component gating_variables (dimensionless)'); LEGEND_RATES(:,8) = strpad('d/dt a in component gating_variables (dimensionless)'); LEGEND_RATES(:,9) = strpad('d/dt b in component gating_variables (dimensionless)'); LEGEND_RATES(:,7) = strpad('d/dt h_T in component gating_variables (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 = []; STATES(:,1) = -64.0; CONSTANTS(:,1) = 55; CONSTANTS(:,2) = 3.2; CONSTANTS(:,3) = 6.4; CONSTANTS(:,4) = 1.5; CONSTANTS(:,5) = 1.2; CONSTANTS(:,6) = 2; CONSTANTS(:,7) = 0.1; STATES(:,2) = 0; CONSTANTS(:,8) = 1; CONSTANTS(:,9) = 0.0004; CONSTANTS(:,10) = -30; CONSTANTS(:,11) = 0.104; CONSTANTS(:,12) = -6.7; CONSTANTS(:,13) = 120; CONSTANTS(:,14) = -85; STATES(:,3) = 0.002; STATES(:,4) = 1.0; CONSTANTS(:,15) = 0.1; CONSTANTS(:,16) = 0.5; STATES(:,5) = -77.0; CONSTANTS(:,17) = 1; STATES(:,6) = 0.1; STATES(:,7) = 0.1; STATES(:,8) = 0.1; STATES(:,9) = 0.1; STATES(:,10) = 0.1; STATES(:,11) = 5.09; CONSTANTS(:,18) = 15; CONSTANTS(:,19) = 18; CONSTANTS(:,20) = 8; CONSTANTS(:,21) = 0.173; CONSTANTS(:,22) = 25; CONSTANTS(:,23) = 5; CONSTANTS(:,24) = 0.18; CONSTANTS(:,25) = 1.4; CONSTANTS(:,26) = 10; CONSTANTS(:,27) = 12.5; CONSTANTS(:,28) = 0; CONSTANTS(:,29) = -50; CONSTANTS(:,30) = 0.19; CONSTANTS(:,31) = 0.14; STATES(:,12) = 0.1; CONSTANTS(:,32) = power(CONSTANTS(:,20), 3.00000)./(power(CONSTANTS(:,20), 3.00000)+power(CONSTANTS(:,18), 3.00000)); CONSTANTS(:,33) = 1.00000; CONSTANTS(:,34) = 10.0000; CONSTANTS(:,35) = 0.500000; CONSTANTS(:,36) = 10.0000; CONSTANTS(:,37) = 190.000; 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(:,3) = 1.00000./(1.00000+exp( - (STATES(:,1)+55.0000)./7.00000)); RATES(:,6) = (ALGEBRAIC(:,3) - STATES(:,6))./CONSTANTS(:,33); ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,1)+80.0000)./8.00000)); RATES(:,10) = (ALGEBRAIC(:,7) - STATES(:,10))./CONSTANTS(:,37); ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1)+60.0000)./10.0000)); RATES(:,8) = (ALGEBRAIC(:,5) - STATES(:,8))./CONSTANTS(:,35); ALGEBRAIC(:,6) = 1.00000./(1.00000+exp((STATES(:,1)+70.0000)./5.70000)); RATES(:,9) = (ALGEBRAIC(:,6) - STATES(:,9))./CONSTANTS(:,36); ALGEBRAIC(:,4) = 1.00000./(1.00000+exp((STATES(:,1)+81.0000)./11.0000)); RATES(:,7) = (ALGEBRAIC(:,4) - STATES(:,7))./CONSTANTS(:,34); ALGEBRAIC(:,11) = CONSTANTS(:,4).*STATES(:,7).*(STATES(:,1) - CONSTANTS(:,13)).*power(STATES(:,6), 2.00000); RATES(:,2) = - ( CONSTANTS(:,11).*ALGEBRAIC(:,11)+ CONSTANTS(:,8).*STATES(:,2)); ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,1)+30.0000)./8.30000)); ALGEBRAIC(:,13) = 0.400000.*(1.00000+2.00000./(1.00000+exp((STATES(:,1)+25.0000)./5.00000))); RATES(:,4) = (ALGEBRAIC(:,10) - STATES(:,4))./ALGEBRAIC(:,13); ALGEBRAIC(:,9) = 1.00000./(1.00000+exp( - (STATES(:,1)+31.0000)./5.30000)); ALGEBRAIC(:,14) = ( 0.800000.*(1.00000+2.00000./(1.00000+exp((STATES(:,1)+25.0000)./10.0000))))./(1.00000+exp( - (STATES(:,1)+70.0000)./10.0000)); RATES(:,3) = (ALGEBRAIC(:,9) - STATES(:,3))./ALGEBRAIC(:,14); ALGEBRAIC(:,8) = 1.00000./(1.00000+exp( - (STATES(:,5)+20.0000)./5.30000)); ALGEBRAIC(:,15) = 0.400000./( 5.00000.*exp( - (STATES(:,5)+11.0000)./8.30000)+( - (STATES(:,5)+11.0000)./8.30000)./(exp( - (STATES(:,5)+11.0000)./8.30000) - 1.00000)); RATES(:,12) = (ALGEBRAIC(:,8) - STATES(:,12))./ALGEBRAIC(:,15); ALGEBRAIC(:,12) = power(STATES(:,11), 3.00000)./(power(STATES(:,11), 3.00000)+power(CONSTANTS(:,18), 3.00000)); ALGEBRAIC(:,17) = CONSTANTS(:,19).*(ALGEBRAIC(:,12) - CONSTANTS(:,32)); ALGEBRAIC(:,20) = (CONSTANTS(:,23)./(1.00000+ (CONSTANTS(:,25)./CONSTANTS(:,26)).*exp( - STATES(:,5)./CONSTANTS(:,27)))).*(STATES(:,5) - CONSTANTS(:,1)); RATES(:,11) = CONSTANTS(:,21).*( - ALGEBRAIC(:,20) - ALGEBRAIC(:,17).*3.00000); ALGEBRAIC(:,19) = CONSTANTS(:,24).*(STATES(:,5) - CONSTANTS(:,29)); ALGEBRAIC(:,22) = (CONSTANTS(:,22)./(1.00000+ (CONSTANTS(:,25)./CONSTANTS(:,26)).*exp( - STATES(:,5)./CONSTANTS(:,27)))).*(STATES(:,5) - CONSTANTS(:,28)); ALGEBRAIC(:,25) = CONSTANTS(:,30).*(STATES(:,5) - CONSTANTS(:,13)).*power(STATES(:,12), 2.00000); ALGEBRAIC(:,2) = CONSTANTS(:,31).*(STATES(:,5) - CONSTANTS(:,14)).*power(STATES(:,3), 2.00000); RATES(:,5) = - ( 1000.00.*(ALGEBRAIC(:,25)+ALGEBRAIC(:,2)+ALGEBRAIC(:,22)+ALGEBRAIC(:,17)+ALGEBRAIC(:,19)+ (CONSTANTS(:,15)./(1.00000 - CONSTANTS(:,16))).*(STATES(:,5) - STATES(:,1))))./CONSTANTS(:,17); ALGEBRAIC(:,23) = 1.00000./(1.00000+exp( - (STATES(:,1)+35.0000)./6.20000)); ALGEBRAIC(:,26) = CONSTANTS(:,2).*STATES(:,4).*(STATES(:,1) - CONSTANTS(:,1)).*power(ALGEBRAIC(:,23), 3.00000); ALGEBRAIC(:,1) = CONSTANTS(:,3).*(STATES(:,1) - CONSTANTS(:,14)).*power(STATES(:,3), 2.00000); ALGEBRAIC(:,16) = (( CONSTANTS(:,5).*power(STATES(:,2), 4.00000))./(power(STATES(:,2), 4.00000)+power(CONSTANTS(:,9), 4.00000))).*(STATES(:,1) - CONSTANTS(:,14)); ALGEBRAIC(:,18) = CONSTANTS(:,6).*STATES(:,9).*(STATES(:,1) - CONSTANTS(:,14)).*power(STATES(:,8), 4.00000); ALGEBRAIC(:,21) = CONSTANTS(:,7).*STATES(:,10).*(STATES(:,1) - CONSTANTS(:,10)); RATES(:,1) = ( 1000.00.*(CONSTANTS(:,12) - (ALGEBRAIC(:,26)+ALGEBRAIC(:,11)+ALGEBRAIC(:,1)+ALGEBRAIC(:,16)+ALGEBRAIC(:,18)+ALGEBRAIC(:,21)+ (CONSTANTS(:,15)./CONSTANTS(:,16)).*(STATES(:,1) - STATES(:,5)))))./CONSTANTS(:,17); 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(:,3) = 1.00000./(1.00000+exp( - (STATES(:,1)+55.0000)./7.00000)); ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,1)+80.0000)./8.00000)); ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1)+60.0000)./10.0000)); ALGEBRAIC(:,6) = 1.00000./(1.00000+exp((STATES(:,1)+70.0000)./5.70000)); ALGEBRAIC(:,4) = 1.00000./(1.00000+exp((STATES(:,1)+81.0000)./11.0000)); ALGEBRAIC(:,11) = CONSTANTS(:,4).*STATES(:,7).*(STATES(:,1) - CONSTANTS(:,13)).*power(STATES(:,6), 2.00000); ALGEBRAIC(:,10) = 1.00000./(1.00000+exp((STATES(:,1)+30.0000)./8.30000)); ALGEBRAIC(:,13) = 0.400000.*(1.00000+2.00000./(1.00000+exp((STATES(:,1)+25.0000)./5.00000))); ALGEBRAIC(:,9) = 1.00000./(1.00000+exp( - (STATES(:,1)+31.0000)./5.30000)); ALGEBRAIC(:,14) = ( 0.800000.*(1.00000+2.00000./(1.00000+exp((STATES(:,1)+25.0000)./10.0000))))./(1.00000+exp( - (STATES(:,1)+70.0000)./10.0000)); ALGEBRAIC(:,8) = 1.00000./(1.00000+exp( - (STATES(:,5)+20.0000)./5.30000)); ALGEBRAIC(:,15) = 0.400000./( 5.00000.*exp( - (STATES(:,5)+11.0000)./8.30000)+( - (STATES(:,5)+11.0000)./8.30000)./(exp( - (STATES(:,5)+11.0000)./8.30000) - 1.00000)); ALGEBRAIC(:,12) = power(STATES(:,11), 3.00000)./(power(STATES(:,11), 3.00000)+power(CONSTANTS(:,18), 3.00000)); ALGEBRAIC(:,17) = CONSTANTS(:,19).*(ALGEBRAIC(:,12) - CONSTANTS(:,32)); ALGEBRAIC(:,20) = (CONSTANTS(:,23)./(1.00000+ (CONSTANTS(:,25)./CONSTANTS(:,26)).*exp( - STATES(:,5)./CONSTANTS(:,27)))).*(STATES(:,5) - CONSTANTS(:,1)); ALGEBRAIC(:,19) = CONSTANTS(:,24).*(STATES(:,5) - CONSTANTS(:,29)); ALGEBRAIC(:,22) = (CONSTANTS(:,22)./(1.00000+ (CONSTANTS(:,25)./CONSTANTS(:,26)).*exp( - STATES(:,5)./CONSTANTS(:,27)))).*(STATES(:,5) - CONSTANTS(:,28)); ALGEBRAIC(:,25) = CONSTANTS(:,30).*(STATES(:,5) - CONSTANTS(:,13)).*power(STATES(:,12), 2.00000); ALGEBRAIC(:,2) = CONSTANTS(:,31).*(STATES(:,5) - CONSTANTS(:,14)).*power(STATES(:,3), 2.00000); ALGEBRAIC(:,23) = 1.00000./(1.00000+exp( - (STATES(:,1)+35.0000)./6.20000)); ALGEBRAIC(:,26) = CONSTANTS(:,2).*STATES(:,4).*(STATES(:,1) - CONSTANTS(:,1)).*power(ALGEBRAIC(:,23), 3.00000); ALGEBRAIC(:,1) = CONSTANTS(:,3).*(STATES(:,1) - CONSTANTS(:,14)).*power(STATES(:,3), 2.00000); ALGEBRAIC(:,16) = (( CONSTANTS(:,5).*power(STATES(:,2), 4.00000))./(power(STATES(:,2), 4.00000)+power(CONSTANTS(:,9), 4.00000))).*(STATES(:,1) - CONSTANTS(:,14)); ALGEBRAIC(:,18) = CONSTANTS(:,6).*STATES(:,9).*(STATES(:,1) - CONSTANTS(:,14)).*power(STATES(:,8), 4.00000); ALGEBRAIC(:,21) = CONSTANTS(:,7).*STATES(:,10).*(STATES(:,1) - CONSTANTS(:,10)); ALGEBRAIC(:,24) = ALGEBRAIC(:,22)+ALGEBRAIC(:,17)+ALGEBRAIC(:,19); 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