I would like to calculate the Hamming distance between two strings of variable length in Matlab. For fixed length strings the following syntax solves my problem:
str1 = 'abcde';
str2 = 'abedc';
sum(str1 ~= str2)
ans = 2
How can I do this efficiently for variable length strings?
Thank you!
EDIT: Because this is a legitimate question: For every character one string is longer then the other, the Hamming distance should be incremented. So for example for
str1 = 'abcdef';
str2 = 'abc';
The answer should be 3.