FIR Halfband Interpolator
Interpolate signal using polyphase FIR half band filter
Libraries:
DSP System Toolbox /
Filtering /
Multirate Filters
Description
The FIR Halfband Interpolator block performs interpolation 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 block uses an efficient polyphase implementation to filter the input. The implementation takes advantage of the zerovalued coefficients of the FIR halfband filter, making one of the polyphase branches a delay. For more information, see Algorithms. You can also use this block to implement the synthesis portion of a twoband filter bank to synthesize a signal from lowpass and highpass subbands.
The input signal can be a real or complexvalued column vector or a matrix. If the input signal is a matrix, the block treats each column of the matrix as an independent channel. The block supports fixedpoint operations and ARM^{®} Cortex^{®} code generation. For more information on ARM Cortex code generation, see Code Generation for ARM CortexM and ARM CortexA Processors.
The block also supports SIMD code generation. For details, see Code Generation.
Ports
Input
LP — Data input
column vector  matrix
Specify the data input as a vector or a matrix. If the input signal is a matrix, the block treats each column of the matrix as an independent channel.
When you select the Input highpass subband parameter, this block acts as a halfband synthesis filter bank. The input at this port is then the lowpass subband output of a halfband analysis filter bank.
This port is unnamed until you select the Input highpass subband parameter.
Data Types: single
 double
 int8
 int16
 int32
 int64
 uint8
 uint16
 uint32
 uint64
 fixed point
Complex Number Support: Yes
HP — Second input to the synthesis filter bank
column vector  matrix
Specify the second input to the synthesis filter bank as a column vector or a matrix. This signal is the highpass subband output of a halfband analysis filter bank. If the input signal is a matrix, the block treats each column of the matrix as an independent channel.
The size, data type, and complexity of both the inputs must be the same.
Dependency
To enable this port, select the Input highpass subband parameter.
Data Types: single
 double
 int8
 int16
 int32
 int64
 fixed point
Complex Number Support: Yes
Output
Output — Output of FIR halfband interpolator
column vector  matrix
Output of the FIR halfband interpolator, returned as a column vector or a matrix. The number of rows in the interpolator output is twice the number of rows in the input signal.
When the output is fixedpoint, it is signed only.
Data Types: single
 double
 int8
 int16
 int32
 int64
 fixed point
Complex Number Support: Yes
Parameters
Main Tab
Filter specification — Filter design parameters
Transition width and stopband
attenuation
(default)  Filter order and transition width
 Filter order and stopband
attenuation
 Coefficients
Select the parameters that the block uses 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 in Hz
4.1e3
 positive real scalar
Specify the transition width as a real positive scalar in Hz. The transition width must be less than 1/2 the sample rate of the input signal.
Dependencies
To enable this parameter, set Filter
specification to Filter order and
transition width
or Transition width
and stopband attenuation
.
Filter order — Filter order
52
 even positive integer
