How can i find indexes of multiple strings from a cell array?
5 views (last 30 days)
Show older comments
Khandakar Tanvir Ahmed
on 19 Sep 2019
Commented: Sulaymon Eshkabilov
on 20 Sep 2019
I have a cell aray A (100,000X1) in which every cell contains a string. I have another cell array B (10000x1) of same kind. I want to find the indexes of A which contains a specific string from B and i want to repeat that for every element of B.
I used the following function to find out the indexes for one element of B at a time. say hhh is the first element of B.
idx = find(ismember(A, 'hhh'))
I can't seem to define a variable in place of 'hhh' so that it can change for each element of B. What should I do?
Thank you.
0 Comments
Accepted Answer
Sulaymon Eshkabilov
on 20 Sep 2019
hi,
Here is one plain answer;
% Search string:
STR = 'hhh';
% Index finding:
IndexFind = strfind(A, STR);
Index = find(not(cellfun('isempty', IndexFind)));
% display the found strings containing STR
A{Index} %#ok
%%
2 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!