Skip to content Skip to navigation

OpenStax_CNX

You are here: Home » Content » IIR Filtering: Filter-Design Exercise in MATLAB

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.

Also in these lenses

  • Lens for Engineering

    This module is included inLens: Lens for Engineering
    By: Sidney Burrus

    Click the "Lens for Engineering" link to see all content selected in this lens.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

IIR Filtering: Filter-Design Exercise in MATLAB

Module by: Douglas L. Jones, Swaroop Appadwedula, Matthew Berry, Mark Haun, Jake Janovetz, Michael Kramer, Dima Moussa, Daniel Sachs, Brian Wade. E-mail the authors

Summary: You will derive the transfer function of a second-order, Direct Form II, infinite impulse response (IIR) filter. Then you will create a fourth-order IIR filter, plot its frequency response, and decompose the fourth-order filter into two second-order sections, choosing an appropriate gain for each stage to prevent overflow.

The transfer function for the second-order section shown in IIR Filtering: Introduction is

Hz=G1+ b 1 z-1+ b 2 z-21+ a 1 z-1+ a 2 z-2 H z G 1 b 1 z -1 b 2 z -2 1 a 1 z -1 a 2 z -2
(1)

Exercise

First, derive the above transfer function. Begin by writing the difference equations for wn w n in terms of the input and past values ( wn1 w n 1 and wn2 w n 2 ). Then write the difference equation for yn y n also in terms of the past samples of wn w n . After finding the two difference equations, compute the corresponding Z-transforms and use the relation Hz=YzXz=YzWzWzXz H z Y z X z Y z W z W z X z to verify the IIR transfer function in Equation 1.

Next, design the coefficients for a fourth-order filter implemented as the cascade of two bi-quad sections. Write a MATLAB script to compute the coefficients. Begin by designing the fourth-order filter and checking the response using the MATLAB commands


	  
	  [B,A] = ellip(4,.25,10,.25) 
	  freqz(B,A)
	  
	

Note:

MATLAB's freqz command displays the frequency responses of IIR filters and FIR filters. For more information about this, type help freqz. Be sure to look at MATLAB's definition of the transfer function.

Note:

If you use the freqz command as shown above, without passing its returned data to another function, both the magnitude (in decibels) and the phase of the response will be shown.

Next you must find the roots of the numerator, zeros, and roots of the denominator, poles, so that you can group them to create two second-order sections. The MATLAB commands roots and poly will be useful for this task. Save the scripts you use to decompose your filter into second-order sections; they will probably be useful later.

Once you have obtained the coefficients for each of your two second-order sections, you are ready to choose a gain factor, G G, for each section. As part of your MATLAB script, use freqz to compute the response WzXz W z X z with G=1 G 1 for each of the sets of second-order coefficients. Recall that on the DSP we cannot represent numbers greater than or equal to 1.0. If the maximum value of |WzXz| W z X z is or exceeds 1.0, an input with magnitude less than one could produce wn w n terms with magnitude greater than or equal to one; this is overflow. You must therefore select a gain values for each second-order section such that the response from the input to the states, WzXz W z X z , is always less than one in magnitude. In other words, set the value of G G to ensure that |WzXz|<1 W z X z 1 .

Preparing for processor implementation

As the processor exercises become more complex, it will become increasingly important to observe good programming practices. Of these, perhaps the most important is careful planning of your program flow, memory and register use, and testing procedure. Write out pseudo-code for the processor implementation of a bi-quad. Make sure you consider the way you will store coefficients and states in memory. Then, to prepare for testing, compute the values of wn w n and yn y n for both second-order sections at n=012 n 0 1 2 using the filter coefficients you calculated in MATLAB. Assume xn=δn x n δ n and all states are initialized to zero. You may also want to create a frequency sweep test-vector like the one in DSP Development Environment: Introductory Exercise for TI TMS320C54x and use the filter command to find the outputs for that input. Later, you can recreate these input signals on the DSP and compare the output values it calculates with those you find now. If your program is working, the values will be almost identical, differing only slightly because of quantization effects, which are considered in IIR Filtering: Filter-Coefficient Quantization Exercise in MATLAB.

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks