Polyphase FIR decimator
FIRDecimator object resamples vector or
matrix inputs along the first dimension. The object reseamples at
a rate M times slower than the input sampling rate,
where M is the integer-valued downsampling factor.
The decimation combines an FIR anti-aliasing filter with downsampling.
The FIR decimator object uses a polyphase implementation of the FIR
To resample vector or matrix inputs along the first dimension:
Define and set up your FIR decimator. See Construction.
step to resample the vector
or matrix inputs according to the properties of
The behavior of
step is specific to each object in
Starting in R2016b, instead of using the
H = dsp.FIRDecimator returns
an FIR decimator,
H, which applies an FIR filter
with a cutoff frequency of
to the input and downsamples the filter output by factor of 2. This System object supports
H = dsp.FIRDecimator (' returns an FIR decimator,
each property set to the specified value.
H = dsp.FIRDecimator(DECIM,
NUM, ' returns an FIR decimator,
DecimationFactor property set
NUM, and other specified properties set
to the specified values.
Specify the downsampling factor as a positive integer. The FIR
decimator reduces the sampling rate of the input by this factor. The
size of the input along the first dimension must be a multiple of
the decimation factor. The default is
FIR filter coefficient source
Specify the source of the numerator coefficients as one of
FIR filter coefficients
Specify the numerator coefficients of the FIR filter in powers of z–1. The following equation defines the system function for a filter of length L:
To prevent aliasing
as a result of downsampling, the filter transfer function should have
a normalized cutoff frequency no greater than 1/
Specify the implementation of the FIR filter as either
|clone||Create FIR decimator object with same property values|
|fvtool||Open filter visualization tool|
|getNumInputs||Number of expected inputs to step method|
|getNumOutputs||Number of outputs of step method|
|isLocked||Locked status for input attributes and nontunable properties|
|phasez||Unwrapped phase response|
|release||Allow property value and input characteristics changes|
|reset||Reset filter states of FIR decimator|
|step||Decimate input by integer factor|
A polyphase implementation of an FIR decimator splits the lowpass FIR filter impulse response into M different subfilters, where M is the downsampling, or decimation factor. Let h(n) denote the FIR filter impulse response of length L and u(n) the input signal. Decimating the filter output by a factor of M is equivalent to the downsampled convolution:
The key to the efficiency of polyphase filtering is that specific
input values are only multiplied by select values of the impulse response
in the downsampled convolution. For example, letting M=2,
the input values u(0),u(2),u(4), ... are
only combined with the filter coefficients h(0),h(2),h(4),...,
and the input values u(1),u(3),u(5),
... are only combined with the filter
By splitting the filter coefficients into two polyphase subfilters,
no unnecessary computations are performed in the convolution. The
outputs of the convolutions with the polyphase subfilters are interleaved
and summed to yield the filter output. The following MATLAB® code
demonstrates how to construct the two polyphase subfilters for the
default order 35 filter in the
and the default
value of two:
M = 2; Num = fir1(35,0.4); FiltLength = length(Num); Num = flipud(Num(:)); if (rem(FiltLength, M) ~= 0) nzeros = M - rem(FiltLength, M); Num = [zeros(nzeros,1); Num]; % Appending zeros end len = length(Num); nrows = len / M; PolyphaseFilt = flipud(reshape(Num, M, nrows).');
The columns of
PolyphaseFilt are subfilters
containing the two phases of the filter in
For a general downsampling factor of M , there
are M phases and therefore M subfilters.
This example shows how to decimate a sum of sine waves with angular frequencies of pi/4 and 2pi/3 radians/sample by a factor of two. To prevent aliasing, the FIR decimator filters out the 2pi/3 radians/sample component before downsampling.
x = cos(pi/4*[0:95]')+sin(2*pi/3*[0:95]'); H = dsp.FIRDecimator; y = H(x);
View group delay of default FIR filter
Group delay of the default linear-phase FIR filter is 17.5 samples. Downsampling by a factor of two expect an approx. 8.75 sample delay in the output y with the initial filter states of zero
subplot(211); stem(x(1:length(x)/2),'b','markerfacecolor',[0 0 1]); title('Input Signal'); subplot(212); stem(y,'b','markerfacecolor',[0 0 1]); title('Output--Lowpass filtered and downsampled by 2');
This example shows how to reduce the sampling rate of an audio signal by 1/2 and plays it.
hmfr = dsp.AudioFileReader('OutputDataType',... 'single'); hap = audioDeviceWriter(22050/2); hfirdec = dsp.FIRDecimator; while ~isDone(hmfr) frame = step(hmfr); y = step(hfirdec, frame); step(hap, y); end release(hmfr); pause(0.5); release(hap);
This object implements the algorithm, inputs, and outputs described on the FIR Decimation block reference page. The object properties correspond to the block parameters, except:
Framing – The FIR decimator
object only supports
Maintain input frame rate
Output buffer initial conditions – The FIR decimator object does not support this parameter.
Rate options – The FIR decimator object does not support this parameter.
Input processing The FIR decimator object does not support this parameter.