Products & Services Solutions Academia Support User Community Company

Learn more about Symbolic Math Toolbox   

unique - Find unique elements of symbolic matrices or their numeric approximations

Syntax

unique(A)
unique(vpa(A))

Description

unique(A) for the symbolic matrix A returns the same values as in A, but with no repetitions. The unique command also sorts the elements of the resulting vector alphabetically. If the resulting vector contains symbolic numbers, the command sorts them in ascending order.

unique(vpa(A)) for the symbolic matrix A returns the numeric approximations of the elements of A, but with no repetitions. The unique command also sorts the elements of the resulting vector in ascending order.

Examples

Sort the elements of a symbolic vector excluding duplicates:

syms a b c d e x;
unique([a b c 5 2 b c d 3 b e x x])

The result is:

ans =
[ 2, 3, 5, a, b, c, d, e, x]
 

Sort the elements of the symbolic Hilbert matrix:

H = sym(hilb(5));
unique(H)

The result is a column vector of unique elements:

ans =
 1/9
 1/8
 1/7
 1/6
 1/5
 1/4
 1/3
 1/2
   1
 

Sort the numeric approximations of the elements of the symbolic Hilbert matrix:

H = sym(hilb(5));
unique(vpa(H))

The result is:

ans =
 0.11111111111111111111111111111111
                              0.125
 0.14285714285714285714285714285714
 0.16666666666666666666666666666667
                                0.2
                               0.25
 0.33333333333333333333333333333333
                                0.5
                                1.0

See Also

sort

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS