This example shows how to use Filter Designer as a convenient alternative to the command-line filter design functions.
Filter Designer is a powerful graphical user interface (GUI) in Signal Processing Toolbox™ for designing and analyzing filters.
Filter Designer enables you to quickly design digital FIR or IIR filters by setting filter performance specifications, by importing filters from your MATLAB® workspace or by adding, moving, or deleting poles and zeros. Filter Designer also provides tools for analyzing filters, such as magnitude and phase response plots and pole-zero plots.
filterDesigner at the MATLAB command prompt:
A Tip of the Day dialog displays with suggestions for using Filter Designer. Then, the GUI displays with a default filter.
The GUI has three main regions:
The Current Filter Information region
The Filter Display region and
The Design panel
The upper half of the GUI displays information on filter specifications and responses for the current filter. The Current Filter Information region, in the upper left, displays filter properties, namely the filter structure, order, number of sections used and whether the filter is stable or not. It also provides access to the Filter manager for working with multiple filters.
The Filter Display region, in the upper right, displays various filter responses, such as, magnitude response, group delay and filter coefficients.
The lower half of the GUI is the interactive portion of Filter Designer. The Design Panel, in the lower half is where you define your filter specifications. It controls what is displayed in the other two upper regions. Other panels can be displayed in the lower half by using the sidebar buttons.
The tool includes Context-sensitive help. You can right-click or click the What's This? button to get information on the different parts of the tool.
We will design a low pass filter that passes all frequencies less than or equal to 20% of the Nyquist frequency (half the sampling frequency) and attenuates frequencies greater than or equal to 50% of the Nyquist frequency. We will use an FIR Equiripple filter with these specifications:
Passband attenuation 1 dB
Stopband attenuation 80 dB
A passband frequency 0.2 [Normalized (0 to 1)]
A stopband frequency 0.5 [Normalized (0 to 1)]
To implement this design, we will use the following specifications:
1. Select Lowpass from the dropdown menu under Response Type and Equiripple under FIR Design Method. In general, when you change the Response Type or Design Method, the filter parameters and Filter Display region update automatically.
2. Select Specify order in the Filter Order area and enter 30.
3. The FIR Equiripple filter has a Density Factor option which controls the density of the frequency grid. Increasing the value creates a filter which more closely approximates an ideal equiripple filter, but more time is required as the computation increases. Leave this value at 20.
4. Select Normalized (0 to 1) in the Units pull down menu in the Frequency Specifications area.
5. Enter 0.2 for wpass and 0.5 for wstop in the Frequency Specifications area.
6. Wpass and Wstop, in the Magnitude Specifications area are positive weights, one per band, used during optimization in the FIR Equiripple filter. Leave these values at 1.
7. After setting the design specifications, click the Design Filter button at the bottom of the GUI to design the filter.
The magnitude response of the filter is displayed in the Filter Analysis area after the coefficients are computed.
Once you have designed the filter, you can view the following filter analyses in the display window by clicking any of the buttons on the toolbar:
In order from left to right, the buttons are
Magnitude and Phase responses
Group delay response
Phase delay response
You can change the x- or y-axis units by right-clicking the mouse on an axis label and selecting the desired units. The current units have a check mark.
In the Display region, you can click on any point in the plot to add a data marker, which displays the values at that point. Right-clicking on the data marker displays a menu where you can move, delete or adjust the appearance of the data markers.
To minimize the cost of implementation of the filter, we will try to reduce the number of coefficients by using Minimum Order option in the design panel.
Change the selection in Filter Order to Minimum Order in the Design Region and leave the other parameters as they are.
Click the Design Filter button to design the new filter.
As you can see in the Current Filter Information area, the filter order decreased from 30 to 16, the number of ripples decreased and the transition width became wider. The passband and the stopband specifications still meet the design criteria.
By right-clicking on the plot and selecting Analysis Parameters, you can display a dialog box for changing analysis-specific parameters. (You can also select Analysis Parameters from the Analysis menu.)
To save the displayed parameters as the default values, click Save as Default. To restore the MATLAB-defined default values, click Restore Original Defaults.
Once you are satisfied with your design, you can export your filter to the following destinations:
Select Export from the File menu.
When you choose to export to the MATLAB workspace or to a MAT-file, you can export the filter as coefficients. If a DSP System Toolbox™ is available you can also export your filter as a System object.
Filter Designer allows you to generate MATLAB code to re-create your filter. This enables you to embed your design into existing code or automate the creation of your filters in a script.
Select Generate MATLAB code from the File menu, choose Filter Design Function and specify the filename in the Generate MATLAB code dialog box.
The following code was generated from the minimum order filter we designed above:
If you have the DSP System Toolbox™ installed, the Set quantization parameters panel is available on the sidebar:
You can use this panel to quantize and analyze double-precision filters. With the DSP System Toolbox you can quantize from double-precision to single-precision. If you have the Fixed-Point Designer, you can quantize filters to fixed-point precision. Note that you cannot mix floating-point and fixed-point arithmetic in your filter.
The Targets menu of Filter Designer allows you to generate various types of code representing your filter. For example, you can generate C header files, XILINX coefficients(COE) files (with the DSP System Toolbox) and VHDL, Verilog along with test benches (with Filter Design HDL Coder™).
Filter Designer also integrates additional functionality from these other MathWorks™ products:
DSP System Toolbox- Adds advanced FIR and IIR design techniques (i.e. Filter transformations, Multirate filters) and generates equivalent block for the filter
Embedded Coder™- Generates, builds and deploys code for Texas Instruments C6000 processors.
Filter Design HDL Coder- Generates synthesizable VHDL or Verilog code for fixed-point filters
Simulink®- Generates filters from atomic Simulink blocks