MATLAB: Find repeated columns of a matrix

MATLABmatrix manipulation

Hello,
Consider a 8×100 matrix.
It consists of 5 8×1 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

Best Answer

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