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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Discrete Math에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by