Main Content

designMultirateFIR

Design and implement antialiasing and anti-imaging lowpass FIR filter

Description

B = designMultirateFIR designs a multirate FIR filter. The output B is a vector of filter coefficients. To implement the filter, you must assign the filter coefficients B to a multirate filter object.

The multirate FIR filter is an antialiasing and anti-imaging lowpass FIR filter used in digital rate conversion.

example

B = designMultirateFIR(Name=Value) specifies options using one or more name-value arguments. (since R2024a)

For example, B = designMultirateFIR(InterpolationFactor=3,DecimationFactor=2,SystemObject=true) designs an FIR rate converter with the interpolation factor of 3, decimation factor of 2, polyphase length of 24, and the stopband attenuation of 80 dB. As the SystemObject argument is true, the function returns a dsp.FIRRateConverter System object™.

When you specify only a partial list of filter parameters, the function designs the filter by setting the other design parameters to their default values.

Examples

collapse all

To design an FIR interpolator using the designMultirateFIR function, specify the interpolation factor (usually a value greater than 1) and set the decimation factor to 1. You can use the default polyphase length and stopband attenuation or you can use nondefault values.

Design an FIR interpolator with the interpolation factor of 5. Use the default polyphase length of 24 and the default stopband attenuation of 80 dB.

b = designMultirateFIR(InterpolationFactor=5,DecimationFactor=1);
impz(b)

Design an FIR decimator with the decimation factor of 3 and polyphase length of 28. Use the default stopband attenuation of 80 dB.

b = designMultirateFIR(InterpolationFactor=1,...
    DecimationFactor=3,...
    PolyphaseLength=28);
impz(b)

Design an FIR rate converter with the interpolation factor of 3, decimation factor of 4, polyphase length of 28, and stopband attenuation of 90 dB.

b = designMultirateFIR(InterpolationFactor=3,...
    DecimationFactor=4,...
    PolyphaseLength=28,...
    StopbandAttenuation=90);
impz(b,1)

Design an FIR rate converter with the interpolation factor of 3, decimation factor of 4, normalized transition width of 0.2, and stopband attenuation of 90 dB.

bTW = designMultirateFIR(InterpolationFactor=3,...
    DecimationFactor=4,...
    TransitionWidth=0.2,...
    StopbandAttenuation=90);
impz(bTW,1)

Design a polyphase FIR interpolator by using the designMultirateFIR function with the interpolation factor of 5, normalized transition width of 0.01, and stopband attenuation of 60 dB. Set the 'SystemObject' argument to true to create a dsp.FIRInterpolator object.

firInterp = designMultirateFIR(InterpolationFactor=5,...
    TransitionWidth=0.01,...
    StopbandAttenuation=60,...
    SystemObject=true);

Visualize the magnitude and phase response of the FIR interpolator using the freqzmr function.

freqzmr(firInterp)

Compute the cost of implementing the filter.

cost(firInterp)
ans = struct with fields:
                  NumCoefficients: 582
                        NumStates: 145
    MultiplicationsPerInputSample: 582
          AdditionsPerInputSample: 578

Measure the frequency response characteristics of the filter object.

measure(firInterp)
ans = 
Sample Rate      : N/A (normalized frequency)
Passband Edge    : 0.195                     
3-dB Point       : 0.19884                   
6-dB Point       : 0.2                       
Stopband Edge    : 0.205                     
Passband Ripple  : 0.016474 dB               
Stopband Atten.  : 60.1827 dB                
Transition Width : 0.01                      
 

Input Arguments

collapse all

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: designMultirateFIR(InterpolationFactor=3,PolyphaseLength=32,SystemObject=true) designs and returns a dsp.FIRInterpolator object with an interpolation factor of 3.

Interpolation factor L, specified as a positive integer. To design a pure decimator, set L to 1.

If you design the filter using PolyphaseLength, the interpolation factor is tunable in the generated code, that is, you can pass the interpolation factor as a runtime variable while generating code.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Decimation factor M, specified as a positive integer. To design a pure interpolator, set M to 1.

