searching cell arrays
古いコメントを表示
I want to find the index of a cell array that contains a specific string, but the search and find functions don't take cell arrays as arguments. How do I return the cell number that contains the string?
採用された回答
その他の回答 (2 件)
Jan
2012 年 2 月 24 日
C = {'abc', 'hello', '81'}
strcmp(C, 'hello')
% >> 0 1 0
find(strcmpi(C, 'HELLO'))
% >> 2
the cyclist
2012 年 2 月 24 日
Here's one way, similar to Jan's:
C = {'abc', 'hello', '81'};
find(ismember(C,'hello'))
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!