find repeated columns of a matrix

13 Ansichten (letzte 30 Tage)
pavlos
pavlos am 1 Nov. 2012
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

Akzeptierte Antwort

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

Weitere Antworten (1)

Matt J
Matt J am 1 Nov. 2012
Bearbeitet: Matt J am 1 Nov. 2012
indices=find(ismember(yourmatrix.',col1.','rows'))
  4 Kommentare
Matt J
Matt J am 1 Nov. 2012
Hah! I hit 500 points because of your upvote. Thanks!
pavlos
pavlos am 2 Nov. 2012
thanks for your help

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by