DSP Blockset    
Sort

Sort the elements in the input by value.

Library

Statistics

Description

The Sort block sorts the elements in each column of the input using a Quicksort algorithm. The Mode parameter specifies the block's mode of operation, and can be set to Value, Index, or Value and Index.

Value Mode

When Mode is set to Value, the block sorts the elements in each column of the M-by-N input matrix u in order of ascending or descending value, as specified by the Sort order parameter.

For convenience, length-M 1-D vector inputs and sample-based length-M row vector inputs are both treated as M-by-1 column vectors.

The output at each sample time, val, is a M-by-N matrix containing the sorted columns of u. Complex inputs are sorted by magnitude, and the output has the same frame status as the input.

Index Mode

When Mode is set to Index, the block sorts the elements in each column of the M-by-N input matrix u,

and outputs the sample-based M-by-N index matrix, idx. The jth column of idx is an index vector that permutes the jth column of u to the desired sorting order:

The index value outputs are always 32-bit unsigned integer values.

As in Value mode, length-M 1-D vector inputs and sample-based length-M row vector inputs are both treated as M-by-1 column vectors.

Value and Index Mode

When Mode is set to Value and Index, the block outputs both the sorted matrix, val, and the index matrix, idx.

Dialog Box

Mode
The block's mode of operation: Output the sorted matrix (Value), the index matrix (Index), or both (Value and Index).
Sort order
The order in which to sort the input values, Descending or Ascending. Tunable, except in the Simulink external mode.

Supported Data Types

To learn how to convert to the above data types in MATLAB and Simulink, see Supported Data Types and How to Convert to Them.

See Also

Histogram
DSP Blockset
Median
DSP Blockset
sort
MATLAB

Also see Statistics for a list of all the blocks in the Statistics library.


  Singular Value Decomposition Spectrum Scope