How to index a cell vector of strings?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Azzi Abdelmalek
le 22 Juin 2015
suppose s={'x','a','x','y','b','b','c','y','y','x'}, what is the expected result?
Réponse acceptée
Azzi Abdelmalek
le 22 Juin 2015
s={'a','b','x','c','d','x'}
idx=find(ismember(s,'x'))
2 commentaires
Azzi Abdelmalek
le 22 Juin 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))']
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!