|On this page…|
The Filter Realization Wizard is another DSP System Toolbox™ 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 DSP System Toolbox 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 Select a Filter Design Block.
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.
noise = cos(2*pi*3*Fs/8*(0:length(mtlb)-1)/Fs)';
at the command line. You can hear the noise signal by typing
u = mtlb + noise;
at the command line.
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
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.
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.
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.
In this section of the tutorial, you will filter noise from a signal in your Simulink model.
Connect a Signal From Workspace block from the Sources library to the input port of your filter block.
Connect a Signal To Workspace block from the Sinks library to the output port of your filter block. Your blocks should now be connected as follows.
Stop time = length(u)-1
Type = Fixed-step
Click OK to save your changes and close the dialog box.
From the Display menu of the model, select Signals & Ports > Port Data Types. You can now see that the input to the Filter block is a signal of type double and the output of the Filter block has a data type of sfix16_En11.
Now you can listen to and look at the results of the fixed-point filter you designed and implemented.
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.
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:
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.
Optimize for unity scale values — Remove all scale value multiplications by 1 from the filter structure.
The following diagram illustrates the results of each of these optimizations.