Filter specification object
d = fdesign.response
d = fdesign.response(spec)
d = fdesign.response(...,Fs)
d = fdesign.response(...,magunits)
d = fdesign.response returns a filter specification object d, of filter response response. To create filters from d, 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.
Use designmethods to determine which filter design methods work for your new filter specification object.
Use design to apply your filter design method from step 2 to your filter specification object to construct a 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 hd from a filter specification object d, use d with a filter design method such as butter —hd = design(d,'butter').
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 String
fdesign.arbgrpdelay creates an object to specify allpass arbitrary group delay filters. Requires the DSP System Toolbox
fdesign.arbmag creates an object to specify IIR filters that have arbitrary magnitude responses defined by the input arguments.
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.
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
fdesign.bandpass creates an object to specify bandpass filters.
fdesign.bandstop creates an object to specify bandstop filters.
fdesign.ciccomp creates an object to specify filters that compensate for the CIC decimator or interpolator response curves. Requires the DSP System Toolbox.
fdesign.comb creates an object to specify a notching or peaking comb filter. Requires the DSP System Toolbox.
fdesign.decimator creates an object to specify decimators. Requires the DSP System Toolbox
fdesign.differentiator creates an object to specify an FIR differentiator filter.
fdesign.fracdelay creates an object to specify fractional delay filters. Requires the DSP System Toolbox.
fdesign.halfband creates an object to specify halfband filters. Requires the DSP System Toolbox.
fdesign.highpass creates an object to specify highpass filters.
fdesign.hilbert creates an object to specify an FIR Hilbert transformer.
fdesign.interpolator creates an object to specify interpolators. Requires the DSP System Toolbox.
fdesign.isinchp creates an object to specify an inverse sinc highpass filter. Requires the DSP System Toolbox.
fdesign.isinclp creates an object to specify an inverse sinc lowpass filters. Requires the DSP System Toolbox.
fdesign.lowpass creates an object to specify lowpass filters.
fdesign.notch creates an object to specify notch filters. Requires the DSP System Toolbox.
fdesign.nyquist creates an object to specify nyquist filters. Requires the DSP System Toolbox.
fdesign.octave creates an object to specify octave and fractional octave filters. Requires the DSP System Toolbox.
fdesign.parameq creates an object to specify parametric equalizer filters. Requires the DSP System Toolbox.
fdesign.peak creates an object to specify peak filters. Requires the DSP System Toolbox.
fdesign.polysrc creates an object to specify polynomial sample-rate converter filters. Requires the DSP System Toolbox.
fdesign.pulseshaping creates an object to specify pulse-shaping filters.
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.
With the strings for the Specification property, you provide filter constraints such as the filter order or the passband attenuation to use when you construct your filter from the specification object.
fdesign returns a filter specification object. Every filter specification object has the following properties.
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.
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.
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.
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 dfilt objects or mfilt objects.
Added Properties for mfilt Objects
Specifies the amount to decrease the sampling rate. Always a positive integer.
Specifies the amount to increase the sampling rate. Always a positive integer.
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.
d = 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 :
H = fdesign.lowpass % Without a terminating semicolon % the filter specifications are displayed
The default specification 'Fp,Fst,Ap,Ast' is only one of the possible specifications for fdesign.lowpass. To see all available specifications:
H = fdesign.lowpass; set(H,'specification')
The DSP System Toolbox software supports all available specification strings. The Signal Processing Toolbox™ supports a subset of the specification strings. See the reference pages for the filter specification object to determine which specification strings your installation supports.
One important note is that the specification string 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:
d = fdesign.lowpass; % Specification is Fp,Fst,Ap,Ast Hd = design(d,'equiripple'); length(Hd.Numerator) % returns 43 % Filter order is 42 fvtool(Hd) %view magnitude
d = 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.
'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.
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.
d = fdesign.lowpass('N,Fc,Ap,Ast',10,0.2,0.5,40); designmethods(d) % Design FIR equiripple filter hd = design(d,'equiripple');
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.
Set all of the specifications simultaneously.
Return the design methods.
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 string.
Filter object constructors take the input arguments in the same order as setspecs and the order in the strings for Specification. Enter doc setspecs at the prompt for more information about using setspecs.
When the first input to fdesign is not a valid Specification string like 'n,fc', fdesign assumes that the input argument is a filter specification and applies it using the default Specification string —fp,fst,ap,ast for a lowpass object, for example.
The following examples require only the Signal Processing Toolbox.
A bandstop filter specification object for data sampled at 8 kHz. The stopband between 2 and 2.4 kHz is attenuated at least 80 dB:
H = fdesign.bandstop('Fp1,Fst1,Fst2,Fp2,Ap1,Ast,Ap2',... 1600,2000,2400,2800,1,80,1,8000);
A lowpass filter specification object for data sampled at 10 kHz. The passband frequency is 500 Hz and the stopband frequency is 750 Hz. The passband ripple is set to 1 dB and the required attenuation in the stopband is 80 dB.
H = fdesign.lowpass('Fp,Fst,Ap,Ast',500,750,1,80,10000);
A default highpass filter specification object.
H = fdesign.highpass % Creates specifications object. H.Description
Notice the correspondence between the property values in Specification and Description — in Description you see in words the definitions of the variables shown in Specification.
Lowpass Butterworth filter specification object Use a filter specification object to construct a lowpass Butterworth filter with Use a filter specification object to construct a lowpass Butterworth filter with default Specification 'Fp,Fst,Ap,Ast' . Set the passband edge frequency to radians/sample, a stopband frequency of ; radians/sample, a passband ripple of 1 dB, and 80 dB of stopband attenuation.
d = fdesign.lowpass(0.4,0.5,1,80);
Determine which design methods apply to d .
Design Methods for class fdesign.lowpass (Fp,Fst,Ap,Ast): butter cheby1 cheby2 ellip equiripple ifir kaiserwin multistage
You can use d and the butter design method to design a Butterworth filter.
hd = design(d,'butter','matchexactly','passband'); fvtool(hd);
The resulting filter magnitude response shown by FVTool appears in the following figure.
If you have the DSP System Toolbox™ software installed, the preceding figure appears with the filter specification mask.