Specify the filter order as an even positive integer.
Dependencies
To enable this parameter, set Filter
specification to Filter order and
transition width
or Filter order and
stopband attenuation
.
Stopband attenuation (dB) — Stopband attenuation
80
(default)  positive real scalar
Specify the stopband attenuation as a real positive scalar in dB.
Dependencies
To enable this parameter, set Filter
specification to Filter order and
stopband attenuation
or Transition
width and stopband attenuation
.
Numerator — FIR halfband filter coefficients
2*firhalfband("minorder",0.407,1e4)
(default)  row vector
Specify the FIR halfband filter coefficients directly as a row vector.
The coefficients must comply with the FIR halfband impulse response
format. If (length
(Numerator
)
− 1)/2 is even, where
(length
(Numerator
) − 1) is
the filter order, every other coefficient starting with the first
coefficient must be 0 except the center coefficient which must be 1.0.
If (length
(Numerator
) − 1)/2
is odd, the sequence of alternating zeros with 1.0 at the center starts
at the second coefficient.
Dependencies
To enable this parameter, set Filter
specification to
Coefficients
.
Design method — Filter design method
Auto
(default)  Equiripple
 Kaiser
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 theAuto
mode is not suitable for your application, manually specify the Design method asEquiripple
orKaiser
.Equiripple
–– The algorithm uses the equiripple method.Kaiser
–– The algorithm uses the Kaiser window method.
Dependencies
To enable this parameter, set Filter
specification to Filter order and
stopband attenuation
, Filter order
and transition width
, or Transition
width and stopband attenuation
.
Input highpass subband — Input highpass subband
off (default)  on
When you select this check box, the block acts as a synthesis filter bank. The block accepts two inputs to synthesize: lowpass and highpass subbands. When you clear this check box, the block acts as an IIR half band interpolator and accepts a single vector or matrix as input. By default, this check box is cleared.
Inherit sample rate from input — Inherit sample rate from input signal
off (default)  on
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).
Input sample rate (Hz) — Sample rate of input signal
44100
(default)  positive real scalar
Specify the sample rate of the input signal as a scalar in Hz.
Dependencies
To enable this parameter, clear the Inherit sample rate from input parameter.
View Filter Response — View Filter Response
button
Click this button to open the Filter Visualization Tool (FVTool) and display the magnitude and phase response of the FIR Halfband Interpolator. The response is based on the values you specify in the block parameters dialog box. 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 — Simulate using
Code generation
(default)  Interpreted execution
Specify the type of simulation to run. You can set this parameter to:
Code generation
(default)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
Interpreted execution
.Interpreted execution
Simulate model using the MATLAB^{®} interpreter. This option shortens startup time but has slower simulation speed than
Code generation
.
Data Types Tab
Rounding mode — Rounding mode for output fixedpoint operations
Floor
(default)  Ceiling
 Convergent
 Nearest
 Round
 Simplest
 Zero
Specify the rounding method for the output fixedpoint operations. The
rounding methods are Ceiling
,
Convergent
,
Floor
,
Nearest
, Round
,
Simplest
, and
Zero
. The default is
Floor
.
Coefficients — Word and fraction lengths of coefficients
fixdt(1,16)
(default)  fixdt(1,16,0)
Specify the fixedpoint data type of the coefficients as one of the following:
fixdt(1,16)
(default) — Signed fixedpoint data type of word length16
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 fixedpoint data type of word length16
and fraction length,0
. You can change the fraction length to any other integer value.<data type expression>
— Specify the coefficients data type by using an expression that evaluates to a data type object. For example,numerictype
(fixdt
([ ]
,18
,15
)). Specify the sign mode of this data type as[ ]
or true.Refresh Data Type
— Refresh to the default data type.
Click the Show data type assistant button to display the data type assistant, which helps you set the coefficients data type.
Block Characteristics
Data Types 

Direct Feedthrough 

Multidimensional Signals 

VariableSize Signals 

ZeroCrossing Detection 

