Process Flow Diagram and Filter Design Methodology
Note
You must minimally have the Signal Processing Toolbox™
installed to use fdesign
and design
. Some of
the features described below may be unavailable if your installation does not
additionally include the DSP System Toolbox™ license. 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 ver
at the command prompt.
Exploring the Process Flow Diagram
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.
Selecting a Response
If you type:
help fdesign/responses
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
Selecting a Specification
A specification is an array of design parameters for a given filter. The specification is a property of the Specifications Object.
Note
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'
The set
command can be used to select one of the available
specifications as
follows:
d = fdesign.lowpass; set(d,'specification', 'N,Fc')
fdesign
returns the
default specification for the response you chose in Select a Response, and provides default values for all design
parameters included in the specification. Selecting an Algorithm
The availability of algorithms depends the chosen filter response, the design
parameters, and the availability of the DSP System Toolbox. 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 'N, Fc'
, only one
algorithm is available—window
.
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:set(d,'specification','Fp,Fst,Ap,Ast') designmethods(d)
Design Methods for class fdesign.lowpass (Fp,Fst,Ap,Ast): butter cheby1 cheby2 ellip equiripple kaiserwin
set(d,'specification','Fp,Fst,Ap,Ast') designmethods(d)
Design Methods for class fdesign.lowpass (Fp,Fst,Ap,Ast): butter cheby1 cheby2 ellip equiripple ifir kaiserwin multistage
design
(DSP System Toolbox) function.
Hd=design(d,'butter');
design
(DSP System Toolbox) automatically selects the
optimum algorithm for the chosen response and specification.Customizing the Algorithm
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:
help(d,'algorithm-name')
d
is the Filter Specification Object, and
algorithm-name
is the name of the algorithm in single quotes,
such as 'butter'
or 'cheby1'
. 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.
Designing the Filter
To create a filter, use the design
command:
Hd = design(d);
d
is 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
follows:
Hd = design(d,'butter');
help fdesign/design
design
command 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 when design
is
called.
Design Analysis
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
Realize or Apply the Filter to Input Data
After the filter is designed and optimized, it can be used to filter actual input
data. The basic filter command takes input data x
, filters it
through the Filter Object, and produces output
y
:
>> y = filter (FilterObj, x)
>> help dfilt/filter
Note
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