You must minimally have the Signal Processing Toolbox™ installed
of the features described below may be unavailable if your installation
does not additionally include the DSP System
The DSP System
Toolbox significantly expands the functionality
available for the specification, design, and analysis of filters.
You can verify the presence of both toolboxes by typing
the command prompt.
The process flow diagram shown in the following figure lists the steps and shows the order of the filter design process.
The first four steps of the filter design process relate to the filter Specifications Object, while the last two steps involve the filter Implementation Object. Both of these objects are discussed in more detail in the following sections. Step 5 - the design of the filter, is the transition step from the filter Specifications Object to the Implementation object. The analysis and verification step is completely optional. It provides methods for the filter designer to ensure that the filter complies with all design criteria. Depending on the results of this verification, you can loop back to steps 3 and 4, to either choose a different algorithm, or to customize the current one. You may also wish to go back to steps 3 or 4 after you filter the input data with the designed filter (step 7), and find that you wish to tweak the filter or change it further.
The diagram shows the help command for each step. Enter the help line at the MATLAB® command prompt to receive instructions and further documentation links for the particular step. Not all of the steps have to be executed explicitly. For example, you could go from step 1 directly to step 5, and the interim three steps are done for you by the software.
The following are the details for each of the steps shown above.
If you type:
You must select a response to initiate the filter. In this example, a bandpass filter Specifications Object is created by typing the following:
d = fdesign.bandpass
A specification is an array of design parameters for a given filter. The specification is a property of the Specifications Object.
A specification is not the same as the Specifications Object. A Specifications Object contains a specification as one of its properties.
When you select a filter response, there are a number of different specifications available. Each one contains a different combination of design parameters. After you create a filter Specifications Object, you can query the available specifications for that response. Specifications marked with an asterisk require the DSP System Toolbox.
d = fdesign.bandpass; set(d,'specification')
ans = 'Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2' 'N,F3dB1,F3dB2' 'N,F3dB1,F3dB2,Ap' 'N,F3dB1,F3dB2,Ast' 'N,F3dB1,F3dB2,Ast1,Ap,Ast2' 'N,F3dB1,F3dB2,BWp' 'N,F3dB1,F3dB2,BWst' 'N,Fc1,Fc2' 'N,Fp1,Fp2,Ap' 'N,Fp1,Fp2,Ast1,Ap,Ast2' 'N,Fst1,Fp1,Fp2,Fst2' 'N,Fst1,Fp1,Fp2,Fst2,Ap' 'N,Fst1,Fst2,Ast' 'Nb,Na,Fst1,Fp1,Fp2,Fst2'
d = fdesign.arbmag; set(d,'specification')
ans = 'N,F,A' 'N,B,F,A'
set command can be used to select one
of the available specifications as follows:
d = fdesign.lowpass; set(d,'specification', 'N,Fc')
fdesignreturns the default specification for the response you chose in Select a Response, and provides default values for all design parameters included in the specification.
The availability of algorithms depends the chosen filter response,
the design parameters, and the availability of the DSP System
In other words, for the same lowpass filter, changing the specification
also changes the available algorithms. In the following example, for
a lowpass filter and a specification of
only one algorithm is available—
set (d, 'specification', 'N,Fc') designmethods (d) %step3: get available algorithms
Design Methods for class fdesign.lowpass (N,Fc): window
'Fp,Fst,Ap,Ast', a number of algorithms are available. If the user has only the Signal Processing Toolbox™ installed, the following algorithms are available:
Design Methods for class fdesign.lowpass (Fp,Fst,Ap,Ast): butter cheby1 cheby2 ellip equiripple kaiserwin
Design Methods for class fdesign.lowpass (Fp,Fst,Ap,Ast): butter cheby1 cheby2 ellip equiripple ifir kaiserwin multistage
designautomatically selects the optimum algorithm for the chosen response and specification.
The customization options available for any given algorithm depend not only on the algorithm itself, selected in Selecting an Algorithm, but also on the specification selected in Selecting a Specification. To explore all the available options, type the following at the MATLAB command prompt:
dis the Filter Specification Object, and
algorithm-nameis the name of the algorithm in single quotes, such as
The application of these customization options takes place while Designing the Filter, because these options are the properties of the filter Implementation Object, not the Specification Object.
If you do not perform this step explicitly, the optimum algorithm structure is selected.
To create a filter, use the
Hd = design(d);
dis the Specifications Object. This code creates a filter without specifying the algorithm. When the algorithm is not specified, the software selects the best available one.
To apply the algorithm chosen in Selecting an Algorithm, use the same
design command, but specify the Butterworth algorithm as
Hd = design(d,'butter');
designcommand itself, but also options that pertain to the method or the algorithm. If you are customizing the algorithm, you apply these options in this step. In the following example, you design a bandpass filter, and then modify the filter structure:
Hd = design(d,'butter','FilterStructure','df2sos')
Hd = FilterStructure: 'Direct-Form II, Second-Order Sections' Arithmetic: 'double' sosMatrix: [13x6 double] ScaleValues: [14x1 double] OptimizeScaleValues: true PersistentMemory: false
The filter design step, just like the first task of choosing
a response, must be performed explicitly. The filter is created only
design is called.
After the filter is designed you may wish to analyze it to determine if the filter satisfies the design criteria. Filter analysis is broken into three main sections:
Frequency domain analysis — Includes the magnitude response, group delay, and pole-zero plots.
Time domain analysis — Includes impulse and step response
Implementation analysis — Includes quantization noise and cost
To display help for analysis of a discrete-time filter, type:
>> help dfilt/analysis
>> help farrow/functions
After the filter is designed and optimized, it can be used to
filter actual input data. The basic filter command takes input data
filters it through the Filter Object, and produces output
>> y = filter (FilterObj, x)
>> help dfilt/filter
If you have Simulink®, you have the option of
exporting this filter to a Simulink block using the
realizemdl command. To
get help on this command, type:
>> help realizemdl