필터 지우기
필터 지우기

Finding positions of a partial string in a cell array

조회 수: 16 (최근 30일)
Devon
Devon 2014년 10월 3일
댓글: Devon 2014년 10월 3일
Hello,
I'm trying to find a way to search through a big cell array (roughly 12,000 x 7) for a partial string, and to get the position of those cells which include that partial string in the array back. In this case, the specific value is '/SH', which can be included as part of a larger string in the cell. I can get another array using strfind(data,'/SH') to return another array marking the cells that have the string I'm looking for, but ideally I'd something that gives me row/column locations of the cells I'm looking for.
Thanks for any help!
Devon

채택된 답변

Mohammad Abouali
Mohammad Abouali 2014년 10월 3일
편집: Mohammad Abouali 2014년 10월 3일
Data={'/SH','abcd','abcd';'abcd','/SH','/SH'}
Data =
'/SH' 'abcd' 'abcd'
'abcd' '/SH' '/SH'
[row,col]=find(~cellfun(@isempty,strfind(Data,'/SH')));
[row,col]
ans =
1 1
2 2
2 3
  댓글 수: 1
Devon
Devon 2014년 10월 3일
Quick response and worked perfectly, thank you very much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by