Please note that the recommended version of Scilab is 2026.0.0. This page might be outdated.
See the recommended documentation of this function
unique
extracts (and sorts) distinct components of a vector or a matrix
Syntax
[N ,k] = unique(M) [N ,k] = unique(M, orient)
Arguments
- M
vector or matrix of numbers or strings.
- orient
flag with possible values : 1 or "r", 2 or "c"
- N
- If
orientis not used: Vector of extractedMcomponents sorted in ascending order. - If
orientis used: Matrix of extractedMrows or columns, sorted in lexicographic ascending order.
- If
- k
Vector of indices of first encountered occurences, such that
N(i) = M(k(i))orN(i,:) = M(k(i),:)orN(:,i) = M(:,k(i)).
Description
unique(M) returns a vector which retains the
unique entries of M in ascending order.
unique(M,"r") or unique(M,1) removes all
duplicates of M rows and returns unique rows in lexicographic
ascending order.
unique(M,"c") or unique(M,2) removes all
duplicates of M columns and returns unique columns in lexicographic
ascending order.
![]() |
Examples
See also
- members — count (and locate) in an array each element or row or column of another array
- gsort — sorting by quick sort algorithm
- vectorfind — finds in a matrix rows or columns matching a vector
- grep — find matches of a string in a vector of strings
- union — extract union components of a vector
- intersect — returns the vector of common values of two vectors
| Report an issue | ||
| << union | Set operations | Signal processing >> |
