Name
unique — mimics Matlab function unique
CALLING SEQUENCE
[b,m,n]=unique(A)
PARAMETERS
- Input
A = a (1 x p) vector or a (m x p) matrix
r = 'rows' (optional)
- Output
b = - a (1 x k) vector (if A is a vector)
- or a (m x k) matrix (if A is a matrix)
with k <= p
m = a (1 x k) vector such that b=A(m) (b=A(m,:) if A is a matrix)
n = a (1 x k) vector such that b=A(m) (b=A(m,:) if A is a matrix)
DESCRIPTION
Function that mimics Matlab function unique, that returns in b the same values as in A, but with no repetition (of lines if 'row' has been given
as 2nd argument); vectors m and n such that b=A(m) (A(m,:) if 'row' has been given) and A=b(n) (A=b(n,:) if 'row' has been given ).
(however, contrary to matlab function unique, it does not work with strings).
EXAMPLE
A=[ 1 1 5 6 2 3 3 9 8 6 2 4];[b,m,n]=unique(A)
This example gives the following:
n =
! 1. 1. 5. 6. 2. 3. 3. 8. 7. 6. 2. 4. !
m =
! 2. 11. 7. 12. 3. 10. 9. 8. !
b =
! 1. 2. 3. 4. 5. 6. 8. 9. !