Main Content

fdesign.lowpass

Lowpass filter specification

Note

Multistage filter design using the fdesign.lowpass and design functions now requires you to set the SystemObject flag to true unless the resulting design is a single-stage filter and not a cascade. This setting generates a dsp.FilterCascade object instead of the mfilt.cascade object.

For more information, see Version History.

Syntax

D = fdesign.lowpass
D = fdesign.lowpass(SPEC)
D = fdesign.lowpass(SPEC,specvalue1,specvalue2,...)
D = fdesign.lowpass(specvalue1,specvalue2,specvalue3,specvalue4)
D = fdesign.lowpass(...,Fs)
D = fdesign.lowpass(...,MAGUNITS)

Description

D = fdesign.lowpass constructs a lowpass filter specification object D, applying default values for the default specification option 'Fp,Fst,Ap,Ast'.

D = fdesign.lowpass(SPEC) constructs object D and sets the Specification property to the entry in SPEC. Entries in SPEC represent various filter response features, such as the filter order, that govern the filter design. Valid entries for SPEC are shown below. The options are not case sensitive.

Note

Specifications options marked with an asterisk require the DSP System Toolbox™ software.

  • 'Fp,Fst,Ap,Ast' (default option)

  • 'N,F3db'

  • 'N,F3db,Ap' *

  • 'N,F3db,Ap,Ast' *

  • 'N,F3db,Ast' *

  • 'N,F3db,Fst' *

  • 'N,Fc'

  • 'N,Fc,Ap,Ast'

  • 'N,Fp,Ap'

  • 'N,Fp,Ap,Ast'

  • 'N,Fp,Fst,Ap' *

  • 'N,Fp,F3db' *

  • 'N,Fp,Fst'

  • 'N,Fp,Fst,Ast' *

  • 'N,Fst,Ap,Ast' *

  • 'N,Fst,Ast'

  • 'Nb,Na,Fp,Fst' *

The filter specifications are defined as follows:

  • Ap — amount of ripple allowed in the pass band in decibels (the default units). Also called Apass.

  • Ast — attenuation in the stop band in decibels (the default units). Also called Astop.

  • F3db — cutoff frequency for the point 3 dB point below the passband value. Specified in normalized frequency units.

  • Fc — cutoff frequency for the point 6 dB point below the passband value. Specified in normalized frequency units.

  • Fp — frequency at the end of the pass band. Specified in normalized frequency units. Also called Fpass.

  • Fst — frequency at the start of the stop band. Specified in normalized frequency units. Also called Fstop.

  • N — filter order.

  • Na and Nb are the order of the denominator and numerator.

Graphically, the filter specifications look similar to those shown in the following figure.

Regions between specification values like Fp and Fst are transition regions where the filter response is not explicitly defined.

D = fdesign.lowpass(SPEC,specvalue1,specvalue2,...) constructs an object D and sets the specification values at construction time using specvalue1, specvalue2, and so on for all of the specification variables in SPEC.

D = fdesign.lowpass(specvalue1,specvalue2,specvalue3,specvalue4) constructs an object D with values for the default Specification property 'Fp,Fst,Ap,Ast' using the specifications you provide as input arguments specvalue1,specvalue2,specvalue3,specvalue4.

D = fdesign.lowpass(...,Fs) adds the argument Fs, specified in Hz to define the sampling frequency to use. In this case, all frequencies in the specifications are in Hz as well.

D = fdesign.lowpass(...,MAGUNITS) specifies the units for any magnitude specification you provide in the input arguments. MAGUNITS can be one of

  • 'linear' — specify the magnitude in linear units

  • 'dB' — specify the magnitude in dB (decibels)

  • 'squared' — specify the magnitude in power units

When you omit the MAGNUNITS argument, fdesign assumes that all magnitudes are in decibels. Note that fdesign stores all magnitude specifications in decibels (converting to decibels when necessary) regardless of how you specify the magnitudes.

Examples

collapse all

