This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

dsp.Median System object

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.

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

Syntax

med = dsp.Median
med = dsp.Median(Name,Value)

Description

example

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 faster at sorting more than 32 elements. The insertion sort algorithm uses a nonrecursive method and is 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. You can specify one of | All | Row | Column | Custom |.

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 as one of | Ceiling | Convergent | Floor | Nearest | Round | Simplest | Zero |.

Specify the overflow action as one of | Wrap | Saturate |.

Specify the product data type as one of | Same as input | Custom |.

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 as one of | Same as product | Same as input | Custom |.

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 as one of | Same as accumulator | Same as product | Same as input | Custom |.

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

For versions earlier than R2016b, use the step function to run the System object algorithm. The arguments to step are the object you created, followed by the arguments shown in this section.

For example, y = step(obj,x) and y = obj(x) perform equivalent operations.

Syntax

y = med(x)

Description

example

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 mean 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

expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,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:

Treat sample-based row input as a column block parameter is not supported by the dsp.Median System object.

Extended Capabilities

Introduced in R2012a