find repeated columns of a matrix

11 次查看(过去 30 天)
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!

请先登录,再进行评论。

类别

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