Design a Butterworth filter with lowpass and highpass frequency responses. The filter design procedure is:

  1. Specify the filter design specifications using a fdesign function.

  2. Pick a design method provided by the designmethods function.

  3. To determine the available design options to choose from, use the designoptions function.

  4. Design the filter using the design function.

Lowpass Filter

Construct a default lowpass filter design specification object using fdesign.lowpass.

designSpecs = fdesign.lowpass
designSpecs = 
  lowpass with properties:

               Response: 'Lowpass'
          Specification: 'Fp,Fst,Ap,Ast'
            Description: {4x1 cell}
    NormalizedFrequency: 1
                  Fpass: 0.4500
                  Fstop: 0.5500
                  Apass: 1
                  Astop: 60

Determine the available design methods using the designmethods function. To design a Butterworth filter, pick butter.

designmethods(designSpecs,SystemObject=true)
Design Methods that support System objects for class fdesign.lowpass (Fp,Fst,Ap,Ast):


butter
cheby1
cheby2
ellip
equiripple
ifir
kaiserwin
multistage

While designing the filter, you can specify additional design options. View a list of the options using the designoptions function. This function also shows the default design options the filter uses.

designoptions(designSpecs,'butter',SystemObject=true)
ans = struct with fields:
           FilterStructure: {'df1sos'  'df2sos'  'df1tsos'  'df2tsos'  'cascadeallpass'  'cascadewdfallpass'}
              SOSScaleNorm: 'ustring'
              SOSScaleOpts: 'fdopts.sosscaling'
              MatchExactly: {'passband'  'stopband'}
    DefaultFilterStructure: 'df2sos'
       DefaultMatchExactly: 'stopband'
       DefaultSOSScaleNorm: ''
       DefaultSOSScaleOpts: [1x1 fdopts.sosscaling]

Use the design function to design the filter. Pass 'butter' and the specifications given by variable designSpecs, as input arguments. Specify the 'matchexactly' design option to 'passband'.

lpFilter = design(designSpecs,'butter',matchexactly='passband',SystemObject=true)
lpFilter = 
  dsp.SOSFilter with properties:

            Structure: 'Direct form II'
    CoefficientSource: 'Property'
            Numerator: [13x3 double]
          Denominator: [13x3 double]
       HasScaleValues: true
          ScaleValues: [0.4095 0.3669 0.3330 0.3059 0.2841 0.2666 0.2525 0.2414 0.2328 0.2263 0.2219 0.2193 0.4674 1]

  Use get to show all properties

Visualize the frequency response of the designed filter.

filterAnalyzer(lpFilter)

Highpass Filter

Construct a highpass filter design specification object using fdesign.highpass. Specify the order to be 7 and the 3 dB frequency to be 0.6π radians/sample.

designSpecs = fdesign.highpass('N,F3dB',7,.6)
designSpecs = 
  highpass with properties:

          Specification: 'N,F3dB'
               Response: 'Highpass'
            Description: {2x1 cell}
    NormalizedFrequency: 1
            FilterOrder: 7
                   F3dB: 0.6000

Determine the available design methods. To design a Butterworth filter, pick butter.

designmethods(designSpecs,SystemObject=true)
Design Methods that support System objects for class fdesign.highpass (N,F3dB):


butter
maxflat

While designing the filter, you can specify additional design options. View a list of the options using the designoptions function. This function also shows the default design options the filter uses.

designoptions(designSpecs,'butter',SystemObject=true)
ans = struct with fields:
           FilterStructure: {'df1sos'  'df2sos'  'df1tsos'  'df2tsos'  'cascadeallpass'  'cascadewdfallpass'}
              SOSScaleNorm: 'ustring'
              SOSScaleOpts: 'fdopts.sosscaling'
    DefaultFilterStructure: 'df2sos'
       DefaultSOSScaleNorm: ''
       DefaultSOSScaleOpts: [1x1 fdopts.sosscaling]

To design the Butterworth filter, use the design function and specify 'butter' as an input. Set 'FilterStructure' to 'cascadeallpass'.

