Documentation Center |
On this page… |
---|
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. |
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:
help fdesign/responses
at the MATLAB command prompt, you see a list of all available filter responses. The responses marked with an asterisk require the DSP System Toolbox.
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.
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; % step 1 - choose the response >> 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; % step 1 >> % step 2: get a list of available specifications >> set (d, 'specification') ans = 'Fp,Fst,Ap,Ast' 'N,F3dB' 'N,F3dB,Ap' 'N,F3dB,Ap,Ast' 'N,F3dB,Ast' 'N,F3dB,Fst' 'N,Fc' 'N,Fc,Ap,Ast' 'N,Fp,Ap' 'N,Fp,Ap,Ast' 'N,Fp,F3dB' 'N,Fp,Fst' 'N,Fp,Fst,Ap' 'N,Fp,Fst,Ast' 'N,Fst,Ap,Ast' 'N,Fst,Ast' 'Nb,Na,Fp,Fst' >> %step 2: set the required specification >> set (d, 'specification', 'N,Fc')
If you do not perform this step explicitly, 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.
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 string 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.
>> %step 2: set the required specification >> set (d, 'specification', 'N,Fc') >> designmethods (d) %step3: get available algorithms Design Methods for class fdesign.lowpass (N,Fc): window
However, for a specification of '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
If the user additionally has the DSP System Toolbox installed, the number of available algorithms for this response and specification string increases:
>>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
The user chooses a particular algorithm and implements the filter with the design function.
>>Hd=design(d,'butter');
The preceding code actually creates the filter, where Hd is the filter Implementation Object. This concept is discussed further in the next step.
If you do not perform this step explicitly, design automatically 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 Select an Algorithm, but also on the specification selected in Select a Specification. To explore all the available options, type the following at the MATLAB command prompt:
help (d, 'algorithm-name')
where 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 Design 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.
This next task introduces a new object, the Filter Object, or dfilt. To create a filter, use the design command:
>> % design filter w/o specifying the algorithm >> Hd = design(d);
where Hd is the Filter Object and 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 Select an Algorithm, use the same design command, but specify the Butterworth algorithm as follows:
>> Hd = design(d, 'butter');
where Hd is the new Filter Object, and d is the Specifications Object.
To obtain help and see all the available options, type:
>> help fdesign/design
This help command describes not only the options for the 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') f = FilterStructure: 'Direct-Form II, Second-Order Sections' Arithmetic: 'double' sosMatrix: [7x6 double] ScaleValues: [8x1 double] PersistentMemory: false
The filter design step, just like the first task of choosing a response, must be performed explicitly. A Filter Object is created only when 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
To display help for analysis of a multirate filter, type:
>> help mfilt/functions
To analyze your filter, you must explicitly perform this step.
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)
This step is never automatically performed for you. To filter your data, you must explicitly execute this step. To understand how the filtering commands work, type:
>> help dfilt/filter