| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Signal Processing Blockset |
| Contents | Index |
| Learn more about Signal Processing Blockset |
| On this page… |
|---|
Overview of the Filter Realization Wizard Designing and Implementing a Fixed-Point Filter |
The Filter Realization Wizard is another Signal Processing Blockset block that can be used to design and implement digital filters. You can use this tool to filter single-channel floating-point or fixed-point signals. Like the Digital Filter Design block, double-clicking a Filter Realization Wizard block opens FDATool. Unlike the Digital Filter Design block, the Filter Realization Wizard starts FDATool with the Realize Model panel selected. This panel is optimized for use with Signal Processing Blockset software.
For more information, see the Filter Realization Wizard block reference page. For information on choosing between the Digital Filter Design block and the Filter Realization Wizard, see Choosing Between Filter Design Blocks.
Alternatively, you can use other MathWorks products, such as Signal Processing Toolbox software and Filter Design Toolbox software, to design your filters. Once you design a filter using either toolbox, you can use one of the filter implementation blocks from Signal Processing Blockset software, such as the Digital Filter block, to realize the filters in your models. For more information, see the Signal Processing Toolbox documentation and Filter Design Toolbox documentation. To learn how to import and export your filter designs, see "Importing and Exporting Quantized Filters" in the Filter Design Toolbox documentation.
In this section, a tutorial guides you through creating a fixed-point filter with the Filter Realization Wizard. You will use the Filter Realization Wizard to remove noise from a signal. This tutorial has the following parts:
In this section of the tutorial, you will create a signal with added noise. Later in the tutorial, you will filter this signal with a fixed-point filter that you design with the Filter Realization Wizard.
load mtlb soundsc(mtlb,Fs)
at the MATLAB command line. You should hear a voice say "MATLAB." This is the signal to which you will add noise.
Create a noise signal by typing
noise = cos(2*pi*3*Fs/8*(0:length(mtlb)-1)/Fs)';
at the command line. You can hear the noise signal by typing
soundsc(noise,Fs)
Add the noise to the original signal by typing
u = mtlb + noise;
at the command line.
Scale the signal with noise by typing
u = u/max(abs(u));
at the command line. You scale the signal to try to avoid overflows later on. You can hear the scaled signal with noise by typing
soundsc(u,Fs)
View the scaled signal with noise by typing
spectrogram(u,256,[],[],Fs);colorbar
at the command line.
The spectrogram appears as follows.

In the spectrogram, you can see the noise signal as a line at about 2800 Hz, which is equal to 3*Fs/8.
Next you will create a fixed-point filter using the Filter Realization Wizard. You will create a filter that reduces the effects of the noise on the signal.
Open a new Simulink model, and drag-and-drop a Filter Realization Wizard block from the Filtering / Filter Implementations library into the model.

Double-click the Filter Realization Wizard block in your model. The Realize Model panel of the Filter Design and Analysis Tool (FDATool) appears.

Click the Design Filter button on the bottom left of FDATool. This brings forward the Design Filter panel of the tool.

Set the following fields in the Design Filter panel:
Set Design Method to IIR -- Constrained Least Pth-norm
Set Fs to Fs
Set Fpass to 0.2*Fs
Set Fstop to 0.25*Fs
Set Max pole radius to 0.8
Click the Design Filter button
The Design Filter panel should now appear as follows.

Click the Set Quantization Parameters button on the bottom left of FDATool. This brings forward the Set Quantization Parameters panel of the tool.

Set the following fields in the Set Quantization Parameters panel:
Select Fixed-point for the Filter arithmetic parameter.
Make sure the Best precision fraction lengths check box is selected on the Coefficients pane.
The Set Quantization Parameters panel should appear as follows.

Click the Realize Model button on the left side of FDATool. This brings forward the Realize Model panel of the tool.

Select the Build model using basic elements check box, then click the Realize Model button on the bottom of FDATool. A block for the new filter appears in your model.

Double-click the Filter block in your model. This will bring up the realization of the filter being represented by the block.

In this section of the tutorial, you will build and run a model with the filter you just designed, in order to filter the noise from your signal.
Connect a Signal From Workspace block from the Signal Processing Sources library to the input port of your filter block.
Connect a Signal To Workspace block from the Signal Processing Sinks library to the output port of your filter block. Your model should now appear as follows.

Change the Signal parameter of the Signal From Workspace block to u by double-clicking on the block.

Open the Configuration Parameters dialog box from the Simulation menu of the model. In the Solver pane of the dialog, set the following fields:
Stop time = length(u)-1
Type = Fixed-step
The Configuration Parameters dialog box should now appear as follows.


Select Port/Signal Displays > Port Data Types from the Format menu. You can you see that a signal of type double is entering your Filter block, and a signal of type sfix16_En11 is exiting your Filter block.
Now you can listen to and look at the results of the fixed-point filter you designed and implemented.
soundsc(yout,Fs)
at the command line to hear the output of the filter. You should hear a voice say "MATLAB." The noise portion of the signal should be close to inaudible.
figure spectrogram(yout,256,[],[],Fs);colorbar
at the command line.

From the colorbars at the side of the input and output spectrograms, you can see that the noise has been reduced by about 40 dB.
The Current Filter Information region of FDATool shows the structure and the number of second-order sections in your filter.

Change the filter structure and number of filter sections of your filter as follows:
Select Convert Structure from the Edit menu to open the Convert Structure dialog box. For details, see "Converting to a New Structure" in the Signal Processing Toolbox documentation.
Select Convert to Second-order Sections from the Edit menu to open the Convert to SOS dialog box. For details, see "Converting to Second-Order Sections" in the Signal Processing Toolbox documentation.
Note You might not be able to directly access some of the supported structures through the Convert Structure dialog of FDATool. However, you can access all of the structures by creating a dfilt filter object with the desired structure, and then importing the filter into FDATool. To learn more about the Import Filter panel, see "Importing a Filter Design" in the Signal Processing Toolbox documentation. |
The Filter Realization Wizard can implement a digital filter using a Digital Filter block or by creating a subsystem block that implements the filter using Sum, Gain, and Delay blocks. The following procedure shows you how to optimize the filter implementation:
Open the Realize Model pane
of FDATool by clicking the Realize Model button
in the lower-left corner
of FDATool.
Select the desired optimizations in the Optimization region of the Realize Model pane. See the following descriptions and illustrations of each optimization option.

Optimize for zero gains — Remove zero-gain paths.
Optimize for unity gains — Substitute gains equal to one with a wire (short circuit).
Optimize for negative gains — Substitute gains equal to -1 with a wire (short circuit), and change the corresponding sums to subtractions.
Optimize delay chains — Substitute any delay chain made up of n unit delays with a single delay by n.
The following diagram illustrates the results of each of these optimizations.

![]() | Digital Filter Design Block | Analog Filter Design Block | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |