DSP Blockset    

Implementing Predesigned Filters with the Digital Filter Block

The Digital Filter block in the Filter Designs library is useful for implementing a predesigned filter whose coefficients you already know. (If you want to first design a filter and then implement it, see Filter Design, Analysis, and Implementation with the Digital Filter Design Block.) The block is ideal for simulating the numerical behavior of your filter on a single- or double-precision floating-point system, such as a personal computer or DSP chip. The block also generates highly-optimized Real-Time Workshop C code for use in floating-point embedded systems.

Required Filter Parameters for Using the Digital Filter Block.   To implement a filter with the Digital Filter block, you must provide the following basic information about the filter:

Related Topics.   For more information, see Examples and Other Related Topics in the topic on implementing predesigned filters.

Example: Using the Digital Filter Block to Implement a Predesigned Filter

In the following model, a lowpass filter filters out high-frequency noise from a noisy sine wave. The high-frequency noise is output by a highpass filter excited by a uniform random signal.

Digital Filter blocks implement both the lowpass and highpass filters, which were predesigned elsewhere (perhaps at the MATLAB command line, or in a Digital Filter Design block). The Vector Scope's display (see Figure , Vector Scope Display After Running the Model,) shows the original sine wave, the noisy sine wave, and the filtered noisy sine wave for comparison.

Model Using the Digital Filter Block to Implement Filters

Vector Scope Display After Running the Model

To build the model yourself, complete the following steps:

Note that the above model is almost identical to the example model in Example: Using the Digital Filter Design Block to Design, Analyze, and Implement a Filter. The only difference is that in this model, Digital Filter blocks implement the filters (rather than Digital Filter Design blocks). Given the same filter design, both blocks implement the filter identically and behave the same in both simulation and code generation. The difference between the blocks is not their filter implementation capabilities, but the manner in which you specify the filter to implement: in the Digital Filter block, you must type in the filter coefficients, whereas in the Digital Filter Design block, you design the filter using a GUI.


  Implementing Predesigned Filters Step 1 -- Get the Coefficients of the Predesigned Filters