How to index a cell vector of strings?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Azzi Abdelmalek
2015-6-22
suppose s={'x','a','x','y','b','b','c','y','y','x'}, what is the expected result?
采纳的回答
Azzi Abdelmalek
2015-6-22
s={'a','b','x','c','d','x'}
idx=find(ismember(s,'x'))
2 个评论
Azzi Abdelmalek
2015-6-22
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))']
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!