title: Calculate Hamming distance between strings of variable length in Matlab
body: <p>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:</p>
  
  <pre><code>str1 = 'abcde';
  str2 = 'abedc';
  
  sum(str1 ~= str2)
  
  ans = 2
  </code></pre>
  
  <p>How can I do this efficiently for variable length strings?</p>
  
  <p>Thank you!</p>
  
  <p>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</p>
  
  <pre><code>str1 = 'abcdef';
  str2 = 'abc';
  </code></pre>
  
  <p>The answer should be 3.</p>