<html lang="en"> <head> <title>Sets - GNU Octave</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GNU Octave"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="prev" href="Statistics.html#Statistics" title="Statistics"> <link rel="next" href="Polynomial-Manipulations.html#Polynomial-Manipulations" title="Polynomial Manipulations"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Sets"></a> <p> Next: <a rel="next" accesskey="n" href="Polynomial-Manipulations.html#Polynomial-Manipulations">Polynomial Manipulations</a>, Previous: <a rel="previous" accesskey="p" href="Statistics.html#Statistics">Statistics</a>, Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a> <hr> </div> <h2 class="chapter">27 Sets</h2> <p>Octave has a limited number of functions for managing sets of data, where a set is defined as a collection of unique elements. In Octave a set is represented as a vector of numbers. <!-- unique scripts/set/unique.m --> <p><a name="doc_002dunique"></a> <div class="defun"> — Function File: <b>unique</b> (<var>x</var>)<var><a name="index-unique-2679"></a></var><br> — Function File: <b>unique</b> (<var>x, "rows"</var>)<var><a name="index-unique-2680"></a></var><br> — Function File: <b>unique</b> (<var><small class="dots">...</small>, "first"</var>)<var><a name="index-unique-2681"></a></var><br> — Function File: <b>unique</b> (<var><small class="dots">...</small>, "last"</var>)<var><a name="index-unique-2682"></a></var><br> — Function File: [<var>y</var>, <var>i</var>, <var>j</var>] = <b>unique</b> (<var><small class="dots">...</small></var>)<var><a name="index-unique-2683"></a></var><br> <blockquote><p>Return the unique elements of <var>x</var>, sorted in ascending order. If the input <var>x</var> is a vector then the output is also a vector with the same orientation (row or column) as the input. For a matrix input the output is always a column vector. <var>x</var> may also be a cell array of strings. <p>If the optional argument <code>"rows"</code> is supplied, return the unique rows of <var>x</var>, sorted in ascending order. <p>If requested, return index vectors <var>i</var> and <var>j</var> such that <code>x(i)==y</code> and <code>y(j)==x</code>. <p>Additionally, if <var>i</var> is a requested output then one of <code>"first"</code> or <code>"last"</code> may be given as an input. If <code>"last"</code> is specified, return the highest possible indices in <var>i</var>, otherwise, if <code>"first"</code> is specified, return the lowest. The default is <code>"last"</code>. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dunion.html#doc_002dunion">union</a>, <a href="doc_002dintersect.html#doc_002dintersect">intersect</a>, <a href="doc_002dsetdiff.html#doc_002dsetdiff">setdiff</a>, <a href="doc_002dsetxor.html#doc_002dsetxor">setxor</a>, <a href="doc_002dismember.html#doc_002dismember">ismember</a>. </p></blockquote></div> <ul class="menu"> <li><a accesskey="1" href="Set-Operations.html#Set-Operations">Set Operations</a> </ul> </body></html>