From e4f2acaf3d1a3153d2a7783ec16d6b6c053f2f93 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Thu, 15 Mar 2012 19:54:41 +0000 Subject: [PATCH] Fixed issues with Matlab toolbox identified by the code analyzer --- .../toolbox/1D/@Domain1D/componentName.m | 1 + .../matlab/toolbox/1D/@Domain1D/gridPoints.m | 2 ++ .../toolbox/1D/@Domain1D/setCoverageEqs.m | 4 +-- interfaces/matlab/toolbox/1D/@Domain1D/z.m | 2 ++ interfaces/matlab/toolbox/1D/@Stack/Stack.m | 1 + .../matlab/toolbox/1D/@Stack/domainIndex.m | 2 +- interfaces/matlab/toolbox/1D/@Stack/save.m | 2 +- .../matlab/toolbox/1D/@Stack/setProfile.m | 2 +- .../matlab/toolbox/1D/@Stack/solution.m | 7 +++-- interfaces/matlab/toolbox/1D/Surface.m | 2 +- interfaces/matlab/toolbox/1D/nComponents.m | 2 +- interfaces/matlab/toolbox/1D/npflame_init.m | 9 +++++- .../matlab/toolbox/@FlowDevice/install.m | 2 +- interfaces/matlab/toolbox/@Func/char.m | 5 ++-- interfaces/matlab/toolbox/@Func/display.m | 2 +- interfaces/matlab/toolbox/@Func/subsref.m | 1 + .../matlab/toolbox/@Kinetics/reactionEqn.m | 6 ++-- interfaces/matlab/toolbox/@Kinetics/rop.m | 6 ++-- interfaces/matlab/toolbox/@Kinetics/rxnEqs.m | 6 ++-- .../matlab/toolbox/@Kinetics/setMultiplier.m | 2 +- .../matlab/toolbox/@Kinetics/stoich_net.m | 2 +- .../matlab/toolbox/@Mixture/phaseMoles.m | 1 + .../matlab/toolbox/@Reactor/massFractions.m | 4 +-- .../matlab/toolbox/@Reactor/setEnergy.m | 2 +- .../toolbox/@ReactorNet/reactornet_hndl.m | 2 +- interfaces/matlab/toolbox/@Solution/set.m | 16 +++++----- .../matlab/toolbox/@ThermoPhase/elementName.m | 2 +- .../matlab/toolbox/@ThermoPhase/equilibrate.m | 29 ------------------- .../matlab/toolbox/@ThermoPhase/gibbs_RT.m | 2 +- .../toolbox/@ThermoPhase/massFraction.m | 1 + .../toolbox/@ThermoPhase/moleFraction.m | 1 + .../matlab/toolbox/@ThermoPhase/setState.m | 2 +- .../matlab/toolbox/@ThermoPhase/speciesName.m | 2 +- .../matlab/toolbox/@Transport/Transport.m | 2 +- interfaces/matlab/toolbox/@Wall/area.m | 2 +- interfaces/matlab/toolbox/@XML_Node/attrib.m | 2 +- interfaces/matlab/toolbox/@XML_Node/build.m | 8 ++--- interfaces/matlab/toolbox/conhp.m | 2 +- interfaces/matlab/toolbox/conuv.m | 2 +- interfaces/matlab/toolbox/geterr.m | 6 ++-- 40 files changed, 72 insertions(+), 84 deletions(-) diff --git a/interfaces/matlab/toolbox/1D/@Domain1D/componentName.m b/interfaces/matlab/toolbox/1D/@Domain1D/componentName.m index de03989e9..8493ca566 100644 --- a/interfaces/matlab/toolbox/1D/@Domain1D/componentName.m +++ b/interfaces/matlab/toolbox/1D/@Domain1D/componentName.m @@ -2,6 +2,7 @@ function s = componentName(d, n) % COMPONENTNAME - Name of component n. % m = length(n); +s = cell(m); for i = 1:m s{i} = domain_methods(d.dom_id, 40, n(i)); end diff --git a/interfaces/matlab/toolbox/1D/@Domain1D/gridPoints.m b/interfaces/matlab/toolbox/1D/@Domain1D/gridPoints.m index 38d5d854a..756542688 100644 --- a/interfaces/matlab/toolbox/1D/@Domain1D/gridPoints.m +++ b/interfaces/matlab/toolbox/1D/@Domain1D/gridPoints.m @@ -2,11 +2,13 @@ function zz = gridPoints(d, n) % GRID - % if nargin == 1 + zz = zeros(1, nPoints(d)); for i = 1:nPoints(d) zz(i) = domain_methods(d.dom_id, 19, i); end else m = length(n); + zz = zeros(1, m); for i = 1:m zz(i) = domain_methods(d.dom_id, 19, n(i)); end diff --git a/interfaces/matlab/toolbox/1D/@Domain1D/setCoverageEqs.m b/interfaces/matlab/toolbox/1D/@Domain1D/setCoverageEqs.m index b1bb2699f..91d982e88 100644 --- a/interfaces/matlab/toolbox/1D/@Domain1D/setCoverageEqs.m +++ b/interfaces/matlab/toolbox/1D/@Domain1D/setCoverageEqs.m @@ -7,9 +7,9 @@ end ion = -1; if isa(onoff,'char') - if strcmp(onoff,'on') | strcmp(onoff,'yes') + if strcmp(onoff,'on') || strcmp(onoff,'yes') ion = 1; - elseif strcmp(onoff,'off') | strcmp(onoff,'no') + elseif strcmp(onoff,'off') || strcmp(onoff,'no') ion = 0; else error(strcat('unknown option: ',onoff)) diff --git a/interfaces/matlab/toolbox/1D/@Domain1D/z.m b/interfaces/matlab/toolbox/1D/@Domain1D/z.m index 22ff3a699..4d9c5cdc4 100644 --- a/interfaces/matlab/toolbox/1D/@Domain1D/z.m +++ b/interfaces/matlab/toolbox/1D/@Domain1D/z.m @@ -2,11 +2,13 @@ function zz = z(d, n) % GRID - % if nargin == 1 + zz = zeros(1, nPoints(d)); for i = 1:nPoints(d) zz(i) = domain_methods(d.dom_id, 19, i); end else m = length(n); + zz = zeros(1, m); for i = 1:m zz(i) = domain_methods(d.dom_id, 19, n(i)); end diff --git a/interfaces/matlab/toolbox/1D/@Stack/Stack.m b/interfaces/matlab/toolbox/1D/@Stack/Stack.m index 9da6845f9..a016efb5f 100644 --- a/interfaces/matlab/toolbox/1D/@Stack/Stack.m +++ b/interfaces/matlab/toolbox/1D/@Stack/Stack.m @@ -10,6 +10,7 @@ s.stack_id = -1; s.domains = domains; if nargin == 1 nd = length(domains); + ids = zeros(1, nd); for n=1:nd ids(n) = domain_hndl(domains(n)); end diff --git a/interfaces/matlab/toolbox/1D/@Stack/domainIndex.m b/interfaces/matlab/toolbox/1D/@Stack/domainIndex.m index 1cbd9a147..ff10f8b37 100644 --- a/interfaces/matlab/toolbox/1D/@Stack/domainIndex.m +++ b/interfaces/matlab/toolbox/1D/@Stack/domainIndex.m @@ -1,7 +1,7 @@ function n = domainIndex(d, name) % DOMAININDEX - Index of the domain with a specified name. if isa(name,'double') - n = name + n = name; else n = stack_methods(d.stack_id, 109, name); end diff --git a/interfaces/matlab/toolbox/1D/@Stack/save.m b/interfaces/matlab/toolbox/1D/@Stack/save.m index 2ce2bfd50..bf49d0a6e 100644 --- a/interfaces/matlab/toolbox/1D/@Stack/save.m +++ b/interfaces/matlab/toolbox/1D/@Stack/save.m @@ -1,4 +1,4 @@ -function saveSoln(s, fname, id, desc) +function save(s, fname, id, desc) % SAVE - % if nargin == 2 diff --git a/interfaces/matlab/toolbox/1D/@Stack/setProfile.m b/interfaces/matlab/toolbox/1D/@Stack/setProfile.m index 2822c3ef8..04e07d037 100644 --- a/interfaces/matlab/toolbox/1D/@Stack/setProfile.m +++ b/interfaces/matlab/toolbox/1D/@Stack/setProfile.m @@ -27,7 +27,7 @@ end d = s.domains(n); -if isa(comp,'double') | isa(comp,'cell') +if isa(comp,'double') || isa(comp,'cell') c = comp; elseif isa(comp,'char') c = {comp}; diff --git a/interfaces/matlab/toolbox/1D/@Stack/solution.m b/interfaces/matlab/toolbox/1D/@Stack/solution.m index e4381eff5..fb7851fc3 100644 --- a/interfaces/matlab/toolbox/1D/@Stack/solution.m +++ b/interfaces/matlab/toolbox/1D/@Stack/solution.m @@ -6,15 +6,16 @@ function x = solution(s, domain, component) % idom = domainIndex(s, domain); d = s.domains(idom); - +np = nPoints(d); if nargin == 3 icomp = componentIndex(d, component); - for n = 1:nPoints(d) + x = zeros(1, np); + for n = 1:np x(n) = stack_methods(s.stack_id, 30, idom, icomp, n); end else nc = nComponents(d); - np = nPoints(d); + x = zeros(nc, np); for m = 1:nc for n = 1:np x(m,n) = stack_methods(s.stack_id, 30, idom, m, n); diff --git a/interfaces/matlab/toolbox/1D/Surface.m b/interfaces/matlab/toolbox/1D/Surface.m index 3eb1f7c8c..228458e1d 100644 --- a/interfaces/matlab/toolbox/1D/Surface.m +++ b/interfaces/matlab/toolbox/1D/Surface.m @@ -9,6 +9,6 @@ if nargin < 2 setID(m,id); end else - m = Domain1D(6, surface_mech) + m = Domain1D(6, surface_mech); setID(m,id); end diff --git a/interfaces/matlab/toolbox/1D/nComponents.m b/interfaces/matlab/toolbox/1D/nComponents.m index b2ff8269e..0baa8aefb 100644 --- a/interfaces/matlab/toolbox/1D/nComponents.m +++ b/interfaces/matlab/toolbox/1D/nComponents.m @@ -1,2 +1,2 @@ function n = nComponents(d) -n = domain_methods(d.dom_id, 11) +n = domain_methods(d.dom_id, 11); diff --git a/interfaces/matlab/toolbox/1D/npflame_init.m b/interfaces/matlab/toolbox/1D/npflame_init.m index 64ba1a200..7c4e16fb0 100644 --- a/interfaces/matlab/toolbox/1D/npflame_init.m +++ b/interfaces/matlab/toolbox/1D/npflame_init.m @@ -46,7 +46,6 @@ wt = molecularWeights(gas); % find the fuel and oxidizer ifuel = speciesIndex(gas,fuel); ioxidizer = speciesIndex(gas,oxidizer); -ih = speciesIndex(gas,'H'); s = nuox*wt(ioxidizer)/wt(ifuel); y0f = massFraction(left,ifuel); @@ -59,6 +58,9 @@ nsp = nSpecies(gas); tf = temperature(left); tox = temperature(right); +yox = zeros(1, nsp); +yf = zeros(1, nsp); +ystoich = zeros(1, nsp); for n = 1:nsp yox(n) = massFraction(right,n); yf(n) = massFraction(left,n); @@ -82,6 +84,11 @@ f = sqrt(a/(2.0*diff(ioxidizer))); x0 = massFlux(left)*dz/(massFlux(left) + massFlux(right)); nz = nPoints(flow); +zm = zeros(1,nz); +u = zeros(1,nz); +v = zeros(1,nz); +y = zeros(nz,nsp); +t = zeros(1,nz); for j = 1:nz x = zz(j); zeta = f*(x - x0); diff --git a/interfaces/matlab/toolbox/@FlowDevice/install.m b/interfaces/matlab/toolbox/@FlowDevice/install.m index 273aa337f..1f31db342 100644 --- a/interfaces/matlab/toolbox/@FlowDevice/install.m +++ b/interfaces/matlab/toolbox/@FlowDevice/install.m @@ -1,7 +1,7 @@ function install(f, upstream, downstream) if nargin == 3 - if ~isa(upstream,'Reactor') | ~isa(downstream,'Reactor') + if ~isa(upstream,'Reactor') || ~isa(downstream,'Reactor') error(['Flow devices can only be installed between reactors or' ... ' reservoirs']) end diff --git a/interfaces/matlab/toolbox/@Func/char.m b/interfaces/matlab/toolbox/@Func/char.m index 59c70bafe..f49e56daa 100644 --- a/interfaces/matlab/toolbox/@Func/char.m +++ b/interfaces/matlab/toolbox/@Func/char.m @@ -30,7 +30,7 @@ else a = -a; end end - if a ~= 1 | d == 0 + if a ~= 1 || d == 0 s = [s num2str(a)]; if d > 0 s = [s '*']; @@ -45,7 +45,6 @@ else d = d - 1; end elseif strcmp(p.typ,'gaussian') - s = num2str(p.coeffs(1)); s = ['Gaussian(' num2str(p.coeffs(1)) ',' ... num2str(p.coeffs(2)) ',' ... num2str(p.coeffs(3)) ')']; @@ -57,7 +56,7 @@ else B = c(2:end,2); N = size(c,1)-1; if Ao ~= 0 - s = [num2str(Ao/2)]; + s = num2str(Ao/2); else s = ''; end diff --git a/interfaces/matlab/toolbox/@Func/display.m b/interfaces/matlab/toolbox/@Func/display.m index f755a1f64..5bcd88136 100644 --- a/interfaces/matlab/toolbox/@Func/display.m +++ b/interfaces/matlab/toolbox/@Func/display.m @@ -1,4 +1,4 @@ -function d = display(a) +function display(a) % DISPLAY - % disp(' '); diff --git a/interfaces/matlab/toolbox/@Func/subsref.m b/interfaces/matlab/toolbox/@Func/subsref.m index 8c65e9009..ac90c99ea 100644 --- a/interfaces/matlab/toolbox/@Func/subsref.m +++ b/interfaces/matlab/toolbox/@Func/subsref.m @@ -3,6 +3,7 @@ function b = subsref(a,s) switch s.type case '()' ind = s.subs{:}; + b = zeros(1, length(ind)); for k = 1:length(ind) b(k) = funcmethods(2,a.index,ind(k)); end diff --git a/interfaces/matlab/toolbox/@Kinetics/reactionEqn.m b/interfaces/matlab/toolbox/@Kinetics/reactionEqn.m index 2b3a6aafd..f78b47b4a 100644 --- a/interfaces/matlab/toolbox/@Kinetics/reactionEqn.m +++ b/interfaces/matlab/toolbox/@Kinetics/reactionEqn.m @@ -4,7 +4,7 @@ function e = reactionEqn(a, irxn) if nargin == 1 m = nReactions(a); n = 1; - irxn = [1:m]'; + irxn = (1:m)'; elseif nargin == 2 if isa(irxn,'double') [m, n] = size(irxn); @@ -13,10 +13,10 @@ elseif nargin == 2 end end -if m == 1 & n == 1 +if m == 1 && n == 1 e = kinetics_get(a.id, 31, irxn); % rxnstring(a.id, irxn); else - e = {}; + e = cell(m,n); for i = 1:m for j = 1:n e{i,j} = kinetics_get(a.id, 31, irxn(i,j)); % rxnstring(a.id, irxn(i,j)); diff --git a/interfaces/matlab/toolbox/@Kinetics/rop.m b/interfaces/matlab/toolbox/@Kinetics/rop.m index 3399814b8..ca060d4e3 100644 --- a/interfaces/matlab/toolbox/@Kinetics/rop.m +++ b/interfaces/matlab/toolbox/@Kinetics/rop.m @@ -6,9 +6,9 @@ function rop = rop(k) % and the second column the reverse rates. If this function % is called with no output argument, a bar graph is produced. % -f = rop_f(k) -r = rop_r(k) -rop = [f r] +f = rop_f(k); +r = rop_r(k); +rop = [f r]; if nargout == 0 figure set(gcf,'Name','Rates of Progress'); diff --git a/interfaces/matlab/toolbox/@Kinetics/rxnEqs.m b/interfaces/matlab/toolbox/@Kinetics/rxnEqs.m index 77c0fcf38..755a749b6 100644 --- a/interfaces/matlab/toolbox/@Kinetics/rxnEqs.m +++ b/interfaces/matlab/toolbox/@Kinetics/rxnEqs.m @@ -4,7 +4,7 @@ function e = rxnEqs(a, irxn) if nargin == 1 m = nReactions(a); n = 1; - irxn = [1:m]' + irxn = (1:m)'; elseif nargin == 2 if isa(irxn,'double') [m, n] = size(irxn); @@ -13,10 +13,10 @@ elseif nargin == 2 end end -if m == 1 & n == 1 +if m == 1 && n == 1 e = rxnstring(a.id, irxn); else - e = {}; + e = cell(m,n); for i = 1:m for j = 1:n e{i,j} = rxnstring(a.id, irxn(i,j)); diff --git a/interfaces/matlab/toolbox/@Kinetics/setMultiplier.m b/interfaces/matlab/toolbox/@Kinetics/setMultiplier.m index dd2893db4..67b376edc 100644 --- a/interfaces/matlab/toolbox/@Kinetics/setMultiplier.m +++ b/interfaces/matlab/toolbox/@Kinetics/setMultiplier.m @@ -9,7 +9,7 @@ function setMultiplier(a,irxn,v) if nargin == 2 v = irxn; m = nReactions(a); - irxn = [1:m]'; + irxn = (1:m)'; n = 1; else [m, n] = size(irxn); diff --git a/interfaces/matlab/toolbox/@Kinetics/stoich_net.m b/interfaces/matlab/toolbox/@Kinetics/stoich_net.m index 84f4c536a..0753ed428 100644 --- a/interfaces/matlab/toolbox/@Kinetics/stoich_net.m +++ b/interfaces/matlab/toolbox/@Kinetics/stoich_net.m @@ -21,7 +21,7 @@ function nu = stoich_net(a,species,rxns) % See also: stoich_r, stoich_p. % if nargin == 1 - nu = stoich_p(a) - stoich_r(a) + nu = stoich_p(a) - stoich_r(a); elseif nargin == 3 nu = stoich_p(a,species,rxns) - stoich_r(a,species,rxns); else diff --git a/interfaces/matlab/toolbox/@Mixture/phaseMoles.m b/interfaces/matlab/toolbox/@Mixture/phaseMoles.m index 5e06e656c..9c319e973 100644 --- a/interfaces/matlab/toolbox/@Mixture/phaseMoles.m +++ b/interfaces/matlab/toolbox/@Mixture/phaseMoles.m @@ -5,6 +5,7 @@ if nargin == 2 moles = mixturemethods(28, mix_hndl(self), n); elseif nargin == 1 np = nPhases(self); + m = zeros(1,np); for n = 1:np m(n) = mixturemethods(28, mix_hndl(self), n); end diff --git a/interfaces/matlab/toolbox/@Reactor/massFractions.m b/interfaces/matlab/toolbox/@Reactor/massFractions.m index 96fa12184..e5aea925d 100644 --- a/interfaces/matlab/toolbox/@Reactor/massFractions.m +++ b/interfaces/matlab/toolbox/@Reactor/massFractions.m @@ -4,7 +4,7 @@ function y = massFractions(r) % nsp = nSpecies(r.contents); ir = reactor_hndl(r); +y = zeros(1, nsp); for k = 1:nsp - yy(k) = reactormethods(30, ir, k-1); + y(k) = reactormethods(30, ir, k-1); end -y = yy; diff --git a/interfaces/matlab/toolbox/@Reactor/setEnergy.m b/interfaces/matlab/toolbox/@Reactor/setEnergy.m index 88d620e4f..7e9c53f81 100644 --- a/interfaces/matlab/toolbox/@Reactor/setEnergy.m +++ b/interfaces/matlab/toolbox/@Reactor/setEnergy.m @@ -11,7 +11,7 @@ function setEnergy(f, flag) % >>> setEnergy(r, 'on'); % >>> setEnergy(r, 'off'); % -iflag = -1 +iflag = -1; if strcmp(flag,{'on'}) iflag = 1; elseif strcmp(flag,{'off'}) diff --git a/interfaces/matlab/toolbox/@ReactorNet/reactornet_hndl.m b/interfaces/matlab/toolbox/@ReactorNet/reactornet_hndl.m index aa39d5350..f6230aded 100644 --- a/interfaces/matlab/toolbox/@ReactorNet/reactornet_hndl.m +++ b/interfaces/matlab/toolbox/@ReactorNet/reactornet_hndl.m @@ -1,2 +1,2 @@ -function i = reactor_hndl(r) +function i = reactornet_hndl(r) i = r.index; diff --git a/interfaces/matlab/toolbox/@Solution/set.m b/interfaces/matlab/toolbox/@Solution/set.m index c312b9025..d723de461 100644 --- a/interfaces/matlab/toolbox/@Solution/set.m +++ b/interfaces/matlab/toolbox/@Solution/set.m @@ -148,23 +148,23 @@ elseif ntot == 2 % % set property pairs % - if nt == 1 & nv == 1 + if nt == 1 && nv == 1 setTemperature(a,tval); setDensity(a,1.0/vval); - elseif nt == 1 & np == 1 + elseif nt == 1 && np == 1 setTemperature(a,tval); setPressure(a, pval); - elseif nt == 1 & nq == 1 + elseif nt == 1 && nq == 1 setState_Tsat(a, [tval,qval]); - elseif np == 1 & nq == 1 + elseif np == 1 && nq == 1 setState_Psat(a, [pval,qval]); - elseif np == 1 & nh == 1 + elseif np == 1 && nh == 1 setState_HP(a,[hval,pval]); - elseif nu == 1 & nv == 1 + elseif nu == 1 && nv == 1 setState_UV(a,[uval,vval]); - elseif ns == 1 & np == 1 + elseif ns == 1 && np == 1 setState_SP(a,[sval,pval]); - elseif ns == 1 & nv == 1 + elseif ns == 1 && nv == 1 setState_SV(a,[sval,vval]); else error('unimplemented property pair'); diff --git a/interfaces/matlab/toolbox/@ThermoPhase/elementName.m b/interfaces/matlab/toolbox/@ThermoPhase/elementName.m index 28efa0292..fe63b4980 100644 --- a/interfaces/matlab/toolbox/@ThermoPhase/elementName.m +++ b/interfaces/matlab/toolbox/@ThermoPhase/elementName.m @@ -7,7 +7,7 @@ function nm = elementName(a, m) % the same shape containing the name strings. % [mm, nn] = size(m); -nm = {}; +nm = cell(mm,nn); for i = 1:mm for j = 1:nn nm{i,j} = phase_get(a.tp_id, 41, m(i,j)); diff --git a/interfaces/matlab/toolbox/@ThermoPhase/equilibrate.m b/interfaces/matlab/toolbox/@ThermoPhase/equilibrate.m index 6987b8c50..5f7067467 100644 --- a/interfaces/matlab/toolbox/@ThermoPhase/equilibrate.m +++ b/interfaces/matlab/toolbox/@ThermoPhase/equilibrate.m @@ -48,36 +48,7 @@ if nargin < 7 loglevel = 0; end -iok = 0; iok = thermo_set(a.tp_id, 50, xy, solver, rtol, maxsteps, maxiter, loglevel); -% $$$ switch xy -% $$$ case 'TP' -% $$$ iok = thermo_set(a.tp_id, 50, 104, solver, rtol, maxsteps, loglevel); -% $$$ case 'TV' -% $$$ iok = thermo_set(a.tp_id, 50, 100, solver, rtol, maxsteps, loglevel); -% $$$ case 'HP' -% $$$ iok = thermo_set(a.tp_id, 50, 101, solver, rtol, maxsteps, loglevel); -% $$$ case 'SP' -% $$$ iok = thermo_set(a.tp_id, 50, 102, solver, rtol, maxsteps, loglevel); -% $$$ case 'SV' -% $$$ iok = thermo_set(a.tp_id, 50, 107, solver, rtol, maxsteps, loglevel); -% $$$ case 'UV' -% $$$ iok = thermo_set(a.tp_id, 50, 105, solver, rtol, maxsteps, loglevel); -% $$$ case 'PT' -% $$$ iok = thermo_set(a.tp_id, 50, 104, solver, rtol, maxsteps, loglevel); -% $$$ case 'VT' -% $$$ iok = thermo_set(a.tp_id, 50, 100, solver, rtol, maxsteps, loglevel); -% $$$ case 'PH' -% $$$ iok = thermo_set(a.tp_id, 50, 101, solver, rtol, maxsteps, loglevel); -% $$$ case 'PS' -% $$$ iok = thermo_set(a.tp_id, 50, 102, solver, rtol, maxsteps, loglevel); -% $$$ case 'VS' -% $$$ iok = thermo_set(a.tp_id, 50, 107, solver, rtol, maxsteps, loglevel); -% $$$ case 'VU' -% $$$ iok = thermo_set(a.tp_id, 50, 105, solver, rtol, maxsteps, loglevel); -% $$$ otherwise -% $$$ error('unsupported option') -% $$$ end if iok < 0 e = geterr; if e == 0 diff --git a/interfaces/matlab/toolbox/@ThermoPhase/gibbs_RT.m b/interfaces/matlab/toolbox/@ThermoPhase/gibbs_RT.m index 78b082c58..754b0a086 100644 --- a/interfaces/matlab/toolbox/@ThermoPhase/gibbs_RT.m +++ b/interfaces/matlab/toolbox/@ThermoPhase/gibbs_RT.m @@ -4,4 +4,4 @@ function g_RT = gibbs_RT(p) % This method returns an array containing the pure species % standard-state Gibbs free energies. % -g_RT = enthalpies_RT(g) - entropies_R(g); +g_RT = enthalpies_RT(p) - entropies_R(p); diff --git a/interfaces/matlab/toolbox/@ThermoPhase/massFraction.m b/interfaces/matlab/toolbox/@ThermoPhase/massFraction.m index 90dbaed50..2e193f9ad 100644 --- a/interfaces/matlab/toolbox/@ThermoPhase/massFraction.m +++ b/interfaces/matlab/toolbox/@ThermoPhase/massFraction.m @@ -10,6 +10,7 @@ if isa(species,'char') elseif isa(species,'cell') n = length(species); + y = zeros(1, n); for j = 1:n k = speciesIndex(s, species{j}); if k > 0 diff --git a/interfaces/matlab/toolbox/@ThermoPhase/moleFraction.m b/interfaces/matlab/toolbox/@ThermoPhase/moleFraction.m index adf0e5912..e01efb07c 100644 --- a/interfaces/matlab/toolbox/@ThermoPhase/moleFraction.m +++ b/interfaces/matlab/toolbox/@ThermoPhase/moleFraction.m @@ -10,6 +10,7 @@ if isa(species,'char') elseif isa(species,'cell') n = length(species); + x = zeros(1, n); for j = 1:n k = speciesIndex(s, species{j}); if k > 0 diff --git a/interfaces/matlab/toolbox/@ThermoPhase/setState.m b/interfaces/matlab/toolbox/@ThermoPhase/setState.m index 3ef8e812a..6cba9fb42 100644 --- a/interfaces/matlab/toolbox/@ThermoPhase/setState.m +++ b/interfaces/matlab/toolbox/@ThermoPhase/setState.m @@ -1,6 +1,6 @@ function a = setState(a,job,values) disp('deprecated') -if nargin ~= 3 | ~isa(job,'char') +if nargin ~= 3 || ~isa(job,'char') error('Syntax error. Type "help setState" for more information.') end diff --git a/interfaces/matlab/toolbox/@ThermoPhase/speciesName.m b/interfaces/matlab/toolbox/@ThermoPhase/speciesName.m index 5e6d00e1a..2acab7352 100644 --- a/interfaces/matlab/toolbox/@ThermoPhase/speciesName.m +++ b/interfaces/matlab/toolbox/@ThermoPhase/speciesName.m @@ -6,7 +6,7 @@ function nm = speciesName(a, k) % the same shape containing the name strings. % [m, n] = size(k); -nm = {}; +nm = cell(m,n); for i = 1:m for j = 1:n nm{i,j} = phase_get(a.tp_id, 40, k(i,j)); diff --git a/interfaces/matlab/toolbox/@Transport/Transport.m b/interfaces/matlab/toolbox/@Transport/Transport.m index 4125e18dc..4318efa58 100644 --- a/interfaces/matlab/toolbox/@Transport/Transport.m +++ b/interfaces/matlab/toolbox/@Transport/Transport.m @@ -10,7 +10,7 @@ function tr = Transport(xml_phase, th, model, loglevel) tr.id = 0; if nargin == 4 tr.th = th; - if model == 'default' + if strcmp(model, 'default') try node = child(xml_phase,'transport'); tr.model = attrib(node,'model'); diff --git a/interfaces/matlab/toolbox/@Wall/area.m b/interfaces/matlab/toolbox/@Wall/area.m index eab0ded34..ed6c6f83a 100644 --- a/interfaces/matlab/toolbox/@Wall/area.m +++ b/interfaces/matlab/toolbox/@Wall/area.m @@ -1,4 +1,4 @@ function a = area(w) % AREA - % -a = wallmethods(23, wall_hndl(w)) +a = wallmethods(23, wall_hndl(w)); diff --git a/interfaces/matlab/toolbox/@XML_Node/attrib.m b/interfaces/matlab/toolbox/@XML_Node/attrib.m index 3b632f5b5..526e408e2 100644 --- a/interfaces/matlab/toolbox/@XML_Node/attrib.m +++ b/interfaces/matlab/toolbox/@XML_Node/attrib.m @@ -1,6 +1,6 @@ function a = attrib(x, key) -if nargin ~= 2 | ~isa(key,'char') +if nargin ~= 2 || ~isa(key,'char') error('Syntax error. Type "help attrib" for more information.') end diff --git a/interfaces/matlab/toolbox/@XML_Node/build.m b/interfaces/matlab/toolbox/@XML_Node/build.m index e1ec2207a..4e3d3bafa 100644 --- a/interfaces/matlab/toolbox/@XML_Node/build.m +++ b/interfaces/matlab/toolbox/@XML_Node/build.m @@ -1,11 +1,11 @@ function x = build(x, file, pre) -if nargin < 2 | ~isa(file,'char') +if nargin < 2 || ~isa(file,'char') error('Syntax error. Type "help build" for more information.') end -if nargin == 3 & pre > 0 - iok = ctmethods(10, 15, x.id, file) +if nargin == 3 && pre > 0 + ctmethods(10, 15, x.id, file) else - iok = ctmethods(10, 4, x.id, file) + ctmethods(10, 4, x.id, file) end diff --git a/interfaces/matlab/toolbox/conhp.m b/interfaces/matlab/toolbox/conhp.m index 5241cf841..d5b5f5b7f 100755 --- a/interfaces/matlab/toolbox/conhp.m +++ b/interfaces/matlab/toolbox/conhp.m @@ -1,4 +1,4 @@ -function dydt = conhp(t,y,gas,mw) +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 diff --git a/interfaces/matlab/toolbox/conuv.m b/interfaces/matlab/toolbox/conuv.m index cc8b1972c..8b060881b 100755 --- a/interfaces/matlab/toolbox/conuv.m +++ b/interfaces/matlab/toolbox/conuv.m @@ -1,4 +1,4 @@ -function dydt = conuv(t,y,gas,mw) +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 diff --git a/interfaces/matlab/toolbox/geterr.m b/interfaces/matlab/toolbox/geterr.m index ec9187753..a530daffd 100755 --- a/interfaces/matlab/toolbox/geterr.m +++ b/interfaces/matlab/toolbox/geterr.m @@ -1,6 +1,6 @@ function e = geterr try e = ctmethods(0,2); % getCanteraError; -catch - e = ' '; -end \ No newline at end of file +catch ME + e = getReport(ME); +end