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 Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by