hpFilter = design(designSpecs,'butter',FilterStructure='cascadeallpass',SystemObject=true)
hpFilter = 
  dsp.CoupledAllpassFilter with properties:

               Structure: 'Minimum multiplier'
         PureDelayBranch: 0
    AllpassCoefficients1: {2x1 cell}
    AllpassCoefficients2: {2x1 cell}
                   Gain1: '-1'
                   Gain2: '1'

Visualize the highpass frequency response.

filterAnalyzer(hpFilter)

Lowpass filter a discrete-time signal consisting of two sine waves.

Create a lowpass filter specification object. Specify the passband frequency to be 0.15π rad/sample and the stopband frequency to be 0.25π rad/sample. Specify 1 dB of allowable passband ripple and a stopband attenuation of 60 dB.

d = fdesign.lowpass("Fp,Fst,Ap,Ast",0.15,0.25,1,60);

Query the valid design methods for your filter specification object, d.

designmethods(d)
Design Methods for class fdesign.lowpass (Fp,Fst,Ap,Ast):


butter
cheby1
cheby2
ellip
equiripple
ifir
kaiserwin
multistage

Create an FIR equiripple filter and view the filter frequency response.

Hd = design(d,"equiripple");
freqz(Hd.Numerator,1)

Figure contains 2 axes objects. Axes object 1 with title Phase, xlabel Normalized Frequency (\times\pi rad/sample), ylabel Phase (degrees) contains an object of type line. Axes object 2 with title Magnitude, xlabel Normalized Frequency (\times\pi rad/sample), ylabel Magnitude (dB) contains an object of type line.

Create a signal consisting of the sum of two discrete-time sinusoids with frequencies of π/8 and π/4 rad/sample and amplitudes of 1 and 0.25, respectively. Filter the discrete-time signal with the FIR equiripple filter object, Hd.

n = 0:159;
x = (0.25*cos((pi/8)*n)+sin((pi/4)*n));
y = filter(Hd,x);

Compute the modified periodogram of the original signal and the filtered signal using a Hamming window. Verify that the high-frequency component has been filtered out.

periodogram([x;y]',hamming(length(x)),1024)
legend("Original Signal","Filtered Signal")

Figure contains an axes object. The axes object with title Periodogram Power Spectral Density Estimate, xlabel Normalized Frequency ( times pi blank rad/sample), ylabel Power/frequency (dB/(rad/sample)) contains 2 objects of type line. These objects represent Original Signal, Filtered Signal.

Create a filter of order 10 with a 6-dB frequency of 9.6 kHz and a sampling frequency of 48 kHz. Look at the available design methods.

d = fdesign.lowpass('N,Fc',10,9600,48000);
designmethods(d)
Design Methods for class fdesign.lowpass (N,Fc):


window

The only valid design method is the FIR window method. Design the filter.

Hd = design(d);

Display the filter magnitude response. The -6 dB point is at 9.6 kHz, as expected.

freqz(Hd)

Figure contains 2 axes objects. Axes object 1 with title Phase, xlabel Normalized Frequency (\times\pi rad/sample), ylabel Phase (degrees) contains an object of type line. Axes object 2 with title Magnitude, xlabel Normalized Frequency (\times\pi rad/sample), ylabel Magnitude (dB) contains an object of type line.

Create an FIR equiripple filter with a passband frequency of 0.2π rad/sample, a stopband frequency of 0.25π rad/sample, a passband ripple of 1 dB, and a stopband attenuation of 60 dB. Design the filter with a 20 dB/rad/sample linear stopband.

D = fdesign.lowpass('Fp,Fst,Ap,Ast',0.2,0.25,1,60);
Hd = design(D,'equiripple','StopbandShape','linear','StopbandDecay',20);

Visualize the frequency response of the filter.

freqz(Hd)

Figure contains 2 axes objects. Axes object 1 with title Phase, xlabel Normalized Frequency (\times\pi rad/sample), ylabel Phase (degrees) contains an object of type line. Axes object 2 with title Magnitude, xlabel Normalized Frequency (\times\pi rad/sample), ylabel Magnitude (dB) contains an object of type line.

Version History

Introduced in R2009a

expand all