Main Content

designMultistageInterpolator

Multistage interpolator design

Description

C = designMultistageInterpolator(L) designs a multistage interpolator that has an overall interpolation factor of L. In order for C to be multistage, L must not be a prime number. For details, see Algorithms. The design process can take a while if L has many factors.

C = designMultistageInterpolator(L,Fs,TW) designs a multistage interpolator with a sampling rate of Fs and a transition width of TW. Sampling rate in this case refers to the output sampling rate of the signal after the multistage interpolator.

The multistage interpolator has a cutoff frequency of Fs/2.

example

C = designMultistageInterpolator(L,Fs,TW,Astop) specifies a minimum attenuation of Astop dB for the resulting design.

example

C = designMultistageInterpolator(___,Name=Value) specifies additional design parameters using one or more name-value pair arguments.

Example: C = designMultistageInterpolator(48,48000,200,80,NumStages='auto') designs a multistage interpolator with the least number of multiplications per input sample (MPIS).

example

Examples

collapse all

Design a single-stage interpolator using the designMultirateFIR function and a multistage interpolator using the designMultistageInterpolator function. Determine the efficiency of the two designs using the cost function. The implementation efficiency is characterized by two cost metrics: NumCoefficients and MultiplicationsPerInputSample.

Compute the cost of implementing both designs, and determine which design is more efficient. To make a comparison, design the filters such that their transition width is the same.

Initialization

Choose an interpolation factor of 48, input sample rate of 640 kHz, one-sided bandwidth of 100 kHz, and a stopband attenuation of 90 dB.

L = 48;
Fin = 640e3;
Astop = 90;
BW = 1e5;

Compute the transition width using the following relationship:

Fc = Fin/2;
TW = 2*(Fc-BW);

Using the designMultirateFIR Function

Designing the interpolation filter using the designMultirateFIR function yields a single-stage design.

d = designMultirateFIR(InterpolationFactor=L,TransitionWidth=TW/(Fin*L/2),...
    StopbandAttenuation=Astop,SystemObject=true)
d = 
  dsp.FIRInterpolator with properties:

    InterpolationFactor: 48
        NumeratorSource: 'Property'
              Numerator: [3.6296e-05 3.9057e-05 4.0435e-05 4.0103e-05 3.7714e-05 3.2899e-05 2.5275e-05 1.4445e-05 0 -1.8471e-05 -4.1383e-05 -6.9142e-05 -1.0215e-04 -1.4078e-04 -1.8540e-04 -2.3633e-04 -2.9386e-04 -3.5824e-04 ... ] (1x401 double)

  Use get to show all properties

Compute the cost of implementing the interpolator. The interpolation filter requires 376 coefficients and 7 states. The number of multiplications per input sample and additions per input sample are 376 and 329, respectively.

cost(d)
ans = struct with fields:
                  NumCoefficients: 392
                        NumStates: 8
    MultiplicationsPerInputSample: 392
          AdditionsPerInputSample: 345

Using the designMultistageInterpolator Function

Design a multistage interpolator with the same filter specifications as the single-stage design.

By default, the number of stages given by the NumStages argument is set to 'auto', yielding an optimal design that tries to minimize the number of multiplications per input sample.

c = designMultistageInterpolator(L,Fin,TW,Astop)
c = 
  dsp.FilterCascade with properties:

         Stage1: [1x1 dsp.FIRInterpolator]
         Stage2: [1x1 dsp.FIRInterpolator]
    CloneStages: false

Calling the info function on c shows that the filter is implemented as a cascade of two dsp.FIRInterpolator objects with interpolation factors of 24 and 2, respectively.

Compute the cost of implementing the interpolator.

cost(c)
ans = struct with fields:
                  NumCoefficients: 184
                        NumStates: 12
    MultiplicationsPerInputSample: 322
          AdditionsPerInputSample: 275

The NumCoefficients and the MultiplicationsPerInputSample parameters are lower for the two-stage filter designed by the designMultistageInterpolator function, making it more efficient.

Compare the magnitude response of both designs.

filterAnalyzer(d,c,FilterNames=["Singlestage","Multistage"]);

