How to find out whether there is a repetitive element in the columns of a matrix?
    6 ビュー (過去 30 日間)
  
       古いコメントを表示
    
example: 
a=[ 1 2 3
      4 2 1
      1 4 2]
Bold ones are that what I am looking for. There is no need for imformation about their indexes. I just want to know whether there is or not.
Thank you.
0 件のコメント
採用された回答
  madhan ravi
      
      
 2019 年 4 月 17 日
        Repetitions_in_columns=true(size(a,2),1);
for k = 1:size(a,2)
    Repetitions_in_columns(k)=any(sum(a(:,k)==unique(a(:,k)).')>1);
end 
Repetitions_in_columns  % 1 means yes 0 means no each 
その他の回答 (1 件)
  Stephen23
      
      
 2019 年 4 月 17 日
        "I just want to know whether there is or not."
>> any(diff(sort(a,1),1)==0,1)
ans =
  1  1  0
2 件のコメント
参考
カテゴリ
				Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


