DSP Blockset | ![]() ![]() |
Find the median value of an input.
Library
Description
The Median block computes the median value of each column in an M-by-N input matrix.
y = median(u) % Equivalent MATLAB code
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, y
, is a sample-based 1-by-N vector containing the median value for each column in u
.
When M is odd, the block sorts the column elements by value, and outputs the central row of the sorted matrix.
s = sort(u); y = s((M+1)/2,:)
When M is even, the block sorts the column elements by value, and outputs the average of the two central rows in the sorted matrix.
s = sort(u); y = mean([s(M/2,:);s(M/2+1,:)])
Complex inputs are sorted by magnitude, and the real and imaginary components are averaged independently (for even M).
Dialog Box
See Also
Maximum |
DSP Blockset |
Mean |
DSP Blockset |
Minimum |
DSP Blockset |
Sort |
DSP Blockset |
Standard Deviation |
DSP Blockset |
Variance |
DSP Blockset |
median |
MATLAB |
![]() | Mean | Minimum | ![]() |