Borrar filtros
Borrar filtros

find repeated columns of a matrix

11 visualizaciones (últimos 30 días)
pavlos
pavlos el 1 de Nov. de 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

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 1 de Nov. de 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)))

Más respuestas (1)

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

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by