The magnitude response shows that the transition width of both the filters is the same, making the filters comparable. The cost function shows that implementing the multistage design is more efficient compared to implementing the single-stage design.

Using the 'design' Option in the designMultistageInterpolator Function

The filter can be made even more efficient by setting the 'CostMethod' argument of the designMultistageInterpolator function to 'design'. By default, this argument is set to 'estimate'.

In the 'design' mode, the function designs each stage and computes the filter order. This yields an optimal design compared to the 'estimate' mode, where the function estimates the filter order for each stage and designs the filter based on the estimate.

Note that the 'design' option can take much longer compared to the 'estimate' option.

cOptimal = designMultistageInterpolator(L,Fin,TW,Astop,CostMethod='design')
cOptimal = 
  dsp.FilterCascade with properties:

         Stage1: [1x1 dsp.FIRInterpolator]
         Stage2: [1x1 dsp.FIRInterpolator]
         Stage3: [1x1 dsp.FIRInterpolator]
    CloneStages: false

cost(cOptimal)
ans = struct with fields:
                  NumCoefficients: 74
                        NumStates: 17
    MultiplicationsPerInputSample: 296
          AdditionsPerInputSample: 249

Design an interpolator with an overall interpolation factor of 24 using the designMultistageInterpolator function. Design the filter in two configurations:

  • Two-stage configuration - NumStages is set to 2.

  • Auto configuration - NumStages is set to 'auto'. This configuration designs a filter with the lowest number of multiplications per input sample.

Compare the cost of implementing both the configurations.

Initialization

Choose an interpolation factor of 24, input sample rate of 250 Hz, stopband attenuation of 90 dB, and a transition width of 0.03×(Fs×L)/2.

L = 24;
Fs = 250;
Astop = 90;
TW = 0.03*Fs*L/2;

Design the Filter

Design the two filters using the designMultistageInterpolator function.

cAuto = designMultistageInterpolator(L,Fs,TW,Astop,NumStages="auto")
cAuto = 
  dsp.FilterCascade with properties:

         Stage1: [1x1 dsp.FIRInterpolator]
         Stage2: [1x1 dsp.FIRInterpolator]
         Stage3: [1x1 dsp.FIRInterpolator]
    CloneStages: false

cTwo = designMultistageInterpolator(L,Fs,TW,Astop,NumStages=2)
cTwo = 
  dsp.FilterCascade with properties:

         Stage1: [1x1 dsp.FIRInterpolator]
         Stage2: [1x1 dsp.FIRInterpolator]
    CloneStages: false

View the filter information using the info function. The 'auto' configuration designs a cascade of three FIR interpolators with interpolation factors 4, 3, and 2, respectively. The two-stage configuration designs a cascade of two FIR interpolators with interpolation factors 6 and 4, respectively.

Compare the Cost

Compare the cost of implementing the two designs using the cost function.

cost(cAuto)
ans = struct with fields:
                  NumCoefficients: 70
                        NumStates: 28
    MultiplicationsPerInputSample: 190
          AdditionsPerInputSample: 167

cost(cTwo)
ans = struct with fields:
                  NumCoefficients: 98
                        NumStates: 22
    MultiplicationsPerInputSample: 208
          AdditionsPerInputSample: 185

The 'auto' configuration interpolation filter yields a three-stage design that out-performs the two-stage design in terms of NumCoefficients and MultiplicationsPerInputSample metrics.

The filters in the multistage design satisfy the following conditions:

  • The combined response must meet or exceed the given design specifications.

  • The combined interpolation must equal the overall interpolation required.

For an overall interpolation factor of 50, there are several combinations of individual stages.

To obtain a design with the least number of total coefficients, set the MinTotalCoeffs argument to true.

Astop = 80;
L = 50;
FsIn = 120;
TW = 0.03*FsIn*L/2;
cMinCoeffs = designMultistageInterpolator(L,FsIn,TW,Astop,MinTotalCoeffs=true)
cMinCoeffs = 
  dsp.FilterCascade with properties:

         Stage1: [1x1 dsp.FIRInterpolator]
         Stage2: [1x1 dsp.FIRInterpolator]
         Stage3: [1x1 dsp.FIRInterpolator]
    CloneStages: false

cost(cMinCoeffs)
ans = struct with fields:
                  NumCoefficients: 58
                        NumStates: 18
    MultiplicationsPerInputSample: 306
          AdditionsPerInputSample: 257

To obtain the design with the lowest number of multiplications per input sample, set NumStages to 'auto'.

cMinMulti = designMultistageInterpolator(L,FsIn,TW,Astop,NumStages='auto')
cMinMulti = 
  dsp.FilterCascade with properties:

         Stage1: [1x1 dsp.FIRInterpolator]
         Stage2: [1x1 dsp.FIRInterpolator]
    CloneStages: false

cost(cMinMulti)
ans = struct with fields:
                  NumCoefficients: 156
                        NumStates: 9
    MultiplicationsPerInputSample: 252
          AdditionsPerInputSample: 203

Compare the magnitude response of both the filters. Both filters have the same transition-band behavior and a stopband attenuation that is below 80 dB.

hvft = filterAnalyzer(cMinCoeffs,cMinMulti);
setLegendStrings(hvft,["Minimize total coefficients","Minimize number of multiplications per input sample"])

Input Arguments

collapse all

Overall interpolation factor, specified as a positive integer greater than one. In order for C to be multistage, L must not be a prime number. For details, see Algorithms.

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

Sampling rate of the output signal after the multistage interpolator, specified as a positive real scalar. If not specified, Fs defaults to 48,000 Hz. The multistage interpolator has a cutoff frequency of Fs/2.

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

Transition width, specified as a positive real scalar less than Fs. If not specified, TW defaults to 0.2×Fs. Transition width must be less than Fs.

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

Minimum stopband attenuation for the resulting design, specified as a positive real scalar.

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

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.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: C = designMultistageInterpolator(48,48000,200,80,'NumStages','auto') designs a multistage interpolator with the lowest number of multiplications per input sample.

Number of interpolator stages, specified as a positive integer. If set to 'auto', the design algorithm determines the number of stages that result in the lowest number of multiplications per input sample. If specified as a positive integer, N, the overall interpolation factor, L, must be able to factor into at least N factors, not counting 1 or L as factors.

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

When false, the design algorithm minimizes the number of multiplications per input sample. When true, the design algorithm minimizes the total number of coefficients.

Data Types: logical

Cost computation method, specified as either:

  • 'estimate' –– The function estimates the filter order required for each stage and designs the filter based on the estimate. This method is faster than 'design', but can lead to suboptimal designs.

  • 'design' –– The function designs each stage and computes the filter order.

Data Types: char

Tolerance, specified as a positive scalar. The tolerance is used to determine the multistage configuration with the least number of MPIS. When multiple configurations result in the same lowest MPIS within the tolerance specified, the configuration that yields the lowest number of coefficients overall is chosen. To view the total number of coefficients and MPIS for a specific filter, use the cost function.

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

Output Arguments

collapse all

Designed filter, returned as a dsp.FilterCascade System object™. The filter is a cascade of the multiple stages designed by the function. The number of stages is determined by the NumStages argument.

To get information about each filter stage, call the info function on the C argument.

Algorithms

The overall interpolation factor is split into smaller factors with each factor being the interpolation factor of the corresponding individual stage. The combined interpolation of all the individual stages must equal the overall interpolation. The combined response must meet or exceed the given design specifications.

The function determines the number of interpolator stages through the NumStages argument. The sequence of stages is determined based on the implementation cost. By default, NumStages is set to 'auto', resulting in a sequence that gives the lowest number of MPIS. When multiple configurations result in the same lowest MPIS within the tolerance specified, the configuration that yields the lowest number of coefficients overall is chosen. If MinTotalCoeffs is set to true, the function determines the sequence that requires the lowest number of total coefficients.

By default, the CostMethod is set to 'estimate'. In this mode, the function estimates the filter order required for each stage and designs the filter based on the estimate. This method is faster but can lead to suboptimal designs. For an optimal design, set CostMethod to 'design'. In this mode, the function designs each stage and computes the filter order.

Version History

Introduced in R2018b

expand all