anyway to translate this command using 'cellfun'

1 Ansicht (letzte 30 Tage)
Yu Li
Yu Li am 14 Mai 2019
Kommentiert: Yu Li am 14 Mai 2019
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

Akzeptierte Antwort

Stephen23
Stephen23 am 14 Mai 2019
Bearbeitet: Stephen23 am 14 Mai 2019
Note that it is simpler to use strfind:
>> C = strfind(test,'_');
>> C{:}
ans = 2
ans = 2

Weitere Antworten (0)

Kategorien

Mehr zu Discrete Math finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by