If you design the filter using PolyphaseLength, the decimation factor is tunable in the generated code, that is, you can pass the decimation factor as a runtime variable while generating code.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Polyphase length, specified as a positive even integer greater than or equal to 2. Specifying both transition width and polyphase length results in an overdetermined design. The function does not support specifying both the values.

The function applies the default polyphase length value of 24 or you can use that value only when you set the interpolation factor L or the decimation factor M to a value greater than 1.

The polyphase length is tunable in the generated code, that is, you can pass the polyphase length as a runtime variable while generating code.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Normalized transition width of the multirate FIR filter, specified as a real scalar in the range (0 1).

Specifying both transition width and polyphase length results in an overdetermined design. The function does not support specifying both the values. When you use the transition width to design the filter, the function determines the polyphase length (and therefore the filter length) iteratively.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Stopband attenuation in dB, specified as a nonnegative real scalar greater than or equal to 0.

The function applies the default stopband attenuation value of 80 dB only when you set the interpolation factor L or the decimation factor M to a value greater than 1.

If you design the filter using PolyphaseLength, the stopband attenuation is tunable in the generated code, that is, you can pass the stopband attenuation as a runtime variable while generating code.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Option to create a multirate filter System object, specified as one of these:

Data Types: logical

Option to print the entire function call in MATLAB, specified as one of these:

  • false –– The function does not print the function call.

  • true –– The function prints the entire function call including the default values of the Name=Value arguments that you did not specify when calling the function.

    Use this argument to view all the values used by the function to design and implement the filter.

Data Types: logical

Output Arguments

collapse all

Designed filter, returned as one of these options.

  • Multirate FIR filter coefficients –– The function returns a row vector of length N when you set the SystemObject argument to false.

    If both L and M are equal to 1, N = 1.

    If L > 1 or M > 1, N={2PR+12PRM>L>1andmod(PL,M)0otherwise, where 2P is the polyphase length and R is defined by one of these equations:

    • R = L if L > 1

    • R = M if L = 1.

    For more details, see the Algorithms section.

    If you specify single-precision values in any of the input arguments, the function outputs single-precision filter coefficients. (since R2024a)

  • Multirate FIR filter object –– The function returns one of these multirate filter System objects when you set the SystemObject argument to true.

Data Types: single | double

Algorithms

designMultirateFIR designs an Rth band Nyquist FIR filter using a Kaiser window vector to window the truncated impulse response of the FIR filter.

The filter length N is defined as

N={2PR+12PRM>L>1andmod(PL,M)0otherwise

where, 2P is the polyphase length and R is defined by one of these equations:

  • R = L if L > 1

  • R = M if L = 1.

The function algorithm delays the truncated impulse response d(n) by N/2 samples to make it causal. The truncated and delayed impulse response is

d(nN/2)=sin(wc(nN/2))π(nN/2),n=0,,N2,,N,

where wc=π/R.

For every Rth band, the impulse response of the Nyquist filters is exactly zero. Because of this property, when the algorithm uses Nyquist filters for pure interpolation, the input samples remain unaltered after interpolating.

When designing a Nyquist filter, the algorithm uses a Kaiser window because of its near-optimum performance and ability to provide a robust design. The window depends on two parameters: length N + 1 and shape parameter β.

The Kaiser window is defined by

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

where I0 is the zeroth-order modified Bessel function of the first kind.

The shape parameter β is calculated using

β={0.1102(Astop8.7)if Astop500.5842(Astop21)0.4+0.07886(Astop21)if 21<Astop<500if Astop21,

where Astop is the stopband attenuation in dB.

The windowed impulse response is

h(n)=w(n)d(nN/2)=w(n)sin(wc(nN/2))π(nN/2),n=0,,N2,,N

h(n) for n = 0,1,…,N/2,…,N are the coefficients of the multirate filter. These coefficients are defined by the interpolation factor L and decimation factor M.

References

[1] Orfanidis, Sophocles J. Introduction to Signal Processing. Upper Saddle River, NJ: Prentice-Hall, 1996.

Extended Capabilities

Version History

Introduced in R2016a

expand all