How to index a cell vector of strings?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Cary
am 22 Jun. 2015
Kommentiert: Cary
am 22 Jun. 2015
I have a vector of cells, each one is 'x' or 'y'. How can I index them, similar to the "find" function? Thank you.
4 Kommentare
Azzi Abdelmalek
am 22 Jun. 2015
suppose s={'x','a','x','y','b','b','c','y','y','x'}, what is the expected result?
Akzeptierte Antwort
Azzi Abdelmalek
am 22 Jun. 2015
s={'a','b','x','c','d','x'}
idx=find(ismember(s,'x'))
2 Kommentare
Azzi Abdelmalek
am 22 Jun. 2015
Maybe you need this
s={'x','a','x','y','b','b','c','y','y','x'}
idx=ismember(s,'x')
idy=ismember(s,'y')
outx=[s(idx)' num2cell(find(idx))']
outy=[s(idy)' num2cell(find(idy))']
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays 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!