FIR Halfband Decimator
Decimate signal using polyphase FIR halfband filter
The FIR Halfband Decimator block performs polyphase decimation of the input signal by a factor of two. The block uses an FIR equiripple design or a Kaiser window design to construct the halfband filters. The implementation takes advantage of the zero-valued coefficients of the FIR halfband filter, making one of the polyphase branches a delay. You can also use the block to implement the analysis portion of a two-band filter bank to separate a signal into lowpass and highpass subbands. For more information, see Algorithms.
The input signal can be a real- or complex-valued column vector or matrix. If the input signal is a matrix, the block treats each column of the matrix as an independent channel. The number of rows in the input signal must be a multiple of 2. The block supports fixed-point operations and ARM® Cortex® code generation. For more information on ARM Cortex code generation, see Code Generation for ARM Cortex-M and ARM Cortex-A Processors.
- Filter specification
Parameters used to design the FIR halfband filter.
Transition width and stopband attenuation(default) — Design the filter using Transition width (Hz) and Stopband attenuation (dB). This design is the minimum order design.
Filter order and transition width— Design the filter using Filter order and Transition width (Hz).
Filter order and stopband attenuation— Design the filter using Filter order and Stopband attenuation (dB).
Coefficients— Specify the filter coefficients directly through the Numerator parameter.
- Transition width (Hz)
Transition width, specified as a real positive scalar in Hz. The transition width must be less than half the input sample rate. You can specify the transition width when Filter specification is set to
Filter order and transition widthor
Transition width and stopband attenuation. The default is
- Filter order
Filter order, specified as an even positive integer. You can specify the filter order when Filter specification is set to
Filter order and transition widthor
Filter order and stopband attenuation. The default is
- Stopband attenuation (dB)
Stopband attenuation, specified as a real positive scalar in dB. You can specify the stopband attenuation when Filter specification is set to
Filter order and stopband attenuationor
Transition width and stopband attenuation. The default is
Specify the FIR halfband filter coefficients directly as a row vector. The coefficients must comply with the FIR halfband impulse response format. If half the order of the filter,
(length(Numerator) - 1)/2, is even, every other coefficient starting from the first coefficient must be a zero except for the center coefficient which must be a 0.5. If half the order of the filter is odd, the sequence of alternating zeros with a 0.5 at the center starts at the second coefficient.
This parameter appears when Filter specification is set to
Coefficients. The default is the coefficients vector returned by
- Design method
Specify the filter design method as one of the following:
Auto–– The algorithm automatically chooses the filter design method depending on the filter design parameters. The algorithm uses the equiripple or the Kaiser window method to design the filter.
If the design constraints are very tight, such as very high stopband attenuation or very narrow transition width, then the algorithm automatically chooses the Kaiser method, as this method is optimal for designing filters with very tight specifications. However, if the design constraints are not tight, then the algorithm chooses the equiripple method.
When you set the Design method parameter to
Auto, you can determine the method used by the algorithm by examining the passband and stopband ripple characteristics of the designed filter. If the block used the equiripple method, the passband and stopband ripples of the designed filter have a constant amplitude in the frequency response. If the filter design method the block chooses in the
Automode is not suitable for your application, manually specify the Design method as
Equiripple–– The algorithm uses the equiripple method.
Kaiser–– The algorithm uses the Kaiser window method.
This parameter appears when you set Filter specification to
Filter order and stopband attenuation,
Filter order and transition width, or
Transition width and stopband attenuation.
- Output highpass subband
When you select this check box, the block acts as a synthesis filter bank and synthesizes a signal from the highpass and lowpass subbands. When you clear this check box, the block acts as an FIR halfband decimator and accepts a single vector– or matrix–valued input.
- Inherit sample rate from input
When you select this check box, the block inherits its sample rate from the input signal. When you clear this check box, you specify the sample rate in Input sample rate (Hz). This parameter appears when you set Filter specification to any option other than
- Input sample rate (Hz)
Input sample rate, specified as a scalar in Hz. The default is
44100. This parameter appears when you set Filter specification to any option other than
Coefficientsand clear the Inherit sample rate from input parameter.
- View Filter Response
Opens the Filter Visualization Tool FVTool and displays the magnitude/phase response of the FIR Halfband Decimator. The response is based on the block dialog box parameters. Changes made to these parameters update FVTool.
To update the magnitude response while FVTool is running, modify the dialog box parameters and click Apply.
- Simulate using
Type of simulation to run. You can set this parameter to:
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 simulation speed than
Simulate model using the MATLAB® interpreter. This option shortens startup time but has slower simulation speed than
Data Types Tab
- Rounding mode
Rounding method for the output fixed-point operations. The rounding methods are
Zero. The default is
Fixed-point data type of the coefficients, specified as one of the following:
fixdt(1,16)(default) — Signed fixed-point data type of word length
16, with binary point scaling. The block determines the fraction length automatically from the coefficient values in such a way that the coefficients occupy maximum representable range without overflowing.
fixdt(1,16,0)— Signed fixed-point data type of word length
16and fraction length,
0. You can change the fraction length to any other integer value.
<data type expression>— Specify the data type using an expression that evaluates to a data type object, for example, numeric type (
15). Specify the sign mode of this data type as
Refresh Data Type— Refreshes to the default data type.
Click the Show data type assistant button to display the data type assistant, which helps you set the stage input parameter.
See Specify Data Types Using Data Type Assistant (Simulink) for more information.
Supported Data Types
|Port||Supported Data Types|
The ideal lowpass halfband filter is given by
The ideal filter is not realizable because the impulse response is noncausal and not absolutely summable. However, the impulse response of the ideal lowpass filter possesses some important properties that are required of a realizable approximation. Specifically, the ideal lowpass halfband filter’s impulse response is:
equal to 0 for all even-indexed samples
equal to 1/2 at n=0. You can see this by using L’Hopital’s rule on the continuous-valued equivalent of the discrete-time impulse response.
The ideal highpass halfband filter is given by
Evaluating the preceding integral gives the following impulse response
The ideal highpass halfband filter’s impulse is:
equal to 0 for all even-indexed samples
equal to 1/2 at n=0.
The FIR halfband decimator uses a causal FIR approximation to the ideal halfband response, which is based on minimizing the norm of the error (minimax). See Algorithms for more details.
The coefficients of a Kaiser window are computed from this equation:
where I0 is the zeroth-order modified Bessel function of the first kind.
To obtain a Kaiser window that represents an FIR filter with stopband attenuation of α dB, use this β.
The filter order n is given by:
where Δω is the transition width.
Filter Design Method
The FIR halfband decimator algorithm uses the equiripple or the Kaiser window method to design
the FIR halfband filter. When the design constraints are tight, such as very high
stopband attenuation or very narrow transition width, use the Kaiser window method. When
the design constraints are not tight, use the equiripple method. If you are not sure of
which method to use, set the design method to
Auto. In this mode, the
algorithm automatically chooses a design method from the two methods that optimally
meets the specified filter constraints.
Halfband Equiripple Design
In the equiripple method, the algorithm uses a minimax (minimize the maximum error) FIR design to design a fullband linear phase filter with the desired specifications. The algorithm upsamples a fullband filter to replace the even-indexed samples of the filter with zeros and creates a halfband filter. It then sets the filter tap corresponding to the group delay of the filter in samples to 1/2. This yields a causal linear-phase FIR filter approximation to the ideal halfband filter defined in Halfband Filters. See  for a description of this filter design method using the Remez exchange algorithm. Since you can design a filter using this approximation method with a constant ripple both in the passband and stopband, the filter is also known as the equiripple filter.
Kaiser Window Design
In the Kaiser window method, the algorithm first truncates the ideal halfband filter defined in Halfband Filters, then it applies a Kaiser window defined in Kaiser Window. This yields a causal linear-phase FIR filter approximation to the ideal halfband filter.
For more information on designing FIR halfband filters, see FIR Halfband Filter Design.
Polyphase Implementation with Halfband Filters
The FIR halfband decimator uses an efficient polyphase implementation for halfband filters when you filter the input signal. The chief advantage of the polyphase implementation is that you can downsample the signal prior to filtering. This allows you to filter at the lower sampling rate.
Splitting a filter’s impulse response, h(n), into two polyphase components results in an even polyphase component with z-transform
and an odd polyphase component with z-transform
The z-transform of the filter can be written in terms of the even and odd polyphase components as
Graphically, you can represent filtering and input followed by downsampling by two with the following figure
Using the multirate noble identity for downsampling, you can move the downsampling operation before filtering. This allows you to filter at the lower rate.
For a halfband filter, the only nonzero coefficient in the even polyphase component is the coefficient corresponding to z0. Implementing the halfband filter as a causal FIR filter shifts the nonzero coefficient to approximately z-N/4 where N is the number of filter taps. This process is illustrated in the following figure.
The top plot shows a halfband filter of order 52. The bottom plot shows the even polyphase component. Both of these filters are noncausal. Delaying the even polyphase component by 13 samples creates a causal FIR filter.
To efficiently implement the halfband decimator, the algorithm replaces the delay block and downsampling operator with a commutator switch. This is illustrated in the following figure where one polyphase component is replaced by a gain and delay.
The commutator switch takes input samples from a single branch and supplies every other sample to one of the two polyphase components for filtering. This halves the sampling rate of the input signal. Which polyphase component reduces to a simple delay depends on whether the half order of the filter is even or odd. This is because the delay required to make the even polyphase component causal can be odd or even depending on the filter half order.
To confirm this behavior, run the following code in the MATLAB command prompt and inspect the polyphase components of the following filters:
filterspec = "Filter order and stopband attenuation"; halfOrderEven = dsp.FIRHalfbandDecimator(Specification=filterspec,... FilterOrder=64,StopbandAttenuation=80,DesignMethod="Auto"); halfOrderOdd = dsp.FIRHalfbandDecimator(Specification=filterspec,... FilterOrder=54,StopbandAttenuation=80,DesignMethod="Auto"); polyphase(halfOrderEven) polyphase(halfOrderOdd)
To summarize, the FIR halfband decimator:
Decimates the input prior to filtering and filters the even and odd polyphase components of the input separately with the even and odd polyphase components of the filter.
Exploits the fact that one filter polyphase component is a simple delay for a halfband filter.
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Design and simulate fixed-point systems using Fixed-Point Designer™.
Introduced in R2015b