diff --git a/samples/matlab/conhp.m b/samples/matlab/conhp.m index 8789573bb..8c5504e31 100755 --- a/samples/matlab/conhp.m +++ b/samples/matlab/conhp.m @@ -1,4 +1,4 @@ -function dydt = conhp(t,y,gas,mw) %#ok +function dydt = conhp(t, y, gas, mw) %#ok % CONHP ODE system for a constant-pressure, adiabatic reactor. % % Function CONHP evaluates the system of ordinary differential @@ -10,6 +10,7 @@ function dydt = conhp(t,y,gas,mw) %#ok % Set the state of the gas, based on the current solution vector. setMassFractions(gas, y(2:end), 'nonorm'); set(gas, 'T', y(1), 'P', pressure(gas)); +nsp = nSpecies(gas); % energy equation wdot = netProdRates(gas); @@ -18,11 +19,10 @@ tdot = - temperature(gas) * gasconstant * enthalpies_RT(gas)' ... % set up column vector for dydt dydt = [ tdot - zeros(53,1) ]; + zeros(nsp, 1) ]; % species equations rrho = 1.0/density(gas); -nsp = nSpecies(gas); for i = 1:nsp dydt(i+1) = rrho*mw(i)*wdot(i); end diff --git a/samples/matlab/conuv.m b/samples/matlab/conuv.m index 276f89e58..6ff1695cd 100755 --- a/samples/matlab/conuv.m +++ b/samples/matlab/conuv.m @@ -1,4 +1,4 @@ -function dydt = conuv(t,y,gas,mw) %#ok +function dydt = conuv(t, y, gas, mw) %#ok % CONUV ODE system for a constant-volume, adiabatic reactor. % % Function CONUV evaluates the system of ordinary differential @@ -19,7 +19,7 @@ tdot = - temperature(gas) * gasconstant * (enthalpies_RT(gas) - ones(nsp,1))' .. % set up column vector for dydt dydt = [ tdot - zeros(53,1) ]; + zeros(nsp, 1) ]; % species equations rrho = 1.0/density(gas);