MATLAB: Hamming distance in one matrix

hdMATLAB

greetings every body i want to calculate the hamming distance between the elements of row of random binary matrix that i have produces with function dec2bin. matrix as : 10100100010001001 ; 01110010100110010; 10000100001000111; 11100011111000011; how to calculate the HD between these lines.

Best Answer

  • B = [10100100010001001;
    01110010100110010;
    10000100001000111;
    11100011111000011];
    D = pdist(B,'minkowski',1);
    or
    D = pdist(B);