\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 = 

 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 = 

 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 = 

 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 = 

 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 = 

 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 = 

 5 
 5 
 5 
 3 
 5 
 3 
 4 
 1 
 3 
 2 

--> unique(A)

ans = 

 1 
 2 
 3 
 4 
 5 

--> [b,m,n] = unique(A,'rows');
--> b

ans = 

 1 
 2 
 3 
 4 
 5 

--> A(m)

ans = 

 1 
 2 
 3 
 4 
 5 

--> b(n)

ans = 

 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 = 

 ['hi']   ['bye']   ['good']   ['tell']   ['hi']   ['bye']   

--> unique(A)

ans = 

 ['bye']   
 ['good']   
 ['hi']   
 ['tell']   


\end{verbatim}
