Reputation: 13614
Suppose I have a cell like
A = {'erogol' 'grerol' 'biral'}
then I want to search inside for a particular string.
Is there any special function doing it?
Upvotes: 1
Views: 89
Reputation: 20915
One of the functions is strmatch
:
index = strmatch('grerol',A,'exact');
It returns an array of indexes. It is now deprecated, and Mathworks recommend using strcmp
instead
logicalIndexing = strcmp('grerol',A);
Another option is ismember
:
[bIsMember,index]=ismember('grerol',A);
Another option is strfind
:
indexes = strfind(A,'grerol');
Last but not least,
booleanIndexes = cellfun(@(x)(isequal(x,'grerol')),A);
Upvotes: 3