If i have two binary matrix how can calculate the similarities between them
    4 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Firas Al-Kharabsheh
 am 5 Mai 2016
  
    
    
    
    
    Kommentiert: Walter Roberson
      
      
 am 6 Mai 2016
            If i have (n,m) matrix M
        M =     [ 1 0 1 1 0 1
                  0 1 1 0 0 1
                  0 0 1 0 1 0
                  1 1 1 1 0 0]
And after some operation i found this two matrix which every one shows the number of group of ones in each row and in each column
             M_row = [ 1 2 1
                       2 1 0
                       1 1 0
                       4 0 0 ]
            M_col = [ 1 1 0 1 0
                      1 1 4 1 2 ]
After that generate a random matrix X in same size of M and then calculate the X_row and X_col like Matrix M
After that i need some way or a function to determine the similarities between M and X using the M_row ,M_col , X_row and X_col
0 Kommentare
Akzeptierte Antwort
  Walter Roberson
      
      
 am 6 Mai 2016
        
      Bearbeitet: Walter Roberson
      
      
 am 6 Mai 2016
  
      if isequal(M_row, X_row) && isequal(M_col, X_col)
  similarity = 1;
else
  similarities = {'purple', 'tuba', 'beer', 'tardigrade', 'top quark'};
  similarity = similarities{randi(length(similarities))};
end
4 Kommentare
  Walter Roberson
      
      
 am 6 Mai 2016
				Well, here it is in function form then:
function similarity = compare_Mx(M_row, M_col, X_row, X_col)
  if isequal(M_row, X_row) && isequal(M_col, X_col)
    similarity = 1;
  else
    similarities = {'purple', 'tuba', 'beer', 'tardigrade', 'top quark'};
    similarity = similarities{randi(length(similarities))};
  end
end
The result of the function is the similarity level that is computed. The function meets all of your specifications for how similarity is to be computed. If it does not produce the answer that you want, then perhaps you should change your specification of "similarity".
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

