Main Content

firhalfband

(To be removed) Halfband FIR filter design

The firhalfband function will be removed in a future release. Use the designHalfbandFIR function instead. For more information on how to update your existing code, see Compatibility Considerations.

Description

b = firhalfband(n,fp) designs a lowpass FIR halfband filter of order n with an equiripple characteristic. n must be an even integer. fp determines the passband edge frequency such that 0 < fp < 1/2, where 1/2 corresponds to π/2 rad/sample.

b = firhalfband(n,win) designs a lowpass nth-order filter using the truncated windowed-impulse response method instead of the equiripple method. win should be an n+1 length vector. The function truncates the ideal response to length n+1, then multiplies it point-by-point with the window specified in win.

b = firhalfband(n,dev,'dev') designs an nth-order lowpass halfband filter with an equiripple characteristic. dev sets the value for the maximum passband and stopband ripple.

example

b = firhalfband('minorder',fp,dev) designs a lowpass minimum-order filter with passband edge fp. The peak ripple is constrained by the scalar dev. This design uses the equiripple method.

b = firhalfband('minorder',fp,dev,'kaiser') designs a lowpass minimum-order filter with passband edge fp. The peak ripple is constrained by the scalar dev. This design uses the Kaiser window method.

b = firhalfband(___,'high') returns a highpass halfband FIR filter.

b = firhalfband(___,'minphase') designs a minimum-phase FIR filter such that the filter is a spectral factor of a halfband filter. Recall that h = conv(b,fliplr(b)) is a halfband filter. This can be useful for designing perfect reconstruction two-channel FIR filter banks. The 'minphase' option is not available for window-based halfband filter designs such as b = firhalfband(n,win) and b = firhalfband('minorder',fp,dev,'kaiser').

In the minimum phase case, the filter order n must be odd.

Examples

collapse all

Design a minimum order halfband filter with maximum ripple set to 0.0001.

b = firhalfband('minorder',.45,0.0001);
impz(b)

Input Arguments

collapse all

FIR halfband filter order, specified as an integer

If you specify the firhalfband function to design a minimum phase filter using the 'minphase' argument, the filter order must be odd. In all other cases, the filter order must be even.

Data Types: single | double

Passband edge frequency, specified as a scalar in the range (0,½), where ½ corresponds to π/2 rad/sample.

Data Types: single | double

Window to apply to the filter, specified as an n+1 length vector. The function truncates the ideal response to length n+1, then multiplies it point-by-point with the window specified in win.

Data Types: single | double
Complex Number Support: Yes

Maximum passband and stopband ripple in the halfband filter, specified as a scalar.

Data Types: single | double

Output Arguments

collapse all

FIR halfband filter coefficients, returned as a vector.

Data Types: single | double
Complex Number Support: Yes

More About

collapse all

Halfband Filters

The ideal lowpass halfband filter is given by

h(n)=12ππ/2π/2ejωndω=sin(π2n)πn.

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

g(n)=12πππ/2ejωndω+12ππ/2πejωndω.

Evaluating the preceding integral gives the following impulse response

g(n)=sin(πn)πnsin(π2n)πn.

The ideal highpass halfband filter’s impulse is:

  • Equal to 0 for all even-indexed samples

  • Equal to 1/2 at n=0

The firhalfband function uses a causal FIR approximation to the ideal halfband response, which is based on minimizing the norm of the error (minimax).

Kaiser Window

The coefficients of a Kaiser window are computed using this equation:

w(n)=I0(β1(nN/2N/2)2)I0(β),0nN,

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 β.

β={0.1102(α8.7),α>500.5842(α21)0.4+0.07886(α21),50α210,α<21

The filter order n is given by:

n=α7.952.285(Δω),

where Δω is the transition width.

For more details, see Algorithms.

Algorithms

The firhalfband function uses the equiripple or the Kaiser window method to design the FIR halfband filter. You can also specify a custom window using the win argument.

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 [2] for a description of this filter design method using the Remez exchange algorithm. As 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.

Window-based Design

In the window-based design method, the algorithm first truncates the ideal halfband filter defined in Halfband Filters, then it applies the user-specified window. This yields a causal linear-phase FIR filter approximation to the ideal halfband filter. If you provide the 'kaiser' argument, the function calculates the window as mentioned in Kaiser Window.

For more information on designing FIR halfband filters, see FIR Halfband Filter Design.

References

[1] Saramaki, T, “Finite Impulse Response Filter Design,” Handbook for Digital Signal Processing. S.K. Mitra and J.F. Kaiser Eds. Wiley-Interscience, N.Y., 1993, Chapter 4.

[2] Harris, F.J. Multirate Signal Processing for Communication Systems, Prentice Hall, 2004, pp. 208–209.

Extended Capabilities

Version History

Introduced in R2011a

expand all

R2024a: firhalfband will be removed

The firhalfband function will be removed in a future release. Existing instances of the function continue to run. For new code, use the designHalfbandFIR function instead.

Update Code

Here are a few key differences between the two functions.

  • You specify the passband characteristics in terms of the passband edge frequency (fp) in the firhalfband function and the transition width, which is 2(0.5−fp), in the designHalfbandFIR function.

  • You specify the stopband attenuation in linear scale in the firhalfband function and in dB in the designHalfbandFIR function.

This table shows how the function is typically used and explains how to update the existing code to use the designHalfbandFIR function.

Discouraged UsageRecommended Replacement

Filter order is N and passband edge frequency is fp.

Design method is equiripple.

b = firhalfband(N,fp);
b = designHalfbandFIR(FilterOrder=N,...
TransitionWidth=2*(0.5-fp),...
DesignMethod="equiripple");

Minimum order filter with a stopband deviation of dev and a passband edge frequency of fp.

Design method is equiripple.

b = firhalfband('minorder',fp,dev);
b = designHalfbandFIR(StopbandAttenuation=-db(dev),...
TransitionWidth=2*(0.5-fp),...
DesignMethod="equiripple");

Minimum order filter with a stopband deviation of dev and a passband edge frequency of fp.

Design method is Kaiser.

b = firhalfband('minorder',fp,dev,'kaiser');
b = designHalfbandFIR(StopbandAttenuation=-db(dev),...
TransitionWidth=2*(0.5-fp),...
DesignMethod="kaiser");

Highpass design.

b = firhalfband(...,
'high');
b = designHalfbandFIR(...,
Passband="highpass");

Generic window design.

b = firhalfband(N,window);

No generic equivalent. However, DesignMethod="kaiser" produces a Kaiser design.

Minimum phase design.

b = firhalfband(...,
"minphase");

No generic equivalent.

See Also

Functions