title: How to obtain jaccard similarity in matlab
body: <p>I have a table:</p>
  
  <pre><code>   x   y   z 
  A  2   0   3   
  B  0   3   0    
  C  0   0   4    
  D  1   4   0
  </code></pre>
  
  <p>I want to calculate the Jaccard similarity in Matlab, between the vectors A, B, C and D.
  The formula is :</p>
  
  <p><img src="https://i.stack.imgur.com/gL3oV.jpg" alt="enter image description here"></p>
  
  <p>In this formula |x| and |y| indicates the number of items which are not zero. For example |A| number of items that is not zero is 2, for |B| and |C| it is 1, and for |D| it is 2.   </p>
  
  <p>|x intersect y| indicates the number of common items which are not zero. |A intersect B| is 0. |A intersect D| is 1, because the value of x in both is not zero.</p>
  
  <p>e.g.: jaccard(A,D)= 1/3=0.33</p>
  
  <p>How can I implement this in Matlab?</p>