title: Error in implementing kmeans clustering
body: <p>There is a grayscale image <code>A</code> , I want to apply kmeans clustering with <code>K=2</code>, MATLAB gives me an error for the following code, How to resolve?</p>
  
  <pre><code>[idx,ctrs] = kmeans(im2double(A),2);
  ??? Error using ==&gt; minus
  Number of array dimensions must match for binary array op.
  
  Error in ==&gt; kmeans&gt;onlineUpdate at 576
          Del(:,i) = (m(i) ./ (m(i) + sgn)) .* sum((X - C(repmat(i,n,1),:)).^2, 2);
  
  Error in ==&gt; kmeans at 341
          converged = onlineUpdate(); 
  </code></pre>