Documentation

This is machine translation

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

fdesign

Filter specification object

Syntax

filtSpecs = fdesign.response
filtSpecs = fdesign.response(spec)
filtSpecs = fdesign.response(...,Fs)
filtSpecs = fdesign.response(...,magunits)

Description

Filter Specification Objects

filtSpecs = fdesign.response returns a filter specification object, filtSpecs, of filter response response. To create filters from filtSpecs, use one of the design methods listed in Using Filter Design Methods with Specification Objects.

    Note:   Several of the filter response types described below are only available if your installation includes the DSP System Toolbox™. The DSP System Toolbox significantly expands the functionality available for the specification, design, and analysis of filters.

Here is how you design filters using fdesign.

  1. Use fdesign.response to construct a filter specification object.

  2. Use designmethods to determine which filter design methods work for your new filter specification object.

  3. Use design to apply your filter design method from step 2 to your filter specification object to construct a filter object.

  4. Use FVTool to inspect and analyze your filter object.

    Note   fdesign does not create filters. fdesign returns a filter specification object that contains the specifications for a filter, such as the passband cutoff or attenuation in the stopband. To design a filter from a filter specification object filtSpecs, use filtSpecs with a filter design method such as butterIIRbutter = design(filtSpecs,'butter','SystemObject',true).

response can be one of the entries in the following table that specify the filter response desired, such as a bandstop filter or an interpolator.

fdesign Response Method

Description

arbgrpdelay

fdesign.arbgrpdelay creates an object to specify allpass arbitrary group delay filters. Requires the DSP System Toolbox

arbmag

fdesign.arbmag creates an object to specify IIR filters that have arbitrary magnitude responses defined by the input arguments.

arbmagnphase

fdesign.arbmagnphase creates an object to specify IIR filters that have arbitrary magnitude and phase responses defined by the input arguments. Requires the DSP System Toolbox.

audioweighting

fdesign.audioweighting creates a filter specification object for audio weighting filters. The supported audio weighting types are: A, C, C-message, ITU-T 0.41, and ITU-R 468-4 weighting. Requires the DSP System Toolbox

bandpass

fdesign.bandpass creates an object to specify bandpass filters.

bandstop

fdesign.bandstop creates an object to specify bandstop filters.

ciccomp

fdesign.ciccomp creates an object to specify filters that compensate for the CIC decimator or interpolator response curves. Requires the DSP System Toolbox.

comb

fdesign.comb creates an object to specify a notching or peaking comb filter. Requires the DSP System Toolbox.

decimator

fdesign.decimator creates an object to specify decimators. Requires the DSP System Toolbox

differentiator

fdesign.differentiator creates an object to specify an FIR differentiator filter.

fracdelay

fdesign.fracdelay creates an object to specify fractional delay filters. Requires the DSP System Toolbox.

halfband

fdesign.halfband creates an object to specify halfband filters. Requires the DSP System Toolbox.

highpass

fdesign.highpass creates an object to specify highpass filters.

hilbert

fdesign.hilbert creates an object to specify an FIR Hilbert transformer.

interpolator

fdesign.interpolator creates an object to specify interpolators. Requires the DSP System Toolbox.

isinchp

fdesign.isinchp creates an object to specify an inverse sinc highpass filter. Requires the DSP System Toolbox.

isinclp

fdesign.isinclp creates an object to specify an inverse sinc lowpass filters. Requires the DSP System Toolbox.

lowpass

fdesign.lowpass creates an object to specify lowpass filters.

notch

fdesign.notch creates an object to specify notch filters. Requires the DSP System Toolbox.

nyquist

fdesign.nyquist creates an object to specify Nyquist filters. Requires the DSP System Toolbox.

octave

fdesign.octave creates an object to specify octave and fractional octave filters. Requires the DSP System Toolbox.

parameq

fdesign.parameq creates an object to specify parametric equalizer filters. Requires the DSP System Toolbox.

peak

fdesign.peak creates an object to specify peak filters. Requires the DSP System Toolbox.

polysrc

fdesign.polysrc creates an object to specify polynomial sample-rate converter filters. Requires the DSP System Toolbox.

rsrc

fdesign.rsrc creates an object to specify rational-factor sample-rate convertors. Requires the DSP System Toolbox.

Use the doc fdesign.response syntax at the MATLAB prompt to get help on a specific structure. Using doc in a syntax like

doc fdesign.lowpass
doc fdesign.bandstop

gets more information about the lowpass or bandstop structure objects.

Each response has a property Specification that defines the specifications to use to design your filter. You can use defaults or specify the Specification property when you construct the specifications object.

