\section{UNIQUE Unique}

\subsection{Usage}

Returns a vector containing the unique elements of an array.  The first
form is simply
\begin{verbatim}
   y = unique(x)
\end{verbatim}
where \verb|x| is either a numerical array or a cell-array of strings.  The 
result is sorted in increasing order.  You can also retrieve two sets
of index vectors
\begin{verbatim}
   [y, m, n] = unique(x)
\end{verbatim}
such that \verb|y = x(m)| and \verb|x = y(n)|.  If the argument \verb|x| is a matrix,
you can also indicate that FreeMat should look for unique rows in the
matrix via
\begin{verbatim}
   y = unique(x,'rows')
\end{verbatim}
and
\begin{verbatim}
   [y, m, n] = unique(x,'rows')
\end{verbatim}
\subsection{Example}

Here is an example in row mode
\begin{verbatim}
--> A = randi(1,3*ones(15,3))
A = 
  <int32>  - size: [15 3]
 
Columns 1 to 3
 2  3  2  
 2  1  1  
 2  2  3  
 2  1  3  
 2  2  3  
 2  1  2  
 1  2  2  
 1  1  1  
 3  1  3  
 2  2  2  
 1  3  3  
 1  2  3  
 3  1  1  
 3  3  1  
 2  3  3  
--> unique(A,'rows')
ans = 
  <int32>  - size: [14 3]
 
Columns 1 to 3
 1  1  1  
 1  2  2  
 1  2  3  
 1  3  3  
 2  1  1  
 2  1  2  
 2  1  3  
 2  2  2  
 2  2  3  
 2  3  2  
 2  3  3  
 3  1  1  
 3  1  3  
 3  3  1  
--> [b,m,n] = unique(A,'rows');
--> b
ans = 
  <int32>  - size: [14 3]
 
Columns 1 to 3
 1  1  1  
 1  2  2  
 1  2  3  
 1  3  3  
 2  1  1  
 2  1  2  
 2  1  3  
 2  2  2  
 2  2  3  
 2  3  2  
 2  3  3  
 3  1  1  
 3  1  3  
 3  3  1  
--> A(m,:)
ans = 
  <int32>  - size: [14 3]
 
Columns 1 to 3
 1  1  1  
 1  2  2  
 1  2  3  
 1  3  3  
 2  1  1  
 2  1  2  
 2  1  3  
 2  2  2  
 2  2  3  
 2  3  2  
 2  3  3  
 3  1  1  
 3  1  3  
 3  3  1  
--> b(n,:)
ans = 
  <int32>  - size: [15 3]
 
Columns 1 to 3
 2  3  2  
 2  1  1  
 2  2  3  
 2  1  3  
 2  2  3  
 2  1  2  
 1  2  2  
 1  1  1  
 3  1  3  
 2  2  2  
 1  3  3  
 1  2  3  
 3  1  1  
 3  3  1  
 2  3  3  

\end{verbatim}
Here is an example in vector mode
\begin{verbatim}
--> A = randi(1,5*ones(10,1))
A = 
  <int32>  - size: [10 1]
 
Columns 1 to 1
 5  
 5  
 5  
 3  
 5  
 3  
 4  
 1  
 3  
 2  
--> unique(A)
ans = 
  <int32>  - size: [5 1]
 
Columns 1 to 1
 1  
 2  
 3  
 4  
 5  
--> [b,m,n] = unique(A,'rows');
--> b
ans = 
  <int32>  - size: [5 1]
 
Columns 1 to 1
 1  
 2  
 3  
 4  
 5  
--> A(m)
ans = 
  <int32>  - size: [5 1]
 
Columns 1 to 1
 1  
 2  
 3  
 4  
 5  
--> b(n)
ans = 
  <int32>  - size: [10 1]
 
Columns 1 to 1
 5  
 5  
 5  
 3  
 5  
 3  
 4  
 1  
 3  
 2  

\end{verbatim}
For cell arrays of strings.
\begin{verbatim}
--> A = {'hi','bye','good','tell','hi','bye'}
A = 
  <cell array> - size: [1 6]
 
Columns 1 to 3
 hi    bye    good    
 
Columns 4 to 6
 tell    hi    bye    
--> unique(A)
ans = 
  <cell array> - size: [4 1]
 
Columns 1 to 1
 bye    
 good    
 hi    
 tell    

\end{verbatim}
