Products & Services Solutions Academia Support User Community Company

Learn more about Symbolic Math Toolbox   

sort - Sort symbolic vectors or polynomials

Syntax

Y = sort(v)
Y = sort(p)

Description

Y = sort(v) sorts the elements of a symbolic vector v in numerical or lexicographic order.

Y = sort(p) sorts the terms in a polynomial p in order of decreasing powers.

Examples

Sort the elements of a symbolic matrices and vectors:

syms a b c d e;
sort(sym(magic(3)))
sort([a c e b d])

The results are:

ans =
[ 1, 2, 3, 4, 5, 6, 7, 8, 9]
 
ans =
[ a, b, c, d, e]

Sort the terms of the polynomial:

syms a b c d e x;
sort([a c e b d]*x.^(0:4).')

The result is:

ans =
d*x^4 + b*x^3 + e*x^2 + c*x + a

See Also

sym2poly, coeffs

  


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