Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Unique values within tolerance

`C = uniquetol(A,tol)`

`C = uniquetol(A)`

```
[C,IA,IC]
= uniquetol(___)
```

`[___] = uniquetol(___,Name,Value)`

returns
the unique elements in `C`

= uniquetol(`A`

,`tol`

)`A`

using tolerance `tol`

.
Two values, `u`

and `v`

, are within
tolerance if

`abs(u-v) <= tol*max(abs(A(:)))`

That is, `uniquetol`

scales the `tol`

input
based on the magnitude of the data.

`uniquetol`

is similar to `unique`

.
Whereas `unique`

performs exact comparisons, `uniquetol`

performs
comparisons using a tolerance.

`[___] = uniquetol(___,`

uses
additional options specified by one or more Name-Value pair arguments
using any of the input or output argument combinations in previous
syntaxes. For example, `Name,Value`

)`uniquetol(A,'ByRows',true)`

determines
the unique rows in `A`

.

There can be multiple valid

`C`

outputs that satisfy the condition,*no two elements in*. The`C`

are within tolerance of each other`uniquetol`

function just returns one of the valid outputs.`uniquetol`

sorts the input lexicographically, and then starts at the lowest value to find unique values within tolerance. As a result, changing the sorting of the input could change the output. For example,`uniquetol(-A)`

might not give the same results as`-uniquetol(A)`

.

Was this topic helpful?