필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by