dsp.Median

(To be removed) Median value of input

Description

The dsp.Median object computes the median value of the input. The object can compute the median along each dimension (row or column) of the input or of the entire input.

Note

The dsp.Median System object™ will be removed in a future release. To compute the median, use the median function. To compute the median in running mode (also known as moving median), use the dsp.MedianFilter object. For more information, see Compatibility Considerations.

To compute the median of the input:

  1. Create the dsp.Median object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects? (MATLAB).

Creation

Description

med = dsp.Median returns a median System object, med, that computes the median along the columns of the input using the quick sort sorting method.

med = dsp.Median(Name,Value) returns a median System object, med, with each property set to the value you specify.

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects (MATLAB).

Specify the method the object should use to sort the data before computing the median. You can specify Quick sort or Insertion sort. The quick sort algorithm uses a recursive sort method and is usually faster at sorting more than 32 elements. The insertion sort algorithm uses a nonrecursive method and is usually faster at sorting less than 32 elements. If you are using the Median object to generate code, you should use the insertion sort algorithm to prevent recursive function calls in your generated code.

Specify the dimension along which the object computes the median values.

Specify the dimension of the input signal (as a one-based value) over which the object computes the median. The cannot exceed the number of dimensions in the input signal.

Dependencies

This property applies only when you set the Dimension property to Custom.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Fixed-Point Properties

Specify the rounding method.

Specify the overflow action.

Specify the product data type.

Specify the product data type as a scaled numerictype object with a Signedness of Auto.

Dependencies

This property applies only when you set the ProductDataType property to Custom.

Specify the accumulator data type.

Specify the fixed-point accumulator data type as a scaled numerictype object with a Signedness of Auto.

Dependencies

This property applies only when you set the AccumulatorDataType property to Custom.

Specify the output data type.

Specify the data type of the output as a scaled numerictype object with a Signedness of Auto.

Dependencies

This property applies only when you set the OutputDataType property to Custom.

Usage

Description

y = med(x) computes the median value of the input x and returns the result in y.

Input Arguments

expand all

Data input, specified as a vector or a matrix. If x is a matrix, each column is treated as an independent channel. The median is computed along each channel.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
Complex Number Support: Yes

Output Arguments

expand all

Median output of the input signal, returned as a scalar, vector, or a matrix. The object computes the median of the input along each channel. If the input is a column vector, the output is a scalar. If the input is a multichannel signal, the output is a 1-by-N vector, where N is the number of input channels.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
Complex Number Support: Yes

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

Compute The Median

Note: If you are using R2016a or an earlier release, replace each call to the object with the equivalent step syntax. For example, obj(x) becomes step(obj,x).

Compute the median value of the input column using the dsp.Median object.

 med = dsp.Median;
 x = [7 -9 0 -1 2 0 3 5 -9]';
 y = med(x)
y = 0

Algorithms

This object implements the algorithm, inputs, and outputs described on the Median block reference page. The object properties correspond to the block properties, except the Treat sample-based row input as a column block parameter is not supported by the dsp.Median System object.

Compatibility Considerations

expand all

Warns starting in R2019b

Extended Capabilities

See Also

Functions

Objects

Introduced in R2012a