Using the Specification property, you can provide filter constraints such as the filter order or the passband attenuation to use when you construct your filter from the specification object.

Properties

fdesign returns a filter specification object. Every filter specification object has the following 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 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 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.

filtSpecs = fdesign.response(spec). In spec, you specify the variables to use that define your filter design, such as the passband frequency or the stopband attenuation. The specifications are applied to the filter design method you choose to design your filter.

For example, when you create a default lowpass filter specification object, fdesign.lowpass sets the passband frequency Fp, the stopband frequency Fst, the stopband attenuation Ast, and the passband ripple Ap:

filtSpecs = fdesign.lowpass

Use without a terminating semicolon to display the filter specifications.

The default specification 'Fp,Fst,Ap,Ast' is only one of the possible specifications for fdesign.lowpass. To see all available specifications:

filtSpecs = fdesign.lowpass;
set(filtSpecs,'Specification')

The DSP System Toolbox software supports all available specification options. The Signal Processing Toolbox™ supports a subset of the specification options. See the reference pages for the filter specification object to determine which specification option your installation supports.

One important note is that the specification option you choose determines which design methods apply to the filter specifications object.

Specifications that do not contain the filter order result in minimum order designs when you invoke the design method:

filtSpecs = fdesign.lowpass;      % Specification is 'Fp,Fst,Ap,Ast'
FIReq = design(filtSpecs,'equiripple','SystemObject',true);
length(FIReq.Numerator)           % Returns 43. The filter order is 42
fvtool(FIReq)                     % View magnitude

filtSpecs = fdesign.response(...,Fs) specifies the sampling frequency in Hz to use in the filter specifications. The sampling frequency is a scalar trailing all other input arguments. If you specify a sampling frequency, all frequency specifications are in Hz.

filtSpecs = fdesign.response(...,magunits) specifies the units for any magnitude specification you provide in the input arguments. magunits can be one of the following options:

  • 'linear' — specify the magnitude in linear units

  • 'dB' — specify the magnitude in decibels

  • 'squared' — specify the magnitude in power units

When you omit the magunits 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.

Using Filter Design Methods with Specification Objects

After you create a filter specification object, you use a filter design method to implement your filter with a selected algorithm. Use designmethods to determine valid design methods for your filter specification object.

filtSpecs = fdesign.lowpass('N,Fc,Ap,Ast',10,0.2,0.5,40);
designmethods(filtSpecs)
% Design FIR equiripple filter
FIReq = design(filtSpecs,'equiripple','SystemObject',true);

When you use any of the design methods without providing an output argument, the resulting filter design appears in FVTool by default.

Along with filter design methods, fdesign works with supporting methods that help you create filter specification objects or determine which design methods work for a given specifications object.

Supporting Function

Description

setspecs

Set all of the specifications simultaneously.

designmethods

Return the design methods.

designopts

Return the input arguments and default values that apply to a specifications object and method

You can set filter specification values by passing them after the Specification argument, or by passing the values without the Specification.

Filter object constructors take the input arguments in the same order as setspecs and Specification. Enter doc setspecs at the prompt for more information about using setspecs.

When the first input to fdesign is not a valid Specification option like 'N,Fc', fdesign assumes that the input argument is a filter specification and applies it using the default Specification option — 'Fp,Fst,Ap,Ast' for a lowpass object, for example.

Examples

collapse all

This example requires the DSP System Toolbox product.

Design a lowpass filter to be used on a signal sampled at 96 kHz. The passband of the filter extends up to 20 kHz. The stopband of the filter starts at 24 kHz. Specify a passband ripple of 0.01 dB and a stopband attenuation of 80 dB. Determine automatically the order required to meet the specifications.

Set up the filter design specifications and determine the available design algorithms.

Fs = 96e3;
Fpass = 20e3;
Fstop = 24e3;
Apass = 0.01;
Astop = 80;

filtSpecs = fdesign.lowpass(Fpass,Fstop,Apass,Astop,Fs);
designmethods(filtSpecs)

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


butter
cheby1
cheby2
ellip
equiripple
ifir
kaiserwin
multistage

Design an equiripple FIR filter and an elliptic IIR filter that meet the specifications. Measure the designs to verify that the filters satisfy the constraints.

lpFIR = design(filtSpecs,'equiripple','SystemObject',true);
lpIIR = design(filtSpecs,'ellip','SystemObject',true);

FIRmeas = measure(lpFIR)
IIRmeas = measure(lpIIR)
FIRmeas = 

