Documentation 
On this page… 

Overview of the Digital Filter Design Block Create a Lowpass Filter in Simulink 
You can use the Digital Filter Design block to design and implement a digital filter. The filter you design can filter singlechannel or multichannel signals. The Digital Filter Design block is ideal for simulating the numerical behavior of your filter on a floatingpoint system, such as a personal computer or DSP chip. You can use the Simulink^{®} Coder™ product to generate C code from your filter block. For more information on generating C code from models, see Understanding C Code Generation.
You perform all filter design and analysis within the Filter Design and Analysis Tool (FDATool) GUI, which opens when you doubleclick the Digital Filter Design block. FDATool provides extensive filter design parameters and analysis tools such as polezero and impulse response plots.
Once you have designed your filter using FDATool, the block automatically realizes the filter using the filter structure you specify. You can then use the block to filter signals in your model. You can also finetune the filter by changing the filter specification parameters during a simulation. The outputs of the Digital Filter Design block numerically match the outputs of the DSP System Toolbox™ filter function and the MATLAB^{®} filter function.
The Digital Filter Design block allows you to save the filters you design, export filters (to the MATLAB workspace, MATfiles, etc.), and import filters designed elsewhere.
To learn how to save your filter designs, see Saving and Opening Filter Design Sessions in the Signal Processing Toolbox™ documentation. To learn how to import and export your filter designs, see Import and Export Quantized Filters.
Note: You can use the Digital Filter Design block to design and implement a filter. To implement a predesigned filter, use the Discrete FIR Filter or Biquad Filter blocks. Both methods implement a filter design in the same manner and have the same behavior during simulation and code generation. 
See the Digital Filter Design block reference page for more information. For information on choosing between the Digital Filter Design block and the Filter Realization Wizard, see Select a Filter Design Block.
This section explains the similarities and differences between the Digital Filter Design and Filter Realization Wizard blocks.
The Digital Filter Design block and Filter Realization Wizard are similar in the following ways:
Filter design and analysis options — Both blocks use the Filter Design and Analysis Tool (FDATool) GUI for filter design and analysis.
Output values — If the output of both blocks is doubleprecision floating point, singleprecision floating point, or fixed point, the output values of both blocks numerically match the output of the filter method of the dfilt object.
The Digital Filter Design block and Filter Realization Wizard handle the following things differently:
Supported filter structures — Both blocks support many of the same basic filter structures, but the Filter Realization Wizard supports more structures than the Digital Filter Design block. This is because the block can implement filters using Sum, Gain, and Delay blocks. See the Filter Realization Wizard and Digital Filter Design block reference pages for a list of all the structures they support.
Data type support — The Filter Realization Wizard block supports single and doubleprecision floatingpoint computation for all filter structures and fixedpoint computation for some filter structures. The Digital Filter Design block only supports single and doubleprecision floatingpoint computation.
Block versus Wizard — The Digital Filter Design block is the filter itself, but the Filter Realization Wizard block just enables you to create new filters and put them in an existing model. Thus, the Filter Realization Wizard is not a block that processes data in your model, it is a wizard that generates filter blocks (or subsystems) which you can then use to process data in your model.
The following are specific situations where only the Digital Filter Design block or the Filter Realization Wizard is appropriate.
Digital Filter Design
Use to simulate single and doubleprecision floatingpoint filters.
Use to generate highly optimized ANSI^{®} C code that implements floatingpoint filters for embedded systems.
Filter Realization Wizard
Use to simulate numerical behavior of fixedpoint filters in a DSP chip, a fieldprogrammable gate array (FPGA), or an applicationspecific integrated circuit (ASIC).
Use to simulate single and doubleprecision floatingpoint filters with structures that the Digital Filter Design block does not support.
Use to visualize the filter structure, as the block can build the filter from Sum, Gain, and Delay blocks.
Use to rapidly generate multiple filter blocks.
See Filter Realization Wizard and the Filter Realization Wizard block reference page for information.
You can use the Digital Filter Design block to design and implement a digital FIR or IIR filter. In this topic, you use it to create an FIR lowpass filter:
From the DSP System Toolbox Filtering library, and then from the Filter Implementations library, clickanddrag a Digital Filter Design block into your model.
Doubleclick the Digital Filter Design block.
The Filter Design and Analysis Tool (FDATool) GUI opens.
Set the parameters as follows, and then click OK:
Response Type = Lowpass
Design Method = FIR, Equiripple
Filter Order = Minimum order
Units = Normalized (0 to 1)
wpass = 0.2
wstop = 0.5
Click Design Filter at the bottom of the GUI to design the filter.
Your Digital Filter Design block now represents a filter with the parameters you specified.
From the Edit menu, select Convert Structure.
The Convert Structure dialog box opens.
The Digital Filter Design block now represents a lowpass filter with a DirectForm FIR Transposed structure. The filter passes all frequencies up to 20% of the Nyquist frequency (half the sampling frequency), and stops frequencies greater than or equal to 50% of the Nyquist frequency as defined by the wpass and wstop parameters. In the next topic, Create a Highpass Filter in Simulink, you use a Digital Filter Design block to create a highpass filter. For more information about implementing a predesigned filter, see Digital Filter Implementations.
In this topic, you create a highpass filter using the Digital Filter Design block:
If the model you created in Create a Lowpass Filter in Simulink is not open on your desktop, you can open an equivalent model by typing
ex_filter_ex4
at the MATLAB command prompt.
From the DSP System Toolbox Filtering library, and then from the Filter Implementations library, clickanddrag a second Digital Filter Design block into your model.
Doubleclick the Digital Filter Design block.
The Filter Design and Analysis Tool (FDATool) GUI opens.
Set the parameters as follows:
Response Type = Highpass
Design Method = FIR, Equiripple
Filter Order = Minimum order
Units = Normalized (0 to 1)
wstop = 0.2
wpass = 0.5
Click the Design Filter button at the bottom of the GUI to design the filter.
Your Digital Filter Design block now represents a filter with the parameters you specified.
In the Edit menu, select Convert Structure.
The Convert Structure dialog box opens.
The block now implements a highpass filter with a direct form FIR transpose structure. The filter passes all frequencies greater than or equal to 50% of the Nyquist frequency (half the sampling frequency), and stops frequencies less than or equal to 20% of the Nyquist frequency as defined by the wpass and wstop parameters. This highpass filter is the opposite of the lowpass filter described in Create a Lowpass Filter in Simulink. The highpass filter passes the frequencies stopped by the lowpass filter, and stops the frequencies passed by the lowpass filter. In the next topic, Filter HighFrequency Noise in Simulink, you use these Digital Filter Design blocks to create a model capable of removing high frequency noise from a signal. For more information about implementing a predesigned filter, see Digital Filter Implementations.
In the previous topics, you used Digital Filter Design blocks to create FIR lowpass and highpass filters. In this topic, you use these blocks to build a model that removes high frequency noise from a signal. In this model, you use the highpass filter, which is excited using a uniform random signal, to create highfrequency noise. After you add this noise to a sine wave, you use the lowpass filter to filter out the highfrequency noise:
If the model you created in Create a Highpass Filter in Simulink is not open on your desktop, you can open an equivalent model by typing
ex_filter_ex5
at the MATLAB command prompt.
Clickanddrag the following blocks into your model.
Block  Library  Quantity 

