MATLAB Function Reference Previous page   Next Page
unique

Find unique elements of vector

Syntax

Description

b = unique(A) returns the same values as in A but with no repetitions. The resulting vector is sorted in ascending order. A can be a cell array of strings.

b = unique(A, 'rows') returns the unique rows of A.

[b, m, n] = unique(...) also returns index vectors m and n such that b = A(m) and A = b(n). Each element of m is the greatest subscript such that b = A(m). For row combinations, b = A(m,:) and A = b(n,:).

Examples

Because NaNs are not equal to each other, unique treats them as unique elements.

See Also

intersect, ismember, issorted, setdiff, setxor, union


Previous page  union unix Next page

© 1994-2005 The MathWorks, Inc.