Main Content

design

Apply design method to filter specification object

Description

filt = design(designSpecs,'Systemobject',true) uses the filter specification object, designSpecs, to generate a filter System object™, filt. When you do not provide a design method as an input argument, design uses the default design method. Use designmethods(designSpecs,'default') to see the default design method for your filter design specification object. For more information on filter design specifications, see Design a Filter in Fdesign — Process Overview.

filt = design(designSpecs,method,'Systemobject',true) uses the design method specified by method. method must be one of the options returned by designmethods.

example

filt = design(designSpecs,method,PARAM,VALUE,...,'Systemobject',true) specifies design method options. Use designoptions(designSpecs,method) to see a list of available design method options to choose from. For detailed help on each of these options, type help(designSpecs,method) in the MATLAB® command prompt.

filt = design(designSpecs,method,opts,'Systemobject',true) specifies design method options using the structure opts. opts is usually obtained from the designopts function and then specified as an input to the design function. Use help(designSpecs,method) for more information on optional inputs.

Examples

collapse all

Design an FIR equiripple lowpass filter. Specify a passband edge frequency of 0.2π rad/sample and a stopband edge frequency of 0.25π rad/sample. Set the passband ripple to 0.5 dB and the stopband attenuation to 40 dB..

designSpecs = fdesign.lowpass('Fp,Fst,Ap,Ast',0.2,0.25,0.5,40)
designSpecs = 
  lowpass with properties:

               Response: 'Lowpass'
          Specification: 'Fp,Fst,Ap,Ast'
            Description: {4x1 cell}
    NormalizedFrequency: 1
                  Fpass: 0.2000
                  Fstop: 0.2500
                  Apass: 0.5000
                  Astop: 40

Use the default Equiripple method to design the filter.

filt = design(designSpecs,'SystemObject',true)
filt = 
  dsp.FIRFilter with properties:

            Structure: 'Direct form'
      NumeratorSource: 'Property'
            Numerator: [1x69 double]
    InitialConditions: 0

  Show all properties

Determine the available design methods by running the designmethods function on the filter design specification object, designSpecs.

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

You can also specify the design options used in designing the filter. To see a list of available options, run the designoptions function on designSpecs.

designoptions(designSpecs,'equiripple')
ans = struct with fields:
           FilterStructure: {'dffir'  'dffirt'  'dfsymfir'  'fftfir'}
             DensityFactor: 'double'
                  MinPhase: 'bool'
                  MaxPhase: 'bool'
                  MinOrder: {'any'  'even'  'odd'}
             StopbandShape: {'flat'  'linear'  '1/f'}
             StopbandDecay: 'double'
               UniformGrid: 'bool'
              SystemObject: 'bool'
    DefaultFilterStructure: 'dffir'
      DefaultDensityFactor: 16
           DefaultMaxPhase: 0
           DefaultMinOrder: 'any'
           DefaultMinPhase: 0
      DefaultStopbandDecay: 0
      DefaultStopbandShape: 'flat'
       DefaultSystemObject: 0
        DefaultUniformGrid: 1

Design a minimum-phase FIR equiripple filter by setting 'MinPhase' to true.

filtMin = design(designSpecs,'equiripple','MinPhase',true,'SystemObject',true)
filtMin = 
  dsp.FIRFilter with properties:

            Structure: 'Direct form'
      NumeratorSource: 'Property'
            Numerator: [1x59 double]
    InitialConditions: 0

  Show all properties

Display pole-zero plots of the default and minimum-phase designs.

fvt = fvtool(filt,filtMin,'Analysis','polezero');
legend(fvt,'Default design','Minimum-phase design')

Redesign the filter using the elliptic method. Determine the available design options for the elliptic method.

designoptions(designSpecs,'ellip')
ans = struct with fields:
           FilterStructure: {1x6 cell}
              SOSScaleNorm: 'ustring'
              SOSScaleOpts: 'fdopts.sosscaling'
              MatchExactly: {'passband'  'stopband'  'both'}
              SystemObject: 'bool'
    DefaultFilterStructure: 'df2sos'
       DefaultMatchExactly: 'both'
       DefaultSOSScaleNorm: ''
       DefaultSOSScaleOpts: [1x1 fdopts.sosscaling]
       DefaultSystemObject: 0

Match the passband exactly by setting 'MatchExactly' to 'passband'.

filt = design(designSpecs,'ellip','MatchExactly','passband','SystemObject',true)
filt = 
  dsp.BiquadFilter with properties:

                   Structure: 'Direct form II'
             SOSMatrixSource: 'Property'
                   SOSMatrix: [3x6 double]
                 ScaleValues: [4x1 double]
           InitialConditions: 0
    OptimizeUnityScaleValues: true

  Show all properties

