Products & Services Solutions Academia Support User Community Company

Learn more about Signal Processing Blockset   

Filter Realization Wizard

Overview of the Filter Realization Wizard

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.

Designing and Implementing a Fixed-Point Filter

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:

Part 1 — Creating a Signal with Added Noise

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.

  1. Type

    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.

  2. 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)
  3. Add the noise to the original signal by typing

    u = mtlb + noise;

    at the command line.

  4. 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)
  5. 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.

Part 2 — Creating a Fixed-Point Filter with the Filter Realization Wizard

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.

  1. Open a new Simulink model, and drag-and-drop a Filter Realization Wizard block from the Filtering / Filter Implementations library into the model.

      Note   You do not have to place a Filter Realization Wizard block in a model in order to use it. You can open the GUI from within a library. However, for purposes of this tutorial, we will keep the Filter Realization Wizard block in the model.

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

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

  4. 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.

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

  6. 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.

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

  8. 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.

      Note   You do not have to keep the Filter Realization Wizard block in the same model as your Filter block. However, for this tutorial, we will keep the blocks in the same model.

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

Part 3 — Building a Model to Filter a Signal

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.

  1. Connect a Signal From Workspace block from the Signal Processing Sources library to the input port of your filter block.

  2. 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.

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

  4. Click the OK button.

  5. 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.

  6. Click the OK button.

  7. Run the model.

  8. 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.

Part 4 — Looking at Filtering Results

Now you can listen to and look at the results of the fixed-point filter you designed and implemented.

  1. Type

    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.

  2. Type

    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.

Setting the Filter Structure and Number of Filter Sections

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:

Optimizing the Filter Structure

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:

  1. Open the Realize Model pane of FDATool by clicking the Realize Model button in the lower-left corner of FDATool.

  2. Select the desired optimizations in the Optimization region of the Realize Model pane. See the following descriptions and illustrations of each optimization option.

The following diagram illustrates the results of each of these optimizations.

  


Related Products & Applications

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