How do I find similar columns in a matrix?
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
Hello! So i have a matrix of 32x129600, I mean, there are 129600 columns of 32 elements each. What I want is to find the columns that are similar, let's say the difference between their elements is less than 0.001, how can I do this?
Thank you so much for your answers.
댓글 수: 2
채택된 답변
  Star Strider
      
      
 2019년 2월 1일
        
      편집: Star Strider
      
      
 2019년 2월 4일
  
      I would use the pdist (link) function.  It will compare the columns of your data using one of the built-in distance metrics, or one you can define.  
EDIT —      (4 Feb 2019 at 21:50)
Using the matrix you posted (That I will call ‘M’), the pdist call would be: 
dr = pdist(M','cityblock');                                 % Transpose ‘M’ To Compare Columns
Result = squareform(dr)
and the results for this matrix are then: 
Result =
         0    0.3065    0.8071    1.4538
    0.3065         0    0.5030    1.1494
    0.8071    0.5030         0    0.6467
    1.4538    1.1494    0.6467         0
To find the rows and columns of those values that meet your criterion: 
    [Row,Col] = find(Result <= 0.001 & Result > 0);
that here returns an empty matrix.  
댓글 수: 11
추가 답변 (1개)
  KSSV
      
      
 2019년 2월 1일
        You can have a llok on ismember, ismemebrtol. Also you can use isequal for logical check whether the lements matching exactly. You may also plot a histogram and see. You can run a loop, get the difference and check. There are multiple methods to achieve what you want. 
참고 항목
카테고리
				Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



