| Filter Design Toolbox™ | ![]() |
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.
Here is how you design filters using fdesign.
Use fdesign.response to construct a filter specification object.
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'). |
For more guidance about using fdesign, refer to the examples in Filter Design Toolbox Getting Started Guide. Alternatively, type the following at the MATLAB prompt for more information:
help fdesign
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 | Description |
|---|---|
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. |
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. |
decimator | fdesign.decimator creates an object to specify decimators. |
differentiator | fdesign.differentiator creates an object to specify differentiators. |
fracdelay | fdesign.fracdelay creates an object to specify fractional delay filters. |
halfband | fdesign.halfband creates an object to specify halfband filters. |
highpass | fdesign.highpass creates an object to specify highpass filters. |
hilbert | fdesign.hilbert creates an object to specify Hilbert filters. |
interpolator | fdesign.interpolator creates an object to specify interpolators. |
isinclp | fdesign.isinclp creates an object to specify lowpass filters that use inverse-sinc form. |
lowpass | fdesign.lowpass creates an object to specify lowpass filters. |
notch | fdesign.notch creates an object to specify notch filters. |
nyquist | fdesign.nyquist creates an object to specify nyquist filters. |
octave | fdesign.octave creates an object to specify octave and fractional octave filters. |
parameq | fdesign.parameq creates an object to specify parametric equalizer filters. |
peak | fdesign.peak creates an object to specify peak filters. |
polysrc | fdesign.polysrc creates an object to specify polynomial sample-rate converter filters. |
pulseshaping | fdesign.pulseshaping creates an object to specify pulse shaping filters. |
rsrc | fdesign.rsrc creates an object to specify rational-factor sample-rate convertors. |
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.
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 Fstop 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. |
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 | 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. |
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. These variables are applied to the filter design method you choose to design your filter.
For example, when you create a default lowpass filter specification object d, fdesign sets the passband frequency Fpass, the stopband frequency Fstop, the stopband attenuation Astop, and the passband attenuation Apass (ripple in the passband) for d:
d = fdesign.lowpass
d =
Response: 'Lowpass'
Specification: 'Fp,Fst,Ap,Ast'
Description: {4x1 cell}
NormalizedFrequency: true
Fpass: 0.45
Fstop: 0.55
Apass: 1
Astop: 60However, lowpass design syntax accepts any one of the following Spec strings (among others) to define the filter response:
Spec String | Description |
|---|---|
Fp,Fst,Ap,Ast | Define the filter by specifying the passband cutoff, the stopband cutoff, the ripple in the passband, and the attenuation in the stopband. This is the default string for a lowpass filter. |
N,Fc | Set the filter order and the cutoff frequency to define the filter. |
N,Fp,Ap | Set the filter order, passband cutoff frequency, and passband ripple. |
N,Fst,Ast | Define the filter by setting the order, stopband frequency, and stopband attenuation. |
N,Fp,Ap,Ast | Set the order, passband cutoff frequency, passband ripple, and stopband attenuation. |
N,Fp,Fst,Ap | Set the filter order, passband cutoff frequency, stopband frequency, and passband ripple. |
Other filter object types, such as Nyquist or highpass, accept a different set of strings for Spec. Refer to the Help system for details about the strings for each filter type.
One important note is that the Spec string you choose controls which design method works for the specifications object.
For the lowpass filter specification object d from earlier, you can use butter, cheby1, cheby2, or ellip (to name a few) to design a filter. However, if the Spec string had been 'n,fp,fst,ap', you could only use the ellip design method to design your filter.
When you implement this lowpass filter hd using a filter design method such as Butterworth (the butter design function), the constraints in fp, fst, ap, and ast (the default string and filter specification) define the response of the final minimum-order lowpass filter:
hd = design(d,'butter')
hd =
FilterStructure: 'Direct-Form II, Second-Order Sections'
Arithmetic: 'double'
sosMatrix: [13x6 double]
ScaleValues: [14x1 double]
PersistentMemory: falseFVTool shows that hd is a lowpass filter that meets the design specification.
d = fdesign.response(...,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.response(...,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 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. The following methods are available for filter specification objects, but all methods do not apply to all object types. Also, the specification string you use to define the object changes the algorithms available to design a filter. Enter doc butter, for example, to get more information about using the Butterworth design method with your filter specification object.
Design Function | Description |
|---|---|
Implement a Butterworth filter resulting in an SOS filter with direct-form II structure | |
Implement a Chebyshev Type I filter, resulting in a direct-form II second-order filter | |
Implement a Chebyshev Type II filter, resulting in an SOS filter with direct-form II structure | |
Implement an elliptic filter resulting in an SOS filter with direct-form II structure | |
Implement an equiripple filter | |
Implement a least-squares filter | |
Implement a filter that uses a Kaiser window | |
lagrange | Implement a Lagrange fractional delay filter |
Implement a multistage filter |
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 |
|---|---|
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.
These examples show a few default filter objects constructed from the MATLAB command prompt, and how to design a Butterworth filter.
Halfband filter specification object with filter order and stopband attenuation provided as input arguments. Add the linear magunits option so you specify the attenuation in decimal — 0.0001.
n = 80;
ast = 1e-4;
fs = 48000
d=fdesign.halfband('n,ast',n,ast,fs,'linear')
d =
Response: [1x51 char]
Specification: 'N,Ast'
Description: {2x1 cell}
NormalizedFrequency: false
Fs: 48000
FilterOrder: 80
Astop: 80
d.description
ans =
'Filter Order'
'Stopband Attenuation (dB)'Interpolator filter specification object
d = fdesign.interpolator % Specifications object.
d =
Response: 'Minimum-order halfband'
Specification: 'TW,Ast'
Description: {2x1 cell}
InterpolationFactor: 2
NormalizedFrequency: true
Fs: 'Normalized'
TransitionWidth: 0.1000
Astop: 80
d.Description
ans =
'Transition Width'
'Stopband Attenuation (dB)'Highpass filter specification object
d=fdesign.highpass % Creates specifications object.
d =
Response: 'Minimum-order highpass'
Specification : 'Fst,Fp,Ast,Ap'
Description: {4x1 cell}
NormalizedFrequency: true
Fs: 'Normalized'
Fstop: 0.4500
Fpass: 0.5500
Astop: 60
Apass: 1
d.Description
ans =
'Stopband Frequency'
'Passband Frequency'
'Stopband Attenuation (dB)'
'Passband Ripple (dB)'Notice the correspondence between the properties Specification and Description — in Description you see in words the definitions of the variables shown in Specification.
Only the Kaiser window-based design method applies to default Nyquist filter objects.
Lowpass Butterworth filter specification object
Use a filter specification object to construct a lowpass Butterworth filter with default Specification fp,fst,ap,ast — the edge frequencies of the passband and stopband, the attenuation in the passband, and the attenuation in the stopband. Start by creating the specifications object d and providing the filter order and cutoff frequency values.
d = fdesign.lowpass(0.4,0.5,1,80);
d
d =
Response: 'Minimum-order lowpass'
Specification: 'Fp,Fst,Ap,Ast'
Description: {4x1 cell}
NormalizedFrequency: true
Fs: 'Normalized'
Fpass: 0.4000
Fstop: 0.5000
Apass: 1
Astop: 80Determine which design methods apply to d.
designmethods(d) Design Methods for class fdesign.lowpass: butter cheby1 cheby2 ellip
Now 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 had a default Nyquist filter specification object d
d = fdesign.nyquist
you could find out which design methods apply to d by entering
designmethods(d) Design methods for class fdesign.nyquist: kaiserwin
butter, cheby1, cheby2, designmethods, designopts, ellip, equiripple, fdatool, fdesign.bandpass, fdesign.bandstop, fdesign.decimator, fdesign.halfband, fdesign.highpass, fdesign.interpolator, fdesign.lowpass, fdesign.nyquist, fdesign.rsrc, firls, fvtool, kaiserwin, lagrange, multistage, setspecs, validstructures
![]() | fdatool | fdesign.arbmag | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |