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 =70; end % There are a total of 7 entries in each of the rate and state variable arrays. % There are a total of 46 entries in the constant variable array. % function [VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel() % Create ALGEBRAIC of correct size global algebraicVariableCount; algebraicVariableCount = getAlgebraicVariableCount(); % Initialise constants and state variables [INIT_STATES, CONSTANTS] = initConsts; % Set timespan to solve over tspan = [0, 10]; % Set numerical accuracy options for ODE solver options = odeset('RelTol', 1e-06, 'AbsTol', 1e-06, 'MaxStep', 1); % Solve model with ODE solver [VOI, STATES] = ode15s(@(VOI, STATES)computeRates(VOI, STATES, CONSTANTS), tspan, INIT_STATES, options); % Compute algebraic variables [RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS); ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI); % Plot state variables against variable of integration [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends(); figure(); plot(VOI, STATES); xlabel(LEGEND_VOI); l = legend(LEGEND_STATES); set(l,'Interpreter','none'); end function [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends() LEGEND_STATES = ''; LEGEND_ALGEBRAIC = ''; LEGEND_VOI = ''; LEGEND_CONSTANTS = ''; LEGEND_VOI = strpad('time in component environment (millisecond)'); LEGEND_STATES(:,1) = strpad('V in component membrane (millivolt)'); LEGEND_ALGEBRAIC(:,2) = strpad('IK in component membrane (femtoA)'); LEGEND_ALGEBRAIC(:,5) = strpad('ICa in component membrane (femtoA)'); LEGEND_ALGEBRAIC(:,3) = strpad('IKCa in component membrane (femtoA)'); LEGEND_ALGEBRAIC(:,30) = strpad('IKATP in component KATP (femtoA)'); LEGEND_CONSTANTS(:,1) = strpad('Cm in component membrane (femtoF)'); LEGEND_CONSTANTS(:,2) = strpad('gK in component membrane (picoS)'); LEGEND_CONSTANTS(:,3) = strpad('VK in component KATP (millivolt)'); LEGEND_STATES(:,2) = strpad('n in component membrane (dimensionless)'); LEGEND_CONSTANTS(:,4) = strpad('gKCa in component membrane (picoS)'); LEGEND_CONSTANTS(:,5) = strpad('kd in component membrane (micromolar)'); LEGEND_STATES(:,3) = strpad('c in component calcium_handling (micromolar)'); LEGEND_CONSTANTS(:,6) = strpad('gCa in component membrane (picoS)'); LEGEND_ALGEBRAIC(:,4) = strpad('minf in component membrane (dimensionless)'); LEGEND_CONSTANTS(:,7) = strpad('VCa in component membrane (millivolt)'); LEGEND_CONSTANTS(:,8) = strpad('taun in component membrane (millisecond)'); LEGEND_ALGEBRAIC(:,1) = strpad('ninf in component membrane (dimensionless)'); LEGEND_STATES(:,4) = strpad('cer in component calcium_handling (micromolar)'); LEGEND_CONSTANTS(:,9) = strpad('fcyt in component calcium_handling (dimensionless)'); LEGEND_ALGEBRAIC(:,12) = strpad('Jmem in component calcium_handling (flux)'); LEGEND_ALGEBRAIC(:,10) = strpad('Jer in component calcium_handling (flux)'); LEGEND_CONSTANTS(:,10) = strpad('fer in component calcium_handling (dimensionless)'); LEGEND_CONSTANTS(:,11) = strpad('sigmaV in component calcium_handling (dimensionless)'); LEGEND_CONSTANTS(:,12) = strpad('pleak in component calcium_handling (first_order_rate_constant)'); LEGEND_CONSTANTS(:,13) = strpad('Kserca in component calcium_handling (first_order_rate_constant)'); LEGEND_CONSTANTS(:,14) = strpad('lambdaer in component calcium_handling (dimensionless)'); LEGEND_CONSTANTS(:,15) = strpad('epser in component calcium_handling (dimensionless)'); LEGEND_CONSTANTS(:,16) = strpad('alpha in component calcium_handling (micromolar_per_femtoA_millisecond)'); LEGEND_CONSTANTS(:,17) = strpad('kpmca in component calcium_handling (first_order_rate_constant)'); LEGEND_ALGEBRAIC(:,6) = strpad('Jserca in component calcium_handling (flux)'); LEGEND_ALGEBRAIC(:,8) = strpad('Jleak in component calcium_handling (flux)'); LEGEND_ALGEBRAIC(:,9) = strpad('rgpdh in component glycolysis (flux)'); LEGEND_CONSTANTS(:,18) = strpad('Rgk in component glycolysis (per_second)'); LEGEND_CONSTANTS(:,19) = strpad('atot in component glycolysis (micromolar)'); LEGEND_CONSTANTS(:,20) = strpad('pfkbas in component glycolysis (dimensionless)'); LEGEND_CONSTANTS(:,21) = strpad('Katpase in component glycolysis (micromolar)'); LEGEND_CONSTANTS(:,22) = strpad('kg in component glycolysis (flux)'); LEGEND_ALGEBRAIC(:,7) = strpad('f6p in component glycolysis (micromolar)'); LEGEND_CONSTANTS(:,23) = strpad('lambda in component glycolysis (dimensionless)'); LEGEND_ALGEBRAIC(:,70) = strpad('pfk in component pfk (micromolar)'); LEGEND_STATES(:,5) = strpad('g6p in component glycolysis (micromolar)'); LEGEND_STATES(:,6) = strpad('fbp in component glycolysis (micromolar)'); LEGEND_CONSTANTS(:,24) = strpad('bottom1 in component pfk (dimensionless)'); LEGEND_CONSTANTS(:,25) = strpad('weight1 in component pfk (dimensionless)'); LEGEND_CONSTANTS(:,26) = strpad('topa1 in component pfk (dimensionless)'); LEGEND_CONSTANTS(:,27) = strpad('k1 in component pfk (micromolar)'); LEGEND_CONSTANTS(:,28) = strpad('k2 in component pfk (micromolar)'); LEGEND_CONSTANTS(:,29) = strpad('k3 in component pfk (micromolar)'); LEGEND_CONSTANTS(:,30) = strpad('k4 in component pfk (micromolar)'); LEGEND_CONSTANTS(:,31) = strpad('cat in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,22) = strpad('atp in component nucleotides (micromolar)'); LEGEND_ALGEBRAIC(:,23) = strpad('weight2 in component pfk (dimensionless)'); LEGEND_CONSTANTS(:,46) = strpad('topa2 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,26) = strpad('bottom2 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,13) = strpad('topa3 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,11) = strpad('weight3 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,29) = strpad('bottom3 in component pfk (dimensionless)'); LEGEND_CONSTANTS(:,32) = strpad('famp in component pfk (dimensionless)'); LEGEND_CONSTANTS(:,33) = strpad('fatp in component pfk (dimensionless)'); LEGEND_CONSTANTS(:,34) = strpad('ffbp in component pfk (dimensionless)'); LEGEND_CONSTANTS(:,35) = strpad('fbt in component pfk (dimensionless)'); LEGEND_CONSTANTS(:,36) = strpad('fmt in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,31) = strpad('weight4 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,32) = strpad('topa4 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,33) = strpad('bottom4 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,14) = strpad('weight5 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,34) = strpad('topa5 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,35) = strpad('bottom5 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,36) = strpad('weight6 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,37) = strpad('topa6 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,38) = strpad('bottom6 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,15) = strpad('weight7 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,39) = strpad('topa7 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,40) = strpad('bottom7 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,41) = strpad('weight8 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,42) = strpad('topa8 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,43) = strpad('bottom8 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,47) = strpad('weight9 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,44) = strpad('topa9 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,48) = strpad('bottom9 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,49) = strpad('weight10 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,45) = strpad('topa10 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,50) = strpad('bottom10 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,51) = strpad('weight11 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,52) = strpad('topa11 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,53) = strpad('bottom11 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,54) = strpad('weight12 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,55) = strpad('topa12 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,56) = strpad('bottom12 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,57) = strpad('weight13 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,58) = strpad('topa13 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,59) = strpad('bottom13 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,60) = strpad('weight14 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,61) = strpad('topa14 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,62) = strpad('bottom14 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,63) = strpad('weight15 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,64) = strpad('topa15 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,65) = strpad('bottom15 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,67) = strpad('weight16 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,68) = strpad('topa16 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,69) = strpad('bottom16 in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,66) = strpad('topb in component pfk (dimensionless)'); LEGEND_ALGEBRAIC(:,46) = strpad('amp in component nucleotides (micromolar)'); LEGEND_ALGEBRAIC(:,16) = strpad('mgadp in component KATP (micromolar)'); LEGEND_ALGEBRAIC(:,17) = strpad('adp3m in component KATP (micromolar)'); LEGEND_ALGEBRAIC(:,24) = strpad('atp4m in component KATP (micromolar)'); LEGEND_ALGEBRAIC(:,18) = strpad('topo in component KATP (dimensionless)'); LEGEND_ALGEBRAIC(:,27) = strpad('bottomo in component KATP (dimensionless)'); LEGEND_ALGEBRAIC(:,28) = strpad('katpo in component KATP (dimensionless)'); LEGEND_CONSTANTS(:,37) = strpad('gkatpbar in component KATP (picoS)'); LEGEND_STATES(:,7) = strpad('adp in component nucleotides (micromolar)'); LEGEND_CONSTANTS(:,38) = strpad('kdd in component KATP (dimensionless)'); LEGEND_CONSTANTS(:,39) = strpad('ktd in component KATP (dimensionless)'); LEGEND_CONSTANTS(:,40) = strpad('ktt in component KATP (dimensionless)'); LEGEND_ALGEBRAIC(:,20) = strpad('fback in component nucleotides (dimensionless)'); LEGEND_CONSTANTS(:,41) = strpad('taua in component nucleotides (dimensionless)'); LEGEND_CONSTANTS(:,42) = strpad('r1 in component nucleotides (micromolar)'); LEGEND_CONSTANTS(:,43) = strpad('r in component nucleotides (dimensionless)'); LEGEND_ALGEBRAIC(:,19) = strpad('y in component nucleotides (dimensionless)'); LEGEND_CONSTANTS(:,44) = strpad('vg in component nucleotides (dimensionless)'); LEGEND_CONSTANTS(:,45) = strpad('kg in component nucleotides (flux)'); LEGEND_ALGEBRAIC(:,21) = strpad('rad in component nucleotides (dimensionless)'); LEGEND_ALGEBRAIC(:,25) = strpad('ratio in component nucleotides (dimensionless)'); LEGEND_RATES(:,1) = strpad('d/dt V in component membrane (millivolt)'); LEGEND_RATES(:,2) = strpad('d/dt n in component membrane (dimensionless)'); LEGEND_RATES(:,3) = strpad('d/dt c in component calcium_handling (micromolar)'); LEGEND_RATES(:,4) = strpad('d/dt cer in component calcium_handling (micromolar)'); LEGEND_RATES(:,6) = strpad('d/dt fbp in component glycolysis (micromolar)'); LEGEND_RATES(:,5) = strpad('d/dt g6p in component glycolysis (micromolar)'); LEGEND_RATES(:,7) = strpad('d/dt adp in component nucleotides (micromolar)'); 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) = -60; CONSTANTS(:,1) = 5300; CONSTANTS(:,2) = 2700; CONSTANTS(:,3) = -75; STATES(:,2) = 0; CONSTANTS(:,4) = 600; CONSTANTS(:,5) = 0.5; STATES(:,3) = 0.25; CONSTANTS(:,6) = 1000; CONSTANTS(:,7) = 25; CONSTANTS(:,8) = 20; STATES(:,4) = 185; CONSTANTS(:,9) = 0.01; CONSTANTS(:,10) = 0.01; CONSTANTS(:,11) = 31; CONSTANTS(:,12) = 0.0002; CONSTANTS(:,13) = 0.4; CONSTANTS(:,14) = 1; CONSTANTS(:,15) = 1; CONSTANTS(:,16) = 0.00000450; CONSTANTS(:,17) = 0.2; CONSTANTS(:,18) = 0.2; CONSTANTS(:,19) = 3000; CONSTANTS(:,20) = 0.06; CONSTANTS(:,21) = 0.0003; CONSTANTS(:,22) = 10; CONSTANTS(:,23) = 0.005; STATES(:,5) = 200; STATES(:,6) = 40; CONSTANTS(:,24) = 1; CONSTANTS(:,25) = 1; CONSTANTS(:,26) = 0; CONSTANTS(:,27) = 30; CONSTANTS(:,28) = 1; CONSTANTS(:,29) = 50000; CONSTANTS(:,30) = 1000; CONSTANTS(:,31) = 2; CONSTANTS(:,32) = 0.02; CONSTANTS(:,33) = 20; CONSTANTS(:,34) = 0.2; CONSTANTS(:,35) = 20; CONSTANTS(:,36) = 20; CONSTANTS(:,37) = 25000; STATES(:,7) = 780; CONSTANTS(:,38) = 17; CONSTANTS(:,39) = 26; CONSTANTS(:,40) = 1; CONSTANTS(:,41) = 300000; CONSTANTS(:,42) = 0.35; CONSTANTS(:,43) = 1; CONSTANTS(:,44) = 2.2; CONSTANTS(:,45) = 10; CONSTANTS(:,46) = CONSTANTS(:,26); 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) = 1.00000./(1.00000+exp( - (16.0000+STATES(:,1))./5.00000)); RATES(:,2) = (ALGEBRAIC(:,1) - STATES(:,2))./CONSTANTS(:,8); ALGEBRAIC(:,6) = CONSTANTS(:,13).*STATES(:,3); ALGEBRAIC(:,8) = CONSTANTS(:,12).*(STATES(:,4) - STATES(:,3)); ALGEBRAIC(:,10) = ( CONSTANTS(:,15).*(ALGEBRAIC(:,8) - ALGEBRAIC(:,6)))./CONSTANTS(:,14); RATES(:,4) = - CONSTANTS(:,10).*CONSTANTS(:,11).*ALGEBRAIC(:,10); ALGEBRAIC(:,4) = 1.00000./(1.00000+exp( - (20.0000+STATES(:,1))./12.0000)); ALGEBRAIC(:,5) = CONSTANTS(:,6).*ALGEBRAIC(:,4).*(STATES(:,1) - CONSTANTS(:,7)); ALGEBRAIC(:,12) = - ( CONSTANTS(:,16).*ALGEBRAIC(:,5)+ CONSTANTS(:,17).*STATES(:,3)); RATES(:,3) = CONSTANTS(:,9).*(ALGEBRAIC(:,12)+ALGEBRAIC(:,10)); ALGEBRAIC(:,21) = power(abs(power(STATES(:,7) - CONSTANTS(:,19), 2.00000) - 4.00000.*power(STATES(:,7), 2.00000)), 1.0 ./ 2); ALGEBRAIC(:,22) = 0.500000.*((CONSTANTS(:,19) - STATES(:,7))+ALGEBRAIC(:,21)); ALGEBRAIC(:,9) = 0.200000.*power(abs(STATES(:,6)), 1.0 ./ 2); ALGEBRAIC(:,19) = CONSTANTS(:,44).*(ALGEBRAIC(:,9)./(CONSTANTS(:,45)+ALGEBRAIC(:,9))); ALGEBRAIC(:,20) = CONSTANTS(:,43)+ALGEBRAIC(:,19); RATES(:,7) = (ALGEBRAIC(:,22) - STATES(:,7).*exp( ALGEBRAIC(:,20).*(1.00000 - STATES(:,3)./CONSTANTS(:,42))))./CONSTANTS(:,41); ALGEBRAIC(:,2) = CONSTANTS(:,2).*STATES(:,2).*(STATES(:,1) - CONSTANTS(:,3)); ALGEBRAIC(:,3) = (CONSTANTS(:,4)./(1.00000+power(CONSTANTS(:,5)./STATES(:,3), 2.00000))).*(STATES(:,1) - CONSTANTS(:,3)); ALGEBRAIC(:,16) = 0.165000.*STATES(:,7); ALGEBRAIC(:,18) = 0.0800000.*(1.00000+( 2.00000.*ALGEBRAIC(:,16))./CONSTANTS(:,38))+ 0.890000.*power(ALGEBRAIC(:,16)./CONSTANTS(:,38), 2.00000); ALGEBRAIC(:,17) = 0.135000.*STATES(:,7); ALGEBRAIC(:,24) = 0.0500000.*ALGEBRAIC(:,22); ALGEBRAIC(:,27) = power(1.00000+ALGEBRAIC(:,16)./CONSTANTS(:,38), 2.00000).*(1.00000+ALGEBRAIC(:,17)./CONSTANTS(:,39)+ALGEBRAIC(:,24)./CONSTANTS(:,40)); ALGEBRAIC(:,28) = ALGEBRAIC(:,18)./ALGEBRAIC(:,27); ALGEBRAIC(:,30) = CONSTANTS(:,37).*ALGEBRAIC(:,28).*(STATES(:,1) - CONSTANTS(:,3)); RATES(:,1) = - (ALGEBRAIC(:,2)+ALGEBRAIC(:,5)+ALGEBRAIC(:,3)+ALGEBRAIC(:,30))./CONSTANTS(:,1); ALGEBRAIC(:,7) = 0.300000.*STATES(:,5); ALGEBRAIC(:,11) = power(ALGEBRAIC(:,7), 2.00000)./CONSTANTS(:,29); ALGEBRAIC(:,13) = CONSTANTS(:,46)+ALGEBRAIC(:,11); ALGEBRAIC(:,31) = power( ALGEBRAIC(:,7).*ALGEBRAIC(:,22), 2.00000)./( CONSTANTS(:,33).*CONSTANTS(:,29).*CONSTANTS(:,30)); ALGEBRAIC(:,32) = ALGEBRAIC(:,13)+ALGEBRAIC(:,31); ALGEBRAIC(:,34) = ALGEBRAIC(:,32); ALGEBRAIC(:,37) = ALGEBRAIC(:,34); ALGEBRAIC(:,15) = ( STATES(:,6).*power(ALGEBRAIC(:,7), 2.00000))./( CONSTANTS(:,28).*CONSTANTS(:,29).*CONSTANTS(:,34)); ALGEBRAIC(:,39) = ALGEBRAIC(:,37)+ALGEBRAIC(:,15); ALGEBRAIC(:,41) = ( STATES(:,6).*power(ALGEBRAIC(:,7), 2.00000).*power(ALGEBRAIC(:,22), 2.00000))./( CONSTANTS(:,28).*CONSTANTS(:,29).*CONSTANTS(:,30).*CONSTANTS(:,34).*CONSTANTS(:,35).*CONSTANTS(:,33)); ALGEBRAIC(:,42) = ALGEBRAIC(:,39)+ALGEBRAIC(:,41); ALGEBRAIC(:,44) = ALGEBRAIC(:,42); ALGEBRAIC(:,45) = ALGEBRAIC(:,44); ALGEBRAIC(:,46) = ( STATES(:,7).*STATES(:,7))./ALGEBRAIC(:,22); ALGEBRAIC(:,51) = ( ALGEBRAIC(:,46).*power(ALGEBRAIC(:,7), 2.00000))./( CONSTANTS(:,27).*CONSTANTS(:,29).*CONSTANTS(:,32)); ALGEBRAIC(:,52) = ALGEBRAIC(:,45)+ALGEBRAIC(:,51); ALGEBRAIC(:,54) = ( ALGEBRAIC(:,46).*power(ALGEBRAIC(:,7), 2.00000).*power(ALGEBRAIC(:,22), 2.00000))./( CONSTANTS(:,27).*CONSTANTS(:,29).*CONSTANTS(:,30).*CONSTANTS(:,32).*CONSTANTS(:,36).*CONSTANTS(:,33)); ALGEBRAIC(:,55) = ALGEBRAIC(:,52)+ALGEBRAIC(:,54); ALGEBRAIC(:,58) = ALGEBRAIC(:,55); ALGEBRAIC(:,61) = ALGEBRAIC(:,58); ALGEBRAIC(:,64) = ALGEBRAIC(:,61); ALGEBRAIC(:,67) = ( ALGEBRAIC(:,46).*STATES(:,6).*power(ALGEBRAIC(:,7), 2.00000).*power(ALGEBRAIC(:,22), 2.00000))./( CONSTANTS(:,27).*CONSTANTS(:,28).*CONSTANTS(:,29).*CONSTANTS(:,30).*CONSTANTS(:,34).*CONSTANTS(:,32).*CONSTANTS(:,35).*CONSTANTS(:,36).*CONSTANTS(:,33)); ALGEBRAIC(:,68) = ALGEBRAIC(:,64)+ALGEBRAIC(:,67); ALGEBRAIC(:,23) = power(ALGEBRAIC(:,22), 2.00000)./CONSTANTS(:,30); ALGEBRAIC(:,26) = CONSTANTS(:,24)+ALGEBRAIC(:,23); ALGEBRAIC(:,29) = ALGEBRAIC(:,26)+ALGEBRAIC(:,11); ALGEBRAIC(:,33) = ALGEBRAIC(:,29)+ALGEBRAIC(:,31); ALGEBRAIC(:,14) = STATES(:,6)./CONSTANTS(:,28); ALGEBRAIC(:,35) = ALGEBRAIC(:,33)+ALGEBRAIC(:,14); ALGEBRAIC(:,36) = ( STATES(:,6).*power(ALGEBRAIC(:,22), 2.00000))./( CONSTANTS(:,28).*CONSTANTS(:,30).*CONSTANTS(:,35)); ALGEBRAIC(:,38) = ALGEBRAIC(:,35)+ALGEBRAIC(:,36); ALGEBRAIC(:,40) = ALGEBRAIC(:,38)+ALGEBRAIC(:,15); ALGEBRAIC(:,43) = ALGEBRAIC(:,40)+ALGEBRAIC(:,41); ALGEBRAIC(:,47) = ALGEBRAIC(:,46)./CONSTANTS(:,27); ALGEBRAIC(:,48) = ALGEBRAIC(:,43)+ALGEBRAIC(:,47); ALGEBRAIC(:,49) = ( ALGEBRAIC(:,46).*power(ALGEBRAIC(:,22), 2.00000))./( CONSTANTS(:,27).*CONSTANTS(:,30).*CONSTANTS(:,36)); ALGEBRAIC(:,50) = ALGEBRAIC(:,48)+ALGEBRAIC(:,49); ALGEBRAIC(:,53) = ALGEBRAIC(:,50)+ALGEBRAIC(:,51); ALGEBRAIC(:,56) = ALGEBRAIC(:,53)+ALGEBRAIC(:,54); ALGEBRAIC(:,57) = ( ALGEBRAIC(:,46).*STATES(:,6))./( CONSTANTS(:,27).*CONSTANTS(:,28)); ALGEBRAIC(:,59) = ALGEBRAIC(:,56)+ALGEBRAIC(:,57); ALGEBRAIC(:,60) = ( ALGEBRAIC(:,46).*STATES(:,6).*power(ALGEBRAIC(:,22), 2.00000))./( CONSTANTS(:,27).*CONSTANTS(:,28).*CONSTANTS(:,30).*CONSTANTS(:,35).*CONSTANTS(:,36)); ALGEBRAIC(:,62) = ALGEBRAIC(:,59)+ALGEBRAIC(:,60); ALGEBRAIC(:,63) = ( ALGEBRAIC(:,46).*STATES(:,6).*power(ALGEBRAIC(:,7), 2.00000))./( CONSTANTS(:,27).*CONSTANTS(:,28).*CONSTANTS(:,29).*CONSTANTS(:,34).*CONSTANTS(:,32)); ALGEBRAIC(:,65) = ALGEBRAIC(:,62)+ALGEBRAIC(:,63); ALGEBRAIC(:,69) = ALGEBRAIC(:,65)+ALGEBRAIC(:,67); ALGEBRAIC(:,66) = ALGEBRAIC(:,63); ALGEBRAIC(:,70) = ( CONSTANTS(:,20).*CONSTANTS(:,31).*ALGEBRAIC(:,68)+ CONSTANTS(:,31).*ALGEBRAIC(:,66))./ALGEBRAIC(:,69); RATES(:,6) = CONSTANTS(:,23).*(ALGEBRAIC(:,70) - 0.500000.*ALGEBRAIC(:,9)); RATES(:,5) = CONSTANTS(:,23).*(CONSTANTS(:,18) - ALGEBRAIC(:,70)); 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) = 1.00000./(1.00000+exp( - (16.0000+STATES(:,1))./5.00000)); ALGEBRAIC(:,6) = CONSTANTS(:,13).*STATES(:,3); ALGEBRAIC(:,8) = CONSTANTS(:,12).*(STATES(:,4) - STATES(:,3)); ALGEBRAIC(:,10) = ( CONSTANTS(:,15).*(ALGEBRAIC(:,8) - ALGEBRAIC(:,6)))./CONSTANTS(:,14); ALGEBRAIC(:,4) = 1.00000./(1.00000+exp( - (20.0000+STATES(:,1))./12.0000)); ALGEBRAIC(:,5) = CONSTANTS(:,6).*ALGEBRAIC(:,4).*(STATES(:,1) - CONSTANTS(:,7)); ALGEBRAIC(:,12) = - ( CONSTANTS(:,16).*ALGEBRAIC(:,5)+ CONSTANTS(:,17).*STATES(:,3)); ALGEBRAIC(:,21) = power(abs(power(STATES(:,7) - CONSTANTS(:,19), 2.00000) - 4.00000.*power(STATES(:,7), 2.00000)), 1.0 ./ 2); ALGEBRAIC(:,22) = 0.500000.*((CONSTANTS(:,19) - STATES(:,7))+ALGEBRAIC(:,21)); ALGEBRAIC(:,9) = 0.200000.*power(abs(STATES(:,6)), 1.0 ./ 2); ALGEBRAIC(:,19) = CONSTANTS(:,44).*(ALGEBRAIC(:,9)./(CONSTANTS(:,45)+ALGEBRAIC(:,9))); ALGEBRAIC(:,20) = CONSTANTS(:,43)+ALGEBRAIC(:,19); ALGEBRAIC(:,2) = CONSTANTS(:,2).*STATES(:,2).*(STATES(:,1) - CONSTANTS(:,3)); ALGEBRAIC(:,3) = (CONSTANTS(:,4)./(1.00000+power(CONSTANTS(:,5)./STATES(:,3), 2.00000))).*(STATES(:,1) - CONSTANTS(:,3)); ALGEBRAIC(:,16) = 0.165000.*STATES(:,7); ALGEBRAIC(:,18) = 0.0800000.*(1.00000+( 2.00000.*ALGEBRAIC(:,16))./CONSTANTS(:,38))+ 0.890000.*power(ALGEBRAIC(:,16)./CONSTANTS(:,38), 2.00000); ALGEBRAIC(:,17) = 0.135000.*STATES(:,7); ALGEBRAIC(:,24) = 0.0500000.*ALGEBRAIC(:,22); ALGEBRAIC(:,27) = power(1.00000+ALGEBRAIC(:,16)./CONSTANTS(:,38), 2.00000).*(1.00000+ALGEBRAIC(:,17)./CONSTANTS(:,39)+ALGEBRAIC(:,24)./CONSTANTS(:,40)); ALGEBRAIC(:,28) = ALGEBRAIC(:,18)./ALGEBRAIC(:,27); ALGEBRAIC(:,30) = CONSTANTS(:,37).*ALGEBRAIC(:,28).*(STATES(:,1) - CONSTANTS(:,3)); ALGEBRAIC(:,7) = 0.300000.*STATES(:,5); ALGEBRAIC(:,11) = power(ALGEBRAIC(:,7), 2.00000)./CONSTANTS(:,29); ALGEBRAIC(:,13) = CONSTANTS(:,46)+ALGEBRAIC(:,11); ALGEBRAIC(:,31) = power( ALGEBRAIC(:,7).*ALGEBRAIC(:,22), 2.00000)./( CONSTANTS(:,33).*CONSTANTS(:,29).*CONSTANTS(:,30)); ALGEBRAIC(:,32) = ALGEBRAIC(:,13)+ALGEBRAIC(:,31); ALGEBRAIC(:,34) = ALGEBRAIC(:,32); ALGEBRAIC(:,37) = ALGEBRAIC(:,34); ALGEBRAIC(:,15) = ( STATES(:,6).*power(ALGEBRAIC(:,7), 2.00000))./( CONSTANTS(:,28).*CONSTANTS(:,29).*CONSTANTS(:,34)); ALGEBRAIC(:,39) = ALGEBRAIC(:,37)+ALGEBRAIC(:,15); ALGEBRAIC(:,41) = ( STATES(:,6).*power(ALGEBRAIC(:,7), 2.00000).*power(ALGEBRAIC(:,22), 2.00000))./( CONSTANTS(:,28).*CONSTANTS(:,29).*CONSTANTS(:,30).*CONSTANTS(:,34).*CONSTANTS(:,35).*CONSTANTS(:,33)); ALGEBRAIC(:,42) = ALGEBRAIC(:,39)+ALGEBRAIC(:,41); ALGEBRAIC(:,44) = ALGEBRAIC(:,42); ALGEBRAIC(:,45) = ALGEBRAIC(:,44); ALGEBRAIC(:,46) = ( STATES(:,7).*STATES(:,7))./ALGEBRAIC(:,22); ALGEBRAIC(:,51) = ( ALGEBRAIC(:,46).*power(ALGEBRAIC(:,7), 2.00000))./( CONSTANTS(:,27).*CONSTANTS(:,29).*CONSTANTS(:,32)); ALGEBRAIC(:,52) = ALGEBRAIC(:,45)+ALGEBRAIC(:,51); ALGEBRAIC(:,54) = ( ALGEBRAIC(:,46).*power(ALGEBRAIC(:,7), 2.00000).*power(ALGEBRAIC(:,22), 2.00000))./( CONSTANTS(:,27).*CONSTANTS(:,29).*CONSTANTS(:,30).*CONSTANTS(:,32).*CONSTANTS(:,36).*CONSTANTS(:,33)); ALGEBRAIC(:,55) = ALGEBRAIC(:,52)+ALGEBRAIC(:,54); ALGEBRAIC(:,58) = ALGEBRAIC(:,55); ALGEBRAIC(:,61) = ALGEBRAIC(:,58); ALGEBRAIC(:,64) = ALGEBRAIC(:,61); ALGEBRAIC(:,67) = ( ALGEBRAIC(:,46).*STATES(:,6).*power(ALGEBRAIC(:,7), 2.00000).*power(ALGEBRAIC(:,22), 2.00000))./( CONSTANTS(:,27).*CONSTANTS(:,28).*CONSTANTS(:,29).*CONSTANTS(:,30).*CONSTANTS(:,34).*CONSTANTS(:,32).*CONSTANTS(:,35).*CONSTANTS(:,36).*CONSTANTS(:,33)); ALGEBRAIC(:,68) = ALGEBRAIC(:,64)+ALGEBRAIC(:,67); ALGEBRAIC(:,23) = power(ALGEBRAIC(:,22), 2.00000)./CONSTANTS(:,30); ALGEBRAIC(:,26) = CONSTANTS(:,24)+ALGEBRAIC(:,23); ALGEBRAIC(:,29) = ALGEBRAIC(:,26)+ALGEBRAIC(:,11); ALGEBRAIC(:,33) = ALGEBRAIC(:,29)+ALGEBRAIC(:,31); ALGEBRAIC(:,14) = STATES(:,6)./CONSTANTS(:,28); ALGEBRAIC(:,35) = ALGEBRAIC(:,33)+ALGEBRAIC(:,14); ALGEBRAIC(:,36) = ( STATES(:,6).*power(ALGEBRAIC(:,22), 2.00000))./( CONSTANTS(:,28).*CONSTANTS(:,30).*CONSTANTS(:,35)); ALGEBRAIC(:,38) = ALGEBRAIC(:,35)+ALGEBRAIC(:,36); ALGEBRAIC(:,40) = ALGEBRAIC(:,38)+ALGEBRAIC(:,15); ALGEBRAIC(:,43) = ALGEBRAIC(:,40)+ALGEBRAIC(:,41); ALGEBRAIC(:,47) = ALGEBRAIC(:,46)./CONSTANTS(:,27); ALGEBRAIC(:,48) = ALGEBRAIC(:,43)+ALGEBRAIC(:,47); ALGEBRAIC(:,49) = ( ALGEBRAIC(:,46).*power(ALGEBRAIC(:,22), 2.00000))./( CONSTANTS(:,27).*CONSTANTS(:,30).*CONSTANTS(:,36)); ALGEBRAIC(:,50) = ALGEBRAIC(:,48)+ALGEBRAIC(:,49); ALGEBRAIC(:,53) = ALGEBRAIC(:,50)+ALGEBRAIC(:,51); ALGEBRAIC(:,56) = ALGEBRAIC(:,53)+ALGEBRAIC(:,54); ALGEBRAIC(:,57) = ( ALGEBRAIC(:,46).*STATES(:,6))./( CONSTANTS(:,27).*CONSTANTS(:,28)); ALGEBRAIC(:,59) = ALGEBRAIC(:,56)+ALGEBRAIC(:,57); ALGEBRAIC(:,60) = ( ALGEBRAIC(:,46).*STATES(:,6).*power(ALGEBRAIC(:,22), 2.00000))./( CONSTANTS(:,27).*CONSTANTS(:,28).*CONSTANTS(:,30).*CONSTANTS(:,35).*CONSTANTS(:,36)); ALGEBRAIC(:,62) = ALGEBRAIC(:,59)+ALGEBRAIC(:,60); ALGEBRAIC(:,63) = ( ALGEBRAIC(:,46).*STATES(:,6).*power(ALGEBRAIC(:,7), 2.00000))./( CONSTANTS(:,27).*CONSTANTS(:,28).*CONSTANTS(:,29).*CONSTANTS(:,34).*CONSTANTS(:,32)); ALGEBRAIC(:,65) = ALGEBRAIC(:,62)+ALGEBRAIC(:,63); ALGEBRAIC(:,69) = ALGEBRAIC(:,65)+ALGEBRAIC(:,67); ALGEBRAIC(:,66) = ALGEBRAIC(:,63); ALGEBRAIC(:,70) = ( CONSTANTS(:,20).*CONSTANTS(:,31).*ALGEBRAIC(:,68)+ CONSTANTS(:,31).*ALGEBRAIC(:,66))./ALGEBRAIC(:,69); ALGEBRAIC(:,25) = ALGEBRAIC(:,22)./STATES(:,7); 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