필터 지우기
필터 지우기

find repeated columns of a matrix

조회 수: 11 (최근 30일)
pavlos
pavlos 2012년 11월 1일
Hello,
Consider a 8x100 matrix.
It consists of 5 8x1 columns that are repeated randomly, namely the col1,...,col5.
How can I find the indexes of the columns that contain the col1?
Thank you.
Pavlos

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 11월 1일
A=repmat(rand(8,5),1,100/5)
A=A(:,randperm(100)) % your matrix
col1=A(:,1)
idx=find(~any(bsxfun(@minus, A,col1)))

추가 답변 (1개)

Matt J
Matt J 2012년 11월 1일
편집: Matt J 2012년 11월 1일
indices=find(ismember(yourmatrix.',col1.','rows'))
  댓글 수: 4
Matt J
Matt J 2012년 11월 1일
Hah! I hit 500 points because of your upvote. Thanks!
pavlos
pavlos 2012년 11월 2일
thanks for your help

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by