More About
Halfband Filters
An ideal lowpass halfband filter is given by
$$h(n)=\frac{1}{2\pi}{\displaystyle {\int}_{\pi /2}^{\pi /2}{e}^{j\omega n}}d\omega =\frac{\mathrm{sin}({\scriptscriptstyle \frac{\pi}{2}}n)}{\pi n}.$$
An ideal filter is not realizable because the impulse response is noncausal and not absolutely summable. However, the impulse response of an ideal lowpass filter possesses some important properties that are required in a realizable approximation. The impulse response of an ideal lowpass halfband filter is:
Equal to 0 for all evenindexed samples
Equal to 1/2 at n=0 as shown by L'Hôpital's rule on the continuousvalued equivalent of the discretetime impulse response
The ideal highpass halfband filter is given by
$$g(n)=\frac{1}{2\pi}{\displaystyle {\int}_{\pi}^{\pi /2}{e}^{j\omega n}}d\omega +\frac{1}{2\pi}{\displaystyle {\int}_{\pi /2}^{\pi}{e}^{j\omega n}}d\omega .$$
Evaluating the preceding integral gives the following impulse response
$$g(n)=\frac{\mathrm{sin}(\pi n)}{\pi n}\frac{\mathrm{sin}({\scriptscriptstyle \frac{\pi}{2}}n)}{\pi n}.$$
The impulse response of an ideal highpass halfband filter is:
Equal to 0 for all evenindexed samples
Equal to 1/2 at n=0
The FIR halfband interpolator uses a causal FIR approximation to the ideal halfband response, which is based on minimizing the $${\ell}^{\infty}$$ norm of the error (minimax). See Algorithms for more information.
Kaiser Window
The coefficients of a Kaiser window are computed from this equation:
$$w(n)=\frac{{I}_{0}\left(\beta \sqrt{1{\left(\frac{nN/2}{N/2}\right)}^{2}}\right)}{{I}_{0}(\beta )},\text{\hspace{1em}}\text{\hspace{1em}}0\le n\le N,$$
where I_{0} is the zerothorder modified Bessel function of the first kind.
To obtain a Kaiser window that represents an FIR filter with stopband attenuation of α dB, use this β.
$$\beta =\{\begin{array}{ll}0.1102(\alpha 8.7),\hfill & \alpha >50\hfill \\ 0.5842{(\alpha 21)}^{0.4}+0.07886(\alpha 21),\hfill & 50\ge \alpha \ge 21\hfill \\ 0,\hfill & \alpha <21\hfill \end{array}$$
The filter order n is given by:
$$n=\frac{\alpha 7.95}{2.285(\Delta \omega )}$$
where Δω is the transition width.
Algorithms
Filter Design Method
The FIR halfband interpolator 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 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 evenindexed 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 linearphase FIR filter approximation to the ideal halfband filter defined in Halfband Filters. See [1] 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 linearphase FIR filter approximation to the ideal halfband filter.
The coefficients of the designed halfband interpolation filter are scaled by the interpolation factor, two, to preserve the output power of the signal.
For more information on designing FIR halfband filters, see FIR Halfband Filter Design.
Polyphase Implementation with Halfband Filters
The FIR halfband interpolator uses an efficient polyphase implementation for halfband filters when you filter the input signal. You can use a polyphase implementation to move the upsampling operation after 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 ztransform of
$${H}_{0}(z)={\displaystyle \sum _{n}h}(2n){z}^{n},$$
and an odd polyphase component with ztransform of
$${H}_{1}(z)={\displaystyle \sum _{n}h}(2n+1){z}^{n}.$$
The ztransform of the filter can be written in terms of the even and odd polyphase components as
$$H(z)={H}_{0}({z}^{2})+{z}^{1}{H}_{1}({z}^{2}).$$
You can represent the upsampling by 2 and then filtering the signal using this figure.
Using the multirate noble identity for upsampling, you can move the upsampling operation after the filtering. This enables 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 z^{0}. 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 shown in the following figure.
The top plot shows a halfband filter of order 52. The bottom plot shows the even polyphase component. Both filters are noncausal. Delaying the even polyphase component by 13 samples creates a causal FIR filter.
To efficiently implement the halfband interpolator, the algorithm replaces the upsampling operator, delay block, and adder with a commutator switch. This is shown in the following figure, where one polyphase component is replaced by a delay.
The commutator switch takes input samples from the two branches alternately, one sample at a time. This doubles the sampling rate of the input signal. The polyphase component that 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.FIRHalfbandInterpolator(Specification=filterspec,... FilterOrder=64,StopbandAttenuation=80); halfOrderOdd = dsp.FIRHalfbandInterpolator(Specification=filterspec,... FilterOrder=54,StopbandAttenuation=80); polyphase(halfOrderEven) polyphase(halfOrderOdd)
One of the polyphase components has a single nonzero coefficient indicating that it is a simple delay. To preserve the output power of the signal, the coefficients are scaled by the interpolation factor, two. To see this scaling, compare the polyphase components of a halfband interpolator with the coefficients of a halfband decimator.
hfirinterp = dsp.FIRHalfbandInterpolator; hfirdecim = dsp.FIRHalfbandDecimator; polyphase(hfirdecim) polyphase(hfirinterp)
To summarize, the FIR halfband interpolator:
Filters the input before upsampling 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.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
The FIR Halfband Interpolator block supports SIMD code generation using
Intel AVX2 technology when the data type of the input signal is
single
or double
.
The SIMD technology significantly improves the performance of the generated code.
FixedPoint Conversion
Design and simulate fixedpoint systems using FixedPoint Designer™.
Version History
Introduced in R2015b
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
 América Latina (Español)
 Canada (English)
 United States (English)
Europe
 Belgium (English)
 Denmark (English)
 Deutschland (Deutsch)
 España (Español)
 Finland (English)
 France (Français)
 Ireland (English)
 Italia (Italiano)
 Luxembourg (English)
 Netherlands (English)
 Norway (English)
 Österreich (Deutsch)
 Portugal (English)
 Sweden (English)
 Switzerland
 United Kingdom (English)