title: issue with sub2ind and matrix of matrix in matlab with images
body: <p>I here by post the code why I came across while exploring one technique.</p>
  
  <pre><code>   Y = repmat((1:m)', [1 n]);
     X = repmat(1:n, [m 1]) - labels_left;
     X(X&lt;1) = 1;
     indices = sub2ind([m,n],Y,X);
  
    final_labels = labels_left;
    final_labels(abs(labels_left - labels_right(indices))&gt;=1) = -1;
  </code></pre>
  
  <p>In above code labels left is single channel image.[m n] is the size of that image. I want to know how this sub2ind works in above code.And Iam also facing problem in the last statement which contains </p>
  
  <pre><code>  labels_right(indices)
  </code></pre>
  
  <p>what the above expression evaluates to.Here labels right is also an image</p>