Add  Simulink Math Operations library  1 
Random Source  Sources  1 
Sine Wave  Sources  1 
Time Scope  Sinks  1 
Set the parameters for these blocks as indicated in the following table. Leave the parameters not listed in the table at their default settings.
Parameter Settings for the Other Blocks
Block  Parameter Setting 

Add 

Random Source 

Sine Wave 

Time Scope 

Connect the blocks as shown in the following figure. You might need to resize some of the blocks to accomplish this task.
From the Simulation menu, select Model Configuration Parameters.
The Configuration Parameters dialog box opens.
In the Solver pane, set the parameters as follows, and then click OK:
Start time = 0
Stop time = 5
Type = Fixedstep
Solver = Discrete (no continuous states)
In the model window, from the Simulation menu, choose Run.
The model simulation begins and the scope displays the three input signals.
After simulation is complete, select View > Legend from the Time Scope menu. The legend appears in the Time Scope window. You can clickanddrag it anywhere on the scope display. To change the channel names, doubleclick inside the legend and replace the default channel names with the following:
Add = Noisy Sine Wave
Digital Filter Design – Lowpass = Filtered Noisy Sine Wave
Sine Wave = Original Sine Wave
In the next step, you will set the color, style, and marker of each channel.
In the Time Scope window, select View > Line Properties, and set the following:
Line  Style  Marker  Color 

Noisy Sine Wave    None  Black 
Filtered Noisy Sine Wave    diamond  Red 
Original Sine Wave  None  *  Blue 
The Time Scope display should now appear as follows:
You can see that the lowpass filter filters out the highfrequency noise in the noisy sine wave.
You have now used Digital Filter Design blocks to build a model that removes high frequency noise from a signal. For more information about these blocks, see the Digital Filter Design block reference page. For information on another block capable of designing and implementing filters, see Filter Realization Wizard. To learn how to save your filter designs, see Saving and Opening Filter Design Sessions in the Signal Processing Toolbox documentation. To learn how to import and export your filter designs, see Import and Export Quantized Filters in the DSP System Toolbox documentation.