title: Efficiently find Unique triplets of three char vectors in MATLAB
body: <p>Given three arrays of char, say <code>size(a) = [N,80]</code>, <code>size(b) = [N,100]</code>;  <code>size(c) = [N,10]</code>;</p>
  
  <p>When <code>N=5</code>
  <code>a</code>, <code>b</code> and <code>c</code> look something like,</p>
  
  <pre><code>ans =
  
    5×80 char array
  
  ‘efawefref’
  ‘Afreafraef’
  ‘afeafefaef’
  ‘afeafeaffa’
  ‘afeafaefae’
  </code></pre>
  
  <p>I want to find the unique entries (not combinations), this is, the unique entries of <code>x = [a, b, c]</code></p>
  
  <p>Of course I can do <code>unique([a, b, c])</code> but this is terrible slow for this data. <code>N~1e7</code></p>
  
  <p>Example,</p>
  
  <pre><code>   a = [   'timon ';
          'simba ';
          'nala  ';
          'timon ';
          'mufasa'];
  
  b = [   'boar   ';
          'lion   ';
          'lionese';
          'boar   ';
          'lion   '];
  
  c = [   'chubby';
          'small ';
          'fat   ';
          'chubby';
          'fit   '];
  
  
  unique([a,b,c],'rows')
  
  ans =
  
    4×19 char array
  
      'mufasalion   fit   '
      'nala  lionesefat   '
      'simba lion   small '
      'timon boar   chubby'
  
  
  size(unique([a,b,c],'rows'),1)
  
  ans =
  
       4
  </code></pre>
  
  <p>IS there a smarter way to do this?</p>
  
  <p>EDIT: results from answers
  For entries of these sizes,</p>
  
  <pre><code>&gt;&gt; size(a)
  
  ans =
  
      11724952          76
  
  &gt;&gt; size(b)
  
  ans =
  
      11724952          64
  
  &gt;&gt; size(c)
  
  ans =
  
      11724952           6
  </code></pre>
  
  <p>Results</p>
  
  <p>@myradio</p>
  
  <pre><code>&gt;&gt; tic, size(unique(horzcat(a,b,c),'rows')), toc
  
  ans =
  
       1038303         146
  
  Elapsed time is 74.402044 seconds.
  </code></pre>
  
  <p>@gnovice 1</p>
  
  <pre><code>&gt;&gt; tic, size(unique(cellstr([a b c]))), toc
  
  ans =
  
       1038303           1
  
  Elapsed time is 77.044463 seconds.
  </code></pre>
  
  <p>@gnovice 2</p>
  
  <pre><code>&gt;&gt; tic, map = containers.Map(cellstr([a b c]), ones(length(a), 1)); size(map.keys.'), toc
  
  ans =
  
       1038303           1
  
  Elapsed time is 58.732947 seconds.
  </code></pre>
  
  <p>@Wolfie</p>
  
  <pre><code>&gt;&gt; tic, size(unique( [categorical(cellstr(a)),categorical(cellstr(b)),categorical(cellstr(c))], 'rows' )), toc
  
  ans =
  
       1038303           3
  
  Elapsed time is 189.517131 seconds.
  </code></pre>
  
  <p>@obchardon</p>
  
  <pre><code>&gt;&gt; tic, x = primes(2000); a1 = prod(x(a+0),2); b1 = prod(x(b+0),2); c1 = prod(x(c+0),2); size(unique([a1,b1,c1],'rows')), toc
  
  ans =
  
       1038258           3
  
  Elapsed time is 46.889431 seconds.
  </code></pre>
  
  <p>I am puzzled about this last one, I tried with other examples and it always gives a slightly lower value.</p>