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: [-0.0057 -0.0010 0.0010 0.0040 0.0065 0.0073 0.0055 0.0014 -0.0033 -0.0066 -0.0067 -0.0029 0.0033 0.0091 0.0114 0.0083 4.2874e-04 -0.0091 -0.0158 -0.0154 -0.0070 0.0069 0.0202 0.0259 0.0193 5.1049e-04 -0.0239 ... ] (1x69 double)
    InitialConditions: 0

  Use get to 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: [0.0162 0.0380 0.0724 0.1143 0.1561 0.1875 0.1981 0.1814 0.1378 0.0750 0.0071 -0.0499 -0.0825 -0.0845 -0.0593 -0.0181 0.0236 0.0514 0.0572 0.0412 0.0117 -0.0187 -0.0385 -0.0410 -0.0272 -0.0040 0.0182 0.0308 ... ] (1x59 double)
    InitialConditions: 0

  Use get to 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')

Figure Figure 1: Pole-Zero Plot contains an axes object. The axes object with title Pole-Zero Plot, xlabel Real Part, ylabel Imaginary Part contains 6 objects of type line, text. One or more of the lines displays its values using only markers These objects represent Default design: Zero, Default design: Pole, Minimum-phase design: Zero, Minimum-phase design: Pole.

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

designoptions(designSpecs,'ellip')
ans = struct with fields:
           FilterStructure: {'df1sos'  'df2sos'  'df1tsos'  'df2tsos'  'cascadeallpass'  'cascadewdfallpass'}
              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.SOSFilter with properties:

            Structure: 'Direct form II'
    CoefficientSource: 'Property'
            Numerator: [3x3 double]
          Denominator: [3x3 double]
       HasScaleValues: true
          ScaleValues: [0.2868 0.1982 0.2819 1]

  Use get to 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.SOSFilter with properties:

            Structure: 'Direct form II'
    CoefficientSource: 'Property'
            Numerator: [3x3 double]
          Denominator: [3x3 double]
       HasScaleValues: false

  Use get to show all properties

Display the frequency responses of the filters.

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

Figure Figure 2: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Normalized Frequency ( times pi blank rad/sample), ylabel Magnitude (dB) contains 3 objects of type line. These objects represent 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

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)

Version History

Introduced in R2009a