## 26 Sets

Octave has a limited set 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.

— Function File: create_set (x)
— Function File: create_set (x, "rows")

> Return a row vector containing the unique values in x, sorted in ascending order. For example,

>               create_set ([ 1, 2; 3, 4; 4, 2; 1, 2 ])
>               => [ 1, 2, 3, 4 ]

> If the optional second input argument is the string "rows" each row of the matrix x will be considered an element of set. For example,

>               create_set ([ 1, 2; 3, 4; 4, 2; 1, 2 ], "rows")
>               =>  1   2
>                   3   4
>                   4   2

> See also: union, intersection, complement, unique.

— Function File: unique (x)

> Return the unique elements of x, sorted in ascending order. If x is a row vector, return a row vector, but if x is a column vector or a matrix return a column vector. — Function File: unique (A, 'rows')

> > Return the unique rows of A, sorted in ascending order. — Function File: [y, i, j] = unique (x)

> > > Return index vectors i and j such that `x(i)==y` and `y(j)==x`.

> > > Additionally, one of 'first' or 'last' can be given as an argument. 'last' (default) specifies that the highest possible indices are returned in i, while 'first' means the lowest.

> > > See also: union, intersect, setdiff, setxor, ismember.