Retrieve Both Besides String of Center String

조회 수: 2 (최근 30일)
Angga Lisdiyanto
Angga Lisdiyanto 2016년 6월 29일
댓글: José-Luis 2016년 6월 30일
Hi, i want to retrieve both string of center string. In example, i have below data :
data = {'a', 'b', 'c', 'o', 'm'}
center_string = {'c'}
Output
'b' 'o'
or
'b' 'c' 'o'
Thanks in advance.

채택된 답변

José-Luis
José-Luis 2016년 6월 29일
편집: José-Luis 2016년 6월 29일
data = {'a', 'b', 'c', 'o', 'm'};
idx = find(~cellfun(@isempty,strfind(data,'o')));
your_result = data(idx-1:idx+1)
  댓글 수: 2
Angga Lisdiyanto
Angga Lisdiyanto 2016년 6월 29일
Thanks.
By the way, what is difference of ~cellfun with cellfun?
José-Luis
José-Luis 2016년 6월 30일
~ is the NOT operator.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by