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일

0 개 추천

data = {'a', 'b', 'c', 'o', 'm'};
idx = find(~cellfun(@isempty,strfind(data,'o')));
your_result = data(idx-1:idx+1)

댓글 수: 2

Thanks.
By the way, what is difference of ~cellfun with cellfun?
José-Luis
José-Luis 2016년 6월 30일
~ is the NOT operator.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Cell Arrays에 대해 자세히 알아보기

질문:

2016년 6월 29일

댓글:

2016년 6월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by