You can specify the Pth norm scaling on the second-order sections. Use L-infinity norm scaling in the time domain.

filtL = design(designSpecs,'ellip','MatchExactly','passband','SOSScaleNorm','linf', ...
    'SystemObject',true)
filtL = 
  dsp.BiquadFilter with properties:

                   Structure: 'Direct form II'
             SOSMatrixSource: 'Property'
                   SOSMatrix: [3x6 double]
                 ScaleValues: [4x1 double]
           InitialConditions: 0
    OptimizeUnityScaleValues: true

  Show all properties

Display the frequency responses of the filters.

fvt = fvtool(filt,filtL);
legend(fvt,'Default scaling','L-infinity norm scaling')

Input Arguments

collapse all

fdesign returns a filter design specification object. Every filter design specification object has these properties.

Property Name

Default Value

Description

Response

Depends on the chosen type

Defines the type of filter to design, such as an interpolator or bandpass filter. This is a read-only value.

Specification

Depends on the chosen type

Defines the filter characteristics used to define the desired filter performance, such as the cutoff frequency Fc or the filter order N.

Description

Depends on the filter type you choose

Contains descriptions of the filter specifications used to define the object, and the filter specifications you use when you create a filter from the object. This is a read-only value.

NormalizedFrequency

Logical true

Determines whether the filter calculation uses a normalized frequency from 0 to 1, or the frequency band from 0 to Fs/2, the sampling frequency. Accepts either true or false without single quotation marks. Audio weighting filters do not support normalized frequency.

In addition to these properties, filter design specification objects may have other properties as well, depending on whether they design single-rate filters or multirate filters.

Added Properties for Multirate Filters

Description

DecimationFactor

Specifies the amount to decrease the sampling rate. Always a positive integer.

InterpolationFactor

Specifies the amount to increase the sampling rate. Always a positive integer.

PolyphaseLength

Polyphase length is the length of each polyphase subfilter that composes the decimator or interpolator or rate-change factor filters. Total filter length is the product of pl and the rate change factors. pl must be an even integer.

Design method, specified as a character vector. The design method you provide as the input argument must be one of the methods returned by:

designmethods(designSpecs,'Systemobject',true)

The table lists all the design methods. A subset of these become available depending on the filter design specification object, designSpecs.

Design methods

Description

butter

Butterworth filter

cheby1

Chebyshev Type I filter

cheby2

Chebyshev Type II filter

ellip

Elliptic filter

equiripple

Equiripple FIR filter

firls

Least-square linear-phase FIR filter

freqsamp

Frequency-sampled FIR filter

ifir

Interpolated FIR filter

iirlinphase

Quasi-linear phase IIR filter

iirlpnorm

Least P-norm optimal IIR filter

iirls

Least-squares IIR filter

fircls

FIR constrained least squares filter

kaiserwin

Kaiser window filter

maxflat

Maxflat FIR filter

multistage

Multistage filter

window

FIR filter using windowed impulse response

ansis142

ANSI S1.42 filter. Applies to the fdesign.audioweighting object.

bell41009

Bell 41009 (C-message) IIR filter. Applies to the fdesign.audioweighting object.

To help you design filters more quickly, the input argument method accepts a variety of special keywords that force design to behave in different ways. This table presents the keywords you can use for method and how design responds to the keyword:

Design Method Keyword

Description of the Design Response

'FIR'

Forces design to produce an FIR filter. When no FIR design method exists for object d, design returns an error.

'IIR'

Forces design to produce an IIR filter. When no IIR design method exists for object d, design returns an error.

'ALLFIR'

Produces filters from every applicable FIR design method for the specifications in d, one filter for each design method. As a result, design returns multiple filters in the output object.

'ALLIIR'

Produces filters from every applicable IIR design method for the specifications in d, one filter for each design method. As a result, design returns multiple filters in the output object.

'ALL'

Designs filters using all applicable design methods for the specifications object d. As a result, design returns multiple filters, one for each design method. design uses the design methods in the order that designmethods(D,'Systemobject',true) returns them.

Keywords are not case sensitive.

When design returns multiple filters in the output object, use indexing to see the individual filters. For example, to see the third filter in filt, enter:

filt(3)

Example: filt = design(designSpecs,'butter','SystemObject',true)

Example: filt = design(designSpecs,'ALLFIR','SystemObject',true)

Specify design options by passing opts structure as an input to the design function. The opts structure is obtained by running designopts(designSpecs,method).

designSpecs = fdesign.notch
opts = designopts(designSpecs,'butter')
opts.FilterStructure = 'df1sos'
filt = design(designSpecs,'butter',opts,'SystemObject',true))
Introduced in R2009a