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!


