FUNCTION REFERENCE
unique
Unique values.
Unique values.
Syntax
C = unique(A)Syntax
[C, ia, ic] = unique(A, 'stable')Syntax
[C, ia, ic] = unique(A, 'rows')Sorted by default; 'stable' keeps first-occurrence order. ia gives first occurrences (or last with 'last'). Each NaN counts as distinct.
Example
unique([3 1 3 2]) % [1 2 3]Differences from MATLAB: Real/logical 2-D arrays and character/cellstr inputs are supported. Real/logical inputs support 'rows', 'stable', 'sorted', 'first' and 'last' (not 'legacy'). Character/cellstr forms also support 'legacy'; for cellstr, 'rows' warns and is ignored. Complex input supports 'rows', 'stable', 'sorted', 'first' and 'last' (not 'legacy'), in the order of sort; NaNs stay distinct.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.