フィルターのクリア

How to index a cell vector of strings?

1 回表示 (過去 30 日間)
Cary
Cary 2015 年 6 月 22 日
コメント済み: Cary 2015 年 6 月 22 日
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 件のコメント
Cary
Cary 2015 年 6 月 22 日
To be more clear...I need to group the 'x's together and the 'y's together, and have their associated rows indexed.
Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 22 日
suppose s={'x','a','x','y','b','b','c','y','y','x'}, what is the expected result?

サインインしてコメントする。

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 22 日
s={'a','b','x','c','d','x'}
idx=find(ismember(s,'x'))
  2 件のコメント
Azzi Abdelmalek
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))']
Cary
Cary 2015 年 6 月 22 日
Thank you very much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by