title: MATLAB: How to remove repeating elements from two corresponding column vectors?
body: <p>I have two column vectors X and Y of the same size derived by following Matlab code:</p>
  
  <pre><code>mask = im2bw(rgb2gray(imread('http://i.stack.imgur.com/ES8w1.jpg')));
  separation = bwulterode(mask,'euclidean',[0 0 0; 1 1 1; 0 0 0]).*mask; 
  [X, Y] = find(separation);
  imshow(mask); hold on; plot(Y, X, '.r');
  </code></pre>
  
  <p>Each element in X has a corresponding element in Y. I need to remove the repeating values in X and also their correspondent values in Y without rearranging the order of elements. I'm using this code, but it does not remove the duplicating elements. What is the problem? </p>
  
  <pre><code>A=[X,Y];
  [UniXY,Index]=unique(A,'rows','first');
  DupIndex=setdiff(1:size(A,1),Index);
  A(DupIndex,:)=[];
  X=A(:,1);
  Y=A(:,2);
  figure; imshow(mask); hold on; plot(Y, X, '.r');
  </code></pre>
  
  <p>Any help is appreciated. </p>