find repeated columns of a matrix

2 ビュー (過去 30 日間)
pavlos
pavlos 2012 年 11 月 1 日
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!
pavlos
pavlos 2012 年 11 月 2 日
thanks for your help

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by