Do you want to search for 'bla' within the text in each element of the cell array, or for elements that are 'bla' exactly? If you explain this detail, then your question would be easier to answer.
If you are searching for text that has 'bla' as part of the text, then starting in R2016b you can use the “contains” function, as Alexander Cranney pointed out.
Index = find(contains(C,'bla'));
In previous versions of MATLAB, you can use the “strfind” function. However, “strfind” returns a cell array of indices. For any input cell whose text does not contain 'bla', “strfind” returns an empty cell. Use “isempty” and “cellfun” with the “find” function to find the empty cells.
IndexC = strfind(C,'bla');
Index = find(not(cellfun('isempty',IndexC)))
If you are searching for text that is exactly 'bla', then see Jos’ answer.
7 Comments
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_3926
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_3926
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_3934
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_3934
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_4088
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_4088
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_131581
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_131581
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_131604
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_131604
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_487774
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_487774
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_487780
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/2015-find-index-of-cells-containing-my-string#comment_487780
Sign in to comment.