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!