Main Content

Median Filter

R2026b

Median filter

  • Median Filter block

Libraries:
DSP System Toolbox / Filtering / Filter Designs
DSP System Toolbox / Statistics

Description

The Median Filter block computes the moving median of the input signal along each channel independently over time. The block uses the sliding window method to compute the moving median. In this method, a window of specified length moves over each channel sample by sample, and the block computes the median of the data in the window. This block performs median filtering on the input data over time.

You can change the window length during simulation by selecting the Make window length tunable parameter. Specify the tunable window length from the block dialog box by updating the Window length parameter or through the input port WL by selecting the Specify window length from input port parameter. For more details, see Algorithms. (since R2026b)

Ports

Input

expand all

Data over which the block computes moving median. The block accepts real-valued or complex-valued multichannel inputs, that is, m-by-n size inputs, where m ≥ 1, and n ≥ 1. The block also accepts variable-size inputs. During simulation, you can change the size of each input channel. However, the number of channels cannot change.

This port is unnamed until you enable the WL input port.

Data Types: single | double
Complex Number Support: Yes

Since R2026b

Specify the tunable window length as a positive integer. The block uses this value as the sliding window length for computing the moving median.

When you select Auto-adjust invalid window length, the block adjusts invalid window length values from the input port and issues a warning. For more information on what values are invalid, see the Auto-adjust invalid window length parameter description.

When you clear the Auto-adjust invalid window length parameter, the block throws an error for invalid window length values.

Dependencies

This port appears when you select Make window length tunable and Specify window length from input port.

Data Types: single | double

Output

expand all

The size of the moving median output matches the size of the input. The block uses the sliding window method to compute the moving median. For more details, see Algorithms.

Data Types: single | double
Complex Number Support: Yes

Parameters

expand all

Since R2026b

Select this parameter to make the window length tunable, that is, you can change the window length during simulation through the block dialog box by updating the Window length parameter or through the input port WL by selecting the Specify window length from input port parameter.

When you clear this parameter, the window length is fixed and you cannot change it during simulation. Specify the window length through the Window length parameter.

Since R2026b

When you select this parameter, the block reads the tunable window length from the input port, WL. When you clear this parameter, the block reads the tunable window length from the Window length parameter.

Dependencies

This parameter appears when you select Make window length tunable.

Specify the length of the sliding window in samples as a positive integer.

When you select the Make window length tunable parameter, the window length you specify is tunable and must be less than or equal to the value you specify in the Maximum window length parameter. When you clear the Make window length tunable parameter, the window length is fixed. (since R2026b)

Dependencies

If you select Make window length tunable, you must clear the Specify window length from input port parameter.

Since R2026b

Specify the maximum value of the tunable window length as a positive integer. The window length you specify during simulation cannot exceed this value.

Dependencies

This parameter appears when you select Make window length tunable.

Since R2026b

When you select this parameter, the block adjusts invalid window length values from the input port and issues a warning.

  • If the tunable window length value is greater than Maximum window length, the block uses Maximum window length.

  • If the tunable window length value is less than 1, the block uses 1.

  • If the tunable window length value is not an integer, the block uses the floored value.

When you clear this parameter, the block throws an error for invalid window length values.

Dependencies

This parameter appears when you select Make window length tunable and Specify window length from input port.

Specify the type of simulation to run. You can set this parameter to:

  • Interpreted execution — Simulate model using the MATLAB® interpreter. This option shortens startup time.

  • Code generation — Simulate model using generated C code. The first time you run a simulation, Simulink® generates C code for the block. The C code is reused for subsequent simulations as long as the model does not change. This option requires additional startup time but provides faster subsequent simulations.

Block Characteristics

Data Types

double | single

Multidimensional Signals

No

Variable-Size Signals

Yes

Algorithms

expand all

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2016b

expand all