Sample Rate      : 96 kHz      
Passband Edge    : 20 kHz      
3-dB Point       : 21.4297 kHz 
6-dB Point       : 21.8447 kHz 
Stopband Edge    : 24 kHz      
Passband Ripple  : 0.0092309 dB
Stopband Atten.  : 80.6014 dB  
Transition Width : 4 kHz       
 

IIRmeas = 

Sample Rate      : 96 kHz     
Passband Edge    : 20 kHz     
3-dB Point       : 20.5524 kHz
6-dB Point       : 20.7138 kHz
Stopband Edge    : 24 kHz     
Passband Ripple  : 0.01 dB    
Stopband Atten.  : 80 dB      
Transition Width : 4 kHz      
 

Estimate and display the computational cost of each filter. The equiripple FIR filter requires many more coefficients than the elliptic IIR filter.

FIRcost = cost(lpFIR)
IIRcost = cost(lpIIR)
FIRcost = 

  struct with fields:

                  NumCoefficients: 101
                        NumStates: 100
    MultiplicationsPerInputSample: 101
          AdditionsPerInputSample: 100


IIRcost = 

  struct with fields:

                  NumCoefficients: 20
                        NumStates: 10
    MultiplicationsPerInputSample: 20
          AdditionsPerInputSample: 20

Visualize the resulting designs with FVTool to compare their properties.

fvtool(lpFIR,lpIIR,'Fs',Fs);
legend('FIR Equiripple','Elliptic IIR')

This example requires the DSP System Toolbox product.

Design a 100-tap FIR lowpass decimator filter that reduces the sample rate of a signal from 60 kHz to 20 kHz. The passband of the filter extends up to 6 kHz. Specify a passband ripple of 0.01 dB and a stopband attenuation of 100 dB.

Fs = 60e3;
N = 99;
Fpass = 6e3;
Apass = 0.01;
Astop = 100;
M = Fs/20e3;

filtSpecs = fdesign.decimator(M,'lowpass','N,Fp,Ap,Ast',N,Fpass,Apass,Astop,Fs);

Design the filter and display information about it.

decimFIR = design(filtSpecs,'equiripple','SystemObject',true);
info(decimFIR)
ans =

Discrete-Time FIR Multirate Filter (real)               
-----------------------------------------               
Filter Structure   : Direct-Form FIR Polyphase Decimator
Decimation Factor  : 3                                  
Polyphase Length   : 34                                 
Filter Length      : 100                                
Stable             : Yes                                
Linear Phase       : Yes (Type 2)                       
                                                        
Arithmetic         : double                             

Visualize the magnitude response of the filter.

fvtool(decimFIR,'Fs',Fs)

Use a filter specification object to construct a lowpass Butterworth filter with the default specification, 'Fp,Fst,Ap,Ast'. Specify a passband edge frequency of $0.4\pi$ rad/sample, a stopband frequency of $0.5\pi$ rad/sample, a passband ripple of 1 dB, and a stopband attenuation of 80 dB.

filtSpecs = fdesign.lowpass(0.4,0.5,1,80);

Determine which design methods apply to filtSpecs.

designmethods(filtSpecs)

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


butter
cheby1
cheby2
ellip
equiripple
ifir
kaiserwin
multistage

You can use filtSpecs and the butter design method to design a Butterworth filter. Determine the available design options.

designoptions(filtSpecs,'butter')
ans = 

  struct with fields:

           FilterStructure: {1×6 cell}
              SOSScaleNorm: 'ustring'
              SOSScaleOpts: 'fdopts.sosscaling'
              MatchExactly: {'passband'  'stopband'}
              SystemObject: 'bool'
    DefaultFilterStructure: 'df2sos'
       DefaultMatchExactly: 'stopband'
       DefaultSOSScaleNorm: ''
       DefaultSOSScaleOpts: [1×1 fdopts.sosscaling]
       DefaultSystemObject: 0

The filter order necessary to meet a set of design constraints must also be rounded up to an integer value. This loosens some of the constraints, and, as a consequence, some design specifications are met while others are exceeded. The 'MatchExactly' option allows you to match the passband or stopband exactly while exceeding the specification for the other band. Design the filter so that it matches the passband exactly.

IIRbutter = design(filtSpecs,'butter','MatchExactly','passband', ...
    'SystemObject',true);

Use FVTool to visualize the magnitude response of the filter.

fvtool(IIRbutter)

If you have the DSP System Toolbox software installed, the preceding figure appears with the filter specification mask.

Introduced in R2009a

Was this topic helpful?