Median - Find median value of input

Library

Statistics

dspstat3

Description

The Median block computes the median value of each row or column of the input, along vectors of a specified dimension of the input, or of the entire input. The median of a set of input values is calculated as follows:

  1. The values are sorted.

  2. If the number of values is odd, the median is the middle value.

  3. If the number of values is even, the median is the average of the two middle values.

For a given input u, the size of the output array y depends on the setting of the Find the median value over parameter. For example, consider a 3-dimensional input signal of size M-by-N-by-P:

Complex inputs are sorted by magnitude squared. For complex value , the magnitude squared is a2+b2.

The Median block accepts real and complex fixed-point and floating-point inputs.

Fixed-Point Data Types

For fixed-point inputs, you can specify accumulator, product output, and output data types as discussed in Dialog Box. Not all these fixed-point parameters are applicable for all types of fixed-point inputs. The following table shows when each kind of data type and scaling is used.

 Output data typeAccumulator data typeProduct output data type

Even M

X

X

 

Odd M

X

 

Odd M and complex

X

X

X

Even M and complex

X

X

X

The accumulator and output data types and scalings are used for fixed-point signals when M is even. The result of the sum performed while calculating the average of the two central rows of the input matrix is stored in the accumulator data type and scaling. The total result of the average is then put into the output data type and scaling.

The accumulator and product output parameters are used for complex fixed-point inputs. The sum of the squares of the real and imaginary parts of such an input are formed before the input elements are sorted, as described in Description. The results of the squares of the real and imaginary parts are placed into the product output data type and scaling. The result of the sum of the squares is placed into the accumulator data type and scaling.

For fixed-point inputs that are both complex and have even M, the data types are used in all of the ways described. Therefore, in such cases, the accumulator type is used in two different ways.

Dialog Box

The Main pane of the Median block dialog appears as follows.

Sort algorithm

Specify whether to sort the elements of the input using a Quick sort or an Insertion sort algorithm.

Find the median value over

Specify whether to find the median value along rows, columns, entire input, or the dimension specified in the Dimension parameter. For more information, see Description.

Treat sample-based row input as a column

Select to treat sample-based length-M row vector inputs as M-by-1 column vectors. This parameter is only visible when the Find the median value over parameter is set to Each column.

Dimension

Specify the dimension (one-based value) of the input signal, over which the median is computed. The value of this parameter cannot exceed the number of dimensions in the input signal. This parameter is only visible when the Find the median value over parameter is set to Specified dimension.

The Fixed-point pane of the Median block dialog appears as follows.

Rounding mode

Select the rounding mode for fixed-point operations.

Overflow mode

Select the overflow mode for fixed-point operations.

Product output

Use this parameter to specify how you want to designate the product output word and fraction lengths:

Accumulator

Use this parameter to specify the accumulator word and fraction lengths resulting from a complex-complex multiplication in the block:

Output

Choose how you specify the output word length and fraction length:

Lock scaling against changes by the autoscaling tool

Select this parameter to prevent any fixed-point scaling you specify in this block mask from being overridden by the autoscaling feature of the Fixed-Point Tool. See the fxptdlg reference page for more information.

Supported Data Types

PortSupported Data Types

Input

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed and unsigned)

  • 8-, 16-, 32-, and 128-bit signed integers

  • 8-, 16-, 32-, and 128-bit unsigned integers

Output

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed and unsigned)

  • 8-, 16-, 32-, and 128-bit signed integers

  • 8-, 16-, 32-, and 128-bit unsigned integers

See Also

MaximumSignal Processing Blockset
MeanSignal Processing Blockset
MinimumSignal Processing Blockset
SortSignal Processing Blockset
Standard DeviationSignal Processing Blockset
VarianceSignal Processing Blockset
medianMATLAB

  


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