Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

dsp.LowpassFilter System object

FIR or IIR lowpass filter

Description

dsp.LowpassFilter independently filters each channel of the input over time using the given design specifications. You can set the FilterType property of dsp.LowpassFilter to 'FIR' or 'IIR' to implement the object as a FIR or IIR lowpass filter. This object supports fixed-point operations, HDL code generation, and ARM Cortex code generation.

To filter each channel of your input:

  1. Define and set up your lowpass filter. See Construction.

  2. Call step to filter each channel of the input signal according to the properties of dsp.LowpassFilter. The input signal can be a real- or complex-valued column vector or matrix, with floating point or fixed-point precision. If the input signal is a matrix, each column of the matrix is treated as an independent channel. The number of rows in the input signal denote the channel length.

Note

Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.

Construction

LPF = dsp.LowpassFilter returns a minimum order FIR lowpass filter, LPF, with the default filter settings. Calling step with the default property settings filters the input data with a passband frequency of 8 kHz, a stopband frequency of 12 kHz, a passband ripple of 0.1 dB, and a stopband attenuation of 80 dB.

LPF = dsp.LowpassFilter(Name,Value) returns a lowpass filter, with additional properties specified by one, or more Name,Value pair arguments. Name is the property name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name-value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Properties

expand all

Input sample rate in Hz, specified as the comma-separated pair consisting of 'SampleRate' and a real positive scalar.

Filter type, specified as one of the following options:

  • 'FIR' — The object designs an FIR lowpass filter.

  • 'IIR' — The object designs an IIR lowpass (biquad) filter.

Minimum order filter design, specified as the comma-separated pair consisting of 'DesignForMinimumOrder' and a logical value. If this property is true, then dsp.LowpassFilter designs filters with the minimum order that meets the passband frequency, stopband frequency, passband ripple, and stopband attenuation specifications. Set these specifications using the corresponding properties. If this property is false, then the object designs filters with the order that you specify in the FilterOrder property. This filter design meets the passband frequency, passband ripple, and stopband attenuation specifications that you set using the respective properties.

Order of the FIR or IIR filter, specified as the comma-separated pair consisting of 'FilterOrder' and a positive integer scalar. Specifying a filter order is only valid when the value of 'DesignForMinimumOrder' is false.

Filter passband edge frequency in Hz, specified as the comma-separated pair of 'PassbandFrequency' and a real positive scalar. The value of the passband edge frequency in Hz must be less than half the SampleRate.

Filter stopband edge frequency in Hz, specified as the comma-separated pair consisting of 'StopbandFrequency' and a real positive scalar. The value of the stopband edge frequency in Hz must be less than half the SampleRate. You can specify the stopband edge frequency only when 'DesignForMinimumOrder' is true.

Maximum ripple of filter response in the passband, in dB, specified as the comma-separated pair consisting of 'PassbandRipple' and a real positive scalar. Maximum ripple of filter response defaults to 0.1 dB.

Minimum attenuation in the stopband in dB, specified as the comma-separated pair consisting of 'StopbandAttenuation' and a real positive scalar. Minimum attenuation in the stopband defaults to 80 dB.

Fixed-Point Properties

Rounding method for output fixed-point operations, specified as a character vector. For more information on the rounding modes, see Precision and Range.

Word and fraction lengths of coefficients, specified as a numerictype object. The default, numerictype(1,16) corresponds to a signed numeric type object with 16-bit coefficients and a fraction length determined based on the coefficient values, to give the best possible precision.

This property is not tunable.

Word length of the output is same as the word length of the input. Fraction length of the output is computed such that the entire dynamic range of the output can be represented without overflow. For details on how the fraction length of the output is computed, see Fixed-Point Precision Rules for Avoiding Overflow in FIR Filters.

Methods

measureMeasure frequency response characteristics of dsp.LowpassFilter System object.
resetReset internal states of lowpass filter
stepFilter input using FIR or IIR lowpass filter

For additional methods, see Analysis Methods for Filter System Objects.

For a complete list of analysis methods supported for the dsp.LowpassFilter object, enter dsp.LowpassFilter.helpFilterAnalysis at the MATLAB® command prompt.

Common to All System Objects
clone

Create System object with same property values

getNumInputs

Expected number of inputs to a System object

getNumOutputs

Expected number of outputs of a System object

isLocked

Check locked states of a System object (logical)

release

Allow System object property value changes

Examples

expand all

Create a minimum-order FIR lowpass filter for data sampled at 44.1 kHz. Specify a passband frequency of 8 kHz, a stopband frequency of 12 kHz, a passband ripple of 0.1 dB, and a stopband attenuation of 80 dB.

Fs = 44.1e3;
filtertype = 'FIR';
Fpass = 8e3;
Fstop = 12e3;
Rp = 0.1;
Astop = 80;
FIRLPF = dsp.LowpassFilter('SampleRate',Fs, ...
                             'FilterType',filtertype, ...
                             'PassbandFrequency',Fpass, ...
                             'StopbandFrequency',Fstop, ...
                             'PassbandRipple',Rp, ...
                             'StopbandAttenuation',Astop);

Design a minimum-order IIR lowpass filter with the same properties as the FIR lowpass filter. Change the FilterType property of the cloned filter to IIR.

IIRLPF = clone(FIRLPF);
IIRLPF.FilterType = 'IIR';

Plot the impulse response of the FIR lowpass filter. The zeroth-order coefficient is delayed by 19 samples, which is equal to the group delay of the filter. The FIR lowpass filter is a causal FIR filter.

fvtool(FIRLPF,'Analysis','impulse')

Plot the impulse response of the IIR lowpass filter.

fvtool(IIRLPF,'Analysis','impulse')

Plot the magnitude and phase response of the FIR lowpass filter.

fvtool(FIRLPF,'Analysis','freq')

Plot the magnitude and phase response of the IIR lowpass filter.

fvtool(IIRLPF,'Analysis','freq')

Calculate the cost of implementing the FIR lowpass filter.

cost(FIRLPF)
ans = 

  struct with fields:

                  NumCoefficients: 39
                        NumStates: 38
    MultiplicationsPerInputSample: 39
          AdditionsPerInputSample: 38

Calculate the cost of implementing the IIR lowpass filter. The IIR filter is more efficient to implement than the FIR filter.

cost(IIRLPF)
ans = 

  struct with fields:

                  NumCoefficients: 18
                        NumStates: 14
    MultiplicationsPerInputSample: 18
          AdditionsPerInputSample: 14

Calculate the group delay of the FIR lowpass filter.

grpdelay(FIRLPF)

Calculate the group delay of the IIR lowpass filter. The FIR filter has a constant group delay (linear phase), while its IIR counterpart does not.

grpdelay(IIRLPF)

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

Set up the IIR lowpass filter. The sampling rate of the white Gaussian noise is 44,100 Hz. The passband frequency of the filter is 8 kHz, the stopband frequency is 12 kHz, the passband ripple is 0.1 dB, and the stopband attenuation is 80 dB.

Fs = 44.1e3;
filtertype = 'IIR';
Fpass = 8e3;
Fstop = 12e3;
Rp = 0.1;
Astop = 80;
LPF = dsp.LowpassFilter('SampleRate',Fs,...
                             'FilterType',filtertype,...
                             'PassbandFrequency',Fpass,...
                             'StopbandFrequency',Fstop,...
                             'PassbandRipple',Rp,...
                             'StopbandAttenuation',Astop);

View the magnitude response of the lowpass filter.

fvtool(LPF)

Create a spectrum analyzer object.

hSA = dsp.SpectrumAnalyzer('SampleRate',44.1e3,...
    'PlotAsTwoSidedSpectrum',false,'ShowLegend',true,'YLimits',...
           [-150 30],...
           'Title',...
           'Input Signal and Output Signal of IIR Lowpass Filter');
hSA.ChannelNames = {'Input','Output'};

Filter the white Gaussian noisy input signal. View the input and output signals using the spectrum analyzer.

for k = 1:100
    Input = randn(1024,1);

    Output = LPF(Input);

    hSA([Input,Output]);
end

Supported Data Types

ArgumentSupported Data Types

Input

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

Output

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

Algorithms

expand all

References

[1] Shpak, D.J., and A. Antoniou. "A generalized Remez method for the design of FIR digital filters." IEEE® Transactions on Circuits and Systems. Vol. 37, Issue 2, Feb. 1990, pp. 161–174.

[2] Selesnick, I.W., and C. S. Burrus. "Exchange algorithms that complement the Parks-McClellan algorithm for linear-phase FIR filter design." IEEE Transactions on Circuits and Systems. Vol. 44, Issue 2, Feb. 1997, pp. 137–143.

Extended Capabilities

Introduced in R2015a

Was this topic helpful?