Financial Time Series Toolbox | ![]() ![]() |
Syntax
Arguments
list |
A cell array of name strings |
|
A string or cell array of name strings |
Description
nameidx = getnameidx(list,
finds the occurrence of a name or set of names in a list. It returns an index (order number) indicating where the specified names are located with the list. If name
)
name
is not found, nameidx
returns 0
.
If name
is a cell array of names, getnameidx
returns a vector containing the indices (order number) of the name
strings within list
. If none of the names in the name
cell array is in list
, it returns zero. If some of names in name
are not found, the indices for these names will be zeros.
getnameidx
finds only the first occurrence of the name in the list of names. This function is meant to be used on a list of unique names (strings) only. It will not find multiple occurrences of a name or a list of names within list
.
Examples
poultry = {'duck', 'chicken'} animals = {'duck', 'cow', 'sheep', 'horse', 'chicken'} nameidx = getnameidx(animals, poultry) ans = 1 5
poultry = {'duck', 'goose', 'chicken'} animals = {'duck', 'cow', 'sheep', 'horse', 'chicken'} nameidx = getnameidx(animals, poultry) ans = 1 0 5
See Also
![]() | getfield | hhigh | ![]() |