Please note that the recommended version of Scilab is 2025.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
orient
is not used: Vector of extractedM
components sorted in ascending order. - If
orient
is used: Matrix of extractedM
rows 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 >> |