Main Content

toMultirate

Create multirate filter System object from digital FIR filter object

Since R2025a

Description

multiFiltObj = toMultirate(digiFiltObj,Name=Value) creates a multirate FIR filter System object™ from the input digitalFilter object based on the properties you specify using one or more name-value arguments. For example, multiFiltObj = toMultirate(digitFiltObj,InterpolationFactor=7,DecimationFactor=3) creates a dsp.FIRRateConverter object with an interpolation factor of 7 and a decimation factor of 3 using the filter coefficients from the digiFiltObj object.

example

Examples

collapse all

Design a lowpass digital FIR filter object with these design specifications using the designfilt function:

  • Filter order of 22

  • Passband frequency of 100 Hz

  • Stopband frequency of 275 Hz

  • Sample rate of 1000 Hz

  • Least-squares design method

designedFilter = designfilt('lowpassfir', ...
    'FilterOrder',22,'PassbandFrequency',100, ...
    'StopbandFrequency',275,'SampleRate',1e3, ...
    'DesignMethod','ls')
designedFilter = 
 digitalFilter with properties:

   Coefficients:
            Numerator: [-9.9314e-05 -0.0016 -0.0031 0.0015 0.0131 0.0136 -0.0166 -0.0547 -0.0286 0.1064 0.2853 0.3693 0.2853 0.1064 -0.0286 -0.0547 -0.0166 0.0136 0.0131 0.0015 -0.0031 -0.0016 -9.9314e-05]
          Denominator: 1

   Specifications:
    FrequencyResponse: 'lowpass'
      ImpulseResponse: 'fir'
           SampleRate: 1000
    StopbandFrequency: 275
    PassbandFrequency: 100
          FilterOrder: 22
         DesignMethod: 'ls'

 Use filterAnalyzer to visualize filter
 Use designfilt to edit filter
 Use filter to filter data

Convert the designed digitalFilter object into a dsp.FIRRateConverter object using the toMultirate function. Specify the interpolation factor as 7, decimation factor as 3, and scale the passband gain by the interpolation factor.

firrcScaledGain = toMultirate(designedFilter,...
    InterpolationFactor=7,DecimationFactor=3,...
    ScaleByInterpolationFactor=true)
firrcScaledGain = 
  dsp.FIRRateConverter with properties:

   Main
    InterpolationFactor: 7
       DecimationFactor: 3
        NumeratorSource: 'Property'
              Numerator: [-6.9520e-04 -0.0111 -0.0219 0.0105 0.0914 0.0953 -0.1165 -0.3830 -0.2000 0.7448 1.9973 2.5854 1.9973 0.7448 -0.2000 -0.3830 -0.1165 0.0953 0.0914 0.0105 -0.0219 -0.0111 -6.9520e-04]

  Show all properties

Create another instance of the dsp.FIRRateConverter object with the same design specifications, but do not scale the passband gain of the filter.

firrcunityGain = toMultirate(designedFilter,...
    InterpolationFactor=7,DecimationFactor=3,...
    ScaleByInterpolationFactor=false)
firrcunityGain = 
  dsp.FIRRateConverter with properties:

   Main
    InterpolationFactor: 7
       DecimationFactor: 3
        NumeratorSource: 'Property'
              Numerator: [-9.9314e-05 -0.0016 -0.0031 0.0015 0.0131 0.0136 -0.0166 -0.0547 -0.0286 0.1064 0.2853 0.3693 0.2853 0.1064 -0.0286 -0.0547 -0.0166 0.0136 0.0131 0.0015 -0.0031 -0.0016 -9.9314e-05]

  Show all properties

Visualize the frequency response of these filters using filterAnalyzer. Note the difference in the passband gain for both these filters.

filterAnalyzer(firrcScaledGain,firrcunityGain)

Input Arguments

collapse all

Digital FIR filter, specified as a digitalFilter object. Use the designfilt function in the form digiFiltObj = designfilt(firResp,Name=Value) to create the digital filter object with the FIR response type. Customize the filter using the name-value arguments.

Name-Value Arguments

collapse all

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: multiFiltObj = toMultirate(digiFiltObj,InterpolationFactor=3,DecimationFactor=2,ScaleByInterpolationFactor=true)

Interpolation factor of the multirate filter object, specified as a positive integer. The values of the InterpolationFactor and DecimationFactor arguments must not have any common factors, that is, gcd(InterpolationFactor,DecimationFactor) must equal 1.

Data Types: single | double

Decimation factor of the multirate filter object, specified as a positive integer. The values of the InterpolationFactor and DecimationFactor arguments must not have any common factors, that is, gcd(InterpolationFactor,DecimationFactor) must equal 1.

Data Types: single | double

Option to scale the passband gain by the interpolation factor, specified as one of these:

  • true –– The multirate filter object scales its passband gain by the interpolation factor that you specify in the InterpolationFactor argument.

  • false –– The multirate filter object maintains its passband gain at unity.

Data Types: logical

Output Arguments

collapse all

Multirate filter object, returned as one of these filter System objects:

Version History

Introduced in R2025a