Elementary functions: improved help pages.
[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 version="5.0-subset Scilab" xml:id="unique" xml:lang="en"
14           xmlns="http://docbook.org/ns/docbook"
15           xmlns:xlink="http://www.w3.org/1999/xlink"
16           xmlns:svg="http://www.w3.org/2000/svg"
17           xmlns:ns5="http://www.w3.org/1999/xhtml"
18           xmlns:mml="http://www.w3.org/1998/Math/MathML"
19           xmlns:db="http://docbook.org/ns/docbook">
20   <info>
21     <pubdate>$LastChangedDate$</pubdate>
22   </info>
23
24   <refnamediv>
25     <refname>unique</refname>
26
27     <refpurpose>extract unique components of a vector or matrices</refpurpose>
28   </refnamediv>
29
30   <refsynopsisdiv>
31     <title>Calling Sequence</title>
32
33     <synopsis>
34       [N [,k]]=unique(M)
35       [N [,k]]=unique(M ,orient)
36     </synopsis>
37   </refsynopsisdiv>
38
39   <refsection>
40     <title>Arguments</title>
41
42     <variablelist>
43       <varlistentry>
44         <term>M</term>
45
46         <listitem>
47           <para>vector or matrix of numbers or strings</para>
48         </listitem>
49       </varlistentry>
50
51       <varlistentry>
52         <term>orient</term>
53
54         <listitem>
55           <para>flag with possible values : 1 or "r", 2 or "c"</para>
56         </listitem>
57       </varlistentry>
58
59       <varlistentry>
60         <term>N</term>
61
62         <listitem>
63           <para>vector or matrix of numbers or strings</para>
64         </listitem>
65       </varlistentry>
66
67       <varlistentry>
68         <term>k</term>
69
70         <listitem>
71           <para>vector of integers</para>
72         </listitem>
73       </varlistentry>
74     </variablelist>
75   </refsection>
76
77   <refsection>
78     <title>Description</title>
79
80     <para><literal>unique(M)</literal> returns a vector which retains the
81     unique entries of <literal>M</literal> in ascending order.</para>
82
83     <para><literal>unique(M,"r")</literal> or
84     <literal>unique(M,1)</literal>returns the unique rows of
85     <literal>M</literal> in lexicographic ascending order.</para>
86
87     <para><literal>unique(M,"c")</literal> or
88     <literal>unique(M,2)</literal>returns the unique columns of
89     <literal>M</literal> in lexicographic ascending order.</para>
90
91     <para>If required the output argument <literal>k</literal> contains the
92     position of the first encountered unique entries.</para>
93   </refsection>
94
95   <refsection>
96     <title>Examples</title>
97
98     <programlisting role="example"><![CDATA[ 
99 M=round(2*rand(20,1));
100
101 unique(M)
102 [N,k]=unique(M)
103
104 unique(string(M))
105 [N,k]=unique(string(M))
106
107 A = [0,0,1,1;
108      0,1,1,1;
109      2,0,1,1;
110      0,2,2,2;
111      2,0,1,1;
112      0,0,1,1];
113 T='x'+string(A);
114
115 //unique rows
116
117 [m,k]=unique(A,'r')
118 unique(T,'r')
119
120 //unique columns
121 [m,k]=unique(T,'c')
122 unique(A,'c')
123  ]]></programlisting>
124   </refsection>
125
126   <refsection role="see also">
127 <title>See Also</title>
128
129     <simplelist type="inline">
130       <member><link linkend="union">union</link></member>
131
132       <member><link linkend="intersect">intersect</link></member>
133
134       <member><link linkend="gsort">gsort</link></member>
135
136       <member><link linkend="lex_sort">lex_sort</link></member>
137     </simplelist>
138   </refsection>
139 </refentry>