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!