开发者

Calculate Hamming distance between two strings of binary digits in Matlab

开发者 https://www.devze.com 2023-01-24 20:12 出处:网络
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 doin开发者_如何学

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 doin开发者_如何学Cg this?

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


Use pdist with the hamming parameter.


dist = sum(a ~= b);
0

精彩评论

暂无评论...
验证码 换一张
取 消