anyway to translate this command using 'cellfun'

1 回表示 (過去 30 日間)
Yu Li
Yu Li 2019 年 5 月 14 日
コメント済み: Yu Li 2019 年 5 月 14 日
Hi:
I have a cell array like below:
test{1}='1_xxxxx';
test{2}='2_xxxxx';
....
now I want to fine the location of '_' in each cell, below are my command:
for i=1:1:length(test)
loc{i}=ismember(test,'_');
end
to further improve my code, I found a 'cellfun' function, but I failed to find a way to translate the above command using 'cellfun'. is there anyway to do this?
Thanks!
Yu

採用された回答

Stephen23
Stephen23 2019 年 5 月 14 日
編集済み: Stephen23 2019 年 5 月 14 日
Note that it is simpler to use strfind:
>> C = strfind(test,'_');
>> C{:}
ans = 2
ans = 2
  1 件のコメント
Yu Li
Yu Li 2019 年 5 月 14 日
Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Math についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by