Skip to content

uniquetol

set · scripts/set/uniquetol.m

C = uniquetol (A)
C = uniquetol (A, tol)
C = uniquetol (..., "ByRows", tf, "DataScale", scale, "OutputAllIndices", tf)
[C, ia, ic] = uniquetol (...)

Unique values of a real floating point array, where values closer than
tol * DataScale are treated as equal.

The default tolerance is 1e-12 (1e-6 for single) and the default scale is
the largest finite magnitude in A.  Sorted values are grouped greedily: the
smallest remaining value anchors a group that takes in every following value
within tol * DataScale of it, and the anchor is the representative.  NaN
values are never grouped.  "ia" and "ic" are column vectors with C = A(ia);
with "OutputAllIndices" "ia" is a cell column holding every index of a group.