added support for cell arrays of species names
This commit is contained in:
parent
d1d2496c8e
commit
83de8c30d1
1 changed files with 18 additions and 2 deletions
|
|
@ -1,9 +1,14 @@
|
|||
function n = speciesIndex(a,name)
|
||||
function k = speciesIndex(a,name)
|
||||
% SPECIESINDEX - The species index of species with name 'name'.
|
||||
%
|
||||
% The index is an integer assigned to each species in sequence as it
|
||||
% is read in from the input file.
|
||||
%
|
||||
% If name is a single string, the return value will be a integer
|
||||
% containing the corresponding index. If it is an cell array of
|
||||
% strings, the output will be an array of the same shape
|
||||
% containing the indices.
|
||||
%
|
||||
% NOTE: In keeping with the conventions used by Matlab, this method
|
||||
% returns 1 for the first species, 2 for the second, etc. In
|
||||
% contrast, the corresponding method speciesIndex in the Cantera C++
|
||||
|
|
@ -13,4 +18,15 @@ function n = speciesIndex(a,name)
|
|||
% ich4 = speciesIndex(gas, 'CH4');
|
||||
% iho2 = speciesIndex(gas, 'HO2');
|
||||
%
|
||||
n = phase_get(a.tp_id,12,name);
|
||||
|
||||
if iscell(name)
|
||||
[m, n] = size(name);
|
||||
k = zeros(m,n);
|
||||
for i = 1:m
|
||||
for j = 1:n
|
||||
k(i,j) = phase_get(a.tp_id,12,name{i,j});
|
||||
end
|
||||
end
|
||||
else
|
||||
k = phase_get(a.tp_id,12,name);
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue