Azzera filtri
Azzera filtri

find repeated columns of a matrix

11 visualizzazioni (ultimi 30 giorni)
pavlos
pavlos il 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

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 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)))

Più risposte (1)

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

Accedi per commentare.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by