* Get ride of the useless tag
[scilab.git] / scilab / modules / elementary_functions / help / en_US / setoperations / unique.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) 2008 - INRIA
5  * 
6  * This file must be used under the terms of the CeCILL.
7  * This source file is licensed as described in the file COPYING, which
8  * you should have received as part of this distribution.  The terms
9  * are also available at    
10  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11  *
12  -->
13 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="unique" xml:lang="en">
14     <refnamediv>
15         <refname>unique</refname>
16         <refpurpose>extract unique components of a vector or matrices</refpurpose>
17     </refnamediv>
18     <refsynopsisdiv>
19         <title>Calling Sequence</title>
20         <synopsis>
21             [N [,k]]=unique(M)
22             [N [,k]]=unique(M ,orient)
23         </synopsis>
24     </refsynopsisdiv>
25     <refsection>
26         <title>Arguments</title>
27         <variablelist>
28             <varlistentry>
29                 <term>M</term>
30                 <listitem>
31                     <para>vector or matrix of numbers or strings</para>
32                 </listitem>
33             </varlistentry>
34             <varlistentry>
35                 <term>orient</term>
36                 <listitem>
37                     <para>flag with possible values : 1 or "r", 2 or "c"</para>
38                 </listitem>
39             </varlistentry>
40             <varlistentry>
41                 <term>N</term>
42                 <listitem>
43                     <para>vector or matrix of numbers or strings</para>
44                 </listitem>
45             </varlistentry>
46             <varlistentry>
47                 <term>k</term>
48                 <listitem>
49                     <para>vector of integers</para>
50                 </listitem>
51             </varlistentry>
52         </variablelist>
53     </refsection>
54     <refsection>
55         <title>Description</title>
56         <para>
57             <literal>unique(M)</literal> returns a vector which retains the
58             unique entries of <literal>M</literal> in ascending order.
59         </para>
60         <para>
61             <literal>unique(M,"r")</literal> or
62             <literal>unique(M,1)</literal>returns the unique rows of
63             <literal>M</literal> in lexicographic ascending order.
64         </para>
65         <para>
66             <literal>unique(M,"c")</literal> or
67             <literal>unique(M,2)</literal>returns the unique columns of
68             <literal>M</literal> in lexicographic ascending order.
69         </para>
70         <para>
71             If required the output argument <literal>k</literal> contains the
72             position of the first encountered unique entries.
73         </para>
74     </refsection>
75     <refsection>
76         <title>Examples</title>
77         <programlisting role="example"><![CDATA[ 
78 M=round(2*rand(20,1));
79
80 unique(M)
81 [N,k]=unique(M)
82
83 unique(string(M))
84 [N,k]=unique(string(M))
85
86 A = [0,0,1,1;
87      0,1,1,1;
88      2,0,1,1;
89      0,2,2,2;
90      2,0,1,1;
91      0,0,1,1];
92 T='x'+string(A);
93
94 //unique rows
95
96 [m,k]=unique(A,'r')
97 unique(T,'r')
98
99 //unique columns
100 [m,k]=unique(T,'c')
101 unique(A,'c')
102  ]]></programlisting>
103     </refsection>
104     <refsection role="see also">
105         <title>See Also</title>
106         <simplelist type="inline">
107             <member>
108                 <link linkend="union">union</link>
109             </member>
110             <member>
111                 <link linkend="intersect">intersect</link>
112             </member>
113             <member>
114                 <link linkend="gsort">gsort</link>
115             </member>
116             <member>
117                 <link linkend="lex_sort">lex_sort</link>
118             </member>
119         </simplelist>
120     </refsection>
121 </refentry>