Calculate Hamming distance between two strings of binary digits in Matlab

GobiasKoffi picture GobiasKoffi · Nov 14, 2010 · Viewed 12.9k times · Source

I have two equal length strings containing 1's and 0's. Each string is 128-bits long, and I want to calculate the Hamming distance between them. What's the best way I can go about doing this?

e.g. a='1000001' and b='1110001' --> dist=Hamming(a,b);

Answer

Donnie picture Donnie · Nov 14, 2010

Use pdist with the hamming parameter.