Effacer les filtres
Effacer les filtres

find repeated columns of a matrix

11 vues (au cours des 30 derniers jours)
pavlos
pavlos le 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

Réponse acceptée

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

Plus de réponses (1)

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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by