title: How to get unique pairs of numbers in matlab where both numbers have not repeated in the matrix before
body: <p>I have an input matrix as below</p>
  
  <pre><code>all = [12 16;12 13;8 14;14 19;3 6;8 6;13 25;25 14;7 2];
  </code></pre>
  
  <p>I need the following output</p>
  
  <pre><code>output = [12 16;8 14;3 6;13 25;7 2];
  </code></pre>
  
  <p>The explanation for the output is as follows. </p>
  
  <p>First row of input i.e. <code>12 16</code> is the first row in output as both the numbers have never been repeated before in the output matrix (obviously).</p>
  
  <p>Second row of input i.e <code>12 13</code> is not needed as the number <code>12</code> is present in first row of output i.e repeated </p>
  
  <p>Third row of input i.e <code>8 14</code> is second row of output as both the numbers have never been repeated before in the output matrix.</p>
  
  <p>Fourth row of input i.e <code>14 19</code> is not needed as the  number <code>14</code> is present in output i.e repeated</p>
  
  <p>On similar lines 
  <code>3 6</code> needed as both are not repeated, </p>
  
  <p><code>8 6</code> not needed as both <code>8</code> and <code>6</code> are repeated, </p>
  
  <p><code>13 25</code>  needed as both are not repeated </p>
  
  <p><code>25 14</code> not needed as both are repeated</p>
  
  <p><code>7 2</code> needed as both are not repeated</p>
  
  <p>I am not able to get any ideas to start. Any help will be appreciated.</p>
  
  <p>Thanks!</p>