DSPRelated.com
Forums

How to caulate the Frequency Sample Response of IIR Filter?

Started by cweston August 3, 2015
This has probably been answered already but how does one the 'DFT' samples
of an IIR filter from the 'b' and 'a' coefficients.

For a FIR, this is trivial.

if b_n are the coefficients which are by definition finite in length.  The
DFT would be easily calculated as DFT = F*b_n  where F is the DFT matrix.


How would one specify and calculate each frequency bin amplitude and phase
for an IIR? 

(here is another case where using Matlab functions like freqz without
actually knowing what they do hurt me)


---------------------------------------
Posted through http://www.DSPRelated.com
On Mon, 03 Aug 2015 11:58:57 -0500, cweston wrote:

> This has probably been answered already but how does one the 'DFT' > samples of an IIR filter from the 'b' and 'a' coefficients. > For a FIR, this is trivial. > > if b_n are the coefficients which are by definition finite in length. > The DFT would be easily calculated as DFT = F*b_n where F is the DFT > matrix. > > > How would one specify and calculate each frequency bin amplitude and > phase for an IIR? > > (here is another case where using Matlab functions like freqz without > actually knowing what they do hurt me)
I assume you mean "how does one calculate the..." Take the transfer function H(z) in the z domain (this works for IIR or FIR). Replace z with w = exp(theta * i), where i = sqrt(-1) and theta is the frequency in radians per sample. Calculate the resulting number. This is the complex gain of the filter. If you want it in terms of real gain and phase, then convert the complex gain into its polar form. Please free yourself from the erroneous assumption that digital signal processing is about the DFT. The DFT is an important tool for some types of digital signal processing, but it's not the right place to be in during the design phase. To put the above method on a solid mathematical footing I suggest that you look at a good signal processing book, such as one of the many Oppenheim "Signals and Systems" books or similar books intended for university courses, or Rick Lyon's "Understanding Digital Signal Processing", or even my book on control systems: http://wescottdesign.com/ actfes/actfes.html. I have a short discussion of z transforms here: http://wescottdesign.com/ articles/zTransform/z-transforms.html, but it's really too brief (there's bits of it in three or four chapters of my book, mostly Chapter 2) and it's entirely oriented toward analyzing control systems so I don't go very deeply at all into the canonical IIR representations for "pure" signal processing. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
>On Mon, 03 Aug 2015 11:58:57 -0500, cweston wrote: > >> This has probably been answered already but how does one the 'DFT' >> samples of an IIR filter from the 'b' and 'a' coefficients. >> For a FIR, this is trivial. >> >> if b_n are the coefficients which are by definition finite in length. >> The DFT would be easily calculated as DFT = F*b_n where F is the DFT >> matrix. >> >> >> How would one specify and calculate each frequency bin amplitude and >> phase for an IIR? >> >> (here is another case where using Matlab functions like freqz without >> actually knowing what they do hurt me) > >I assume you mean "how does one calculate the..." > >Take the transfer function H(z) in the z domain (this works for IIR or >FIR). > >Replace z with w = exp(theta * i), where i = sqrt(-1) and theta is the >frequency in radians per sample. > >Calculate the resulting number. This is the complex gain of the filter. > >If you want it in terms of real gain and phase, then convert the complex
>gain into its polar form. > >Please free yourself from the erroneous assumption that digital signal >processing is about the DFT. The DFT is an important tool for some types
>of digital signal processing, but it's not the right place to be in >during the design phase. > >To put the above method on a solid mathematical footing I suggest that >you look at a good signal processing book, such as one of the many >Oppenheim "Signals and Systems" books or similar books intended for >university courses, or Rick Lyon's "Understanding Digital Signal >Processing", or even my book on control systems:
http://wescottdesign.com/
>actfes/actfes.html. > >I have a short discussion of z transforms here:
http://wescottdesign.com/
>articles/zTransform/z-transforms.html, but it's really too brief (there's
>bits of it in three or four chapters of my book, mostly Chapter 2) and >it's entirely oriented toward analyzing control systems so I don't go >very deeply at all into the canonical IIR representations for "pure" >signal processing. > >-- > >Tim Wescott >Wescott Design Services >http://www.wescottdesign.com
Thanks Tim. Definitely correct that caulate should read 'calculate'.
>Please free yourself from the erroneous assumption that digital signal >processing is about the DFT
But DSP really only means DFT right? No... you are very correct. And one of the problems is you get so far displaced from the roots of difference equations, you end up with a "Wiki" type knowledge of the subject. Matlab makes the situation worse where you end up looking for a canned function to do everything and forget how to do a calculation yourself. --------------------------------------- Posted through http://www.DSPRelated.com
cweston <107520@DSPRelated> wrote:

>Tim writes,
>>On Mon, 03 Aug 2015 11:58:57 -0500, cweston wrote:
>>Please free yourself from the erroneous assumption that digital signal >>processing is about the DFT
>But DSP really only means DFT right?
(I'm hoping this was, at this point, intended sarcastically.... )
>No... you are very correct. And one of the problems is you get so far >displaced from the roots of difference equations, you end up with a "Wiki" >type knowledge of the subject. Matlab makes the situation worse where you >end up looking for a canned function to do everything and forget how to do >a calculation yourself.
That certainly can be a disadvantage of any environment with a rich set of non-trivial library functions (Matlab being a relevant example). freqz() is actually one of the "safer" such functions, in that I believe the "help" page spells out exactly what it does. Note that, the freqz help page says nothing about being any sort Fourier transform; this is because it's a Laplace transform, which in uniformly sampled time becomes a Z transform. Steve
On Monday, August 3, 2015 at 5:32:23 PM UTC-4, Steve Pope wrote:
> cweston <107520@DSPRelated> wrote: > > >Tim writes, > > >>On Mon, 03 Aug 2015 11:58:57 -0500, cweston wrote: > > >>Please free yourself from the erroneous assumption that digital signal > >>processing is about the DFT > > >But DSP really only means DFT right? > > (I'm hoping this was, at this point, intended sarcastically.... ) > > >No... you are very correct. And one of the problems is you get so far > >displaced from the roots of difference equations, you end up with a "Wiki" > >type knowledge of the subject. Matlab makes the situation worse where you > >end up looking for a canned function to do everything and forget how to do > >a calculation yourself. > > That certainly can be a disadvantage of any environment with a rich > set of non-trivial library functions (Matlab being a relevant example). > > freqz() is actually one of the "safer" such functions, in that > I believe the "help" page spells out exactly what it does. > Note that, the freqz help page says nothing about being any sort > Fourier transform; this is because it's a Laplace transform, > which in uniformly sampled time becomes a Z transform. > > Steve
If he has MATLAB freqz() would be easiest. Just slightly more difficult, for appropriate N, he could compute the N-point fft of the z-transform numerator coefficients and divide point-by-point by N-point fft of the z-transform denominator coefficients, to get the frequency response (complex). No window used. Dirk
On Mon, 03 Aug 2015 12:59:46 -0500, Tim Wescott
<seemywebsite@myfooter.really> wrote:

>On Mon, 03 Aug 2015 11:58:57 -0500, cweston wrote: > >> This has probably been answered already but how does one the 'DFT' >> samples of an IIR filter from the 'b' and 'a' coefficients. >> For a FIR, this is trivial. >> >> if b_n are the coefficients which are by definition finite in length. >> The DFT would be easily calculated as DFT = F*b_n where F is the DFT >> matrix. >> >> >> How would one specify and calculate each frequency bin amplitude and >> phase for an IIR? >> >> (here is another case where using Matlab functions like freqz without >> actually knowing what they do hurt me) > >I assume you mean "how does one calculate the..." > >Take the transfer function H(z) in the z domain (this works for IIR or >FIR). > >Replace z with w = exp(theta * i), where i = sqrt(-1) and theta is the >frequency in radians per sample.
Hi, When we convert a z-transform expression to a Fourier transform expression don't we replace z with exp(w*i)? Or am I missing something here? [-Rick-]
On Mon, 03 Aug 2015 12:59:46 -0500, Tim Wescott
<seemywebsite@myfooter.really> wrote:

   [Snipped by Lyons]
> >To put the above method on a solid mathematical footing I suggest that >you look at a good signal processing book, such as one of the many >Oppenheim "Signals and Systems" books or similar books intended for >university courses, or Rick Lyon's "Understanding Digital Signal >Processing", or even my book on control systems: http://wescottdesign.com/ >actfes/actfes.html.
Hi Tim, Thanks for recommending my book. cweston may also benefit from looking at: http://www.dspguide.com/pdfbook.htm He can click on one of the Table of Contents entries on the left side of that web page, and then click on one of the line items in the center of the next page. [-Rick-]
On Sat, 08 Aug 2015 01:28:49 -0700, Rick Lyons wrote:

> On Mon, 03 Aug 2015 12:59:46 -0500, Tim Wescott > <seemywebsite@myfooter.really> wrote: > >>On Mon, 03 Aug 2015 11:58:57 -0500, cweston wrote: >> >>> This has probably been answered already but how does one the 'DFT' >>> samples of an IIR filter from the 'b' and 'a' coefficients. >>> For a FIR, this is trivial. >>> >>> if b_n are the coefficients which are by definition finite in length. >>> The DFT would be easily calculated as DFT = F*b_n where F is the DFT >>> matrix. >>> >>> >>> How would one specify and calculate each frequency bin amplitude and >>> phase for an IIR? >>> >>> (here is another case where using Matlab functions like freqz without >>> actually knowing what they do hurt me) >> >>I assume you mean "how does one calculate the..." >> >>Take the transfer function H(z) in the z domain (this works for IIR or >>FIR). >> >>Replace z with w = exp(theta * i), where i = sqrt(-1) and theta is the >>frequency in radians per sample. > > Hi, > When we convert a z-transform expression to a Fourier > transform expression don't we replace z with exp(w*i)? > Or am I missing something here? > > [-Rick-]
I think this is just a discussion of semantics, and a problem with the inadequate typesetting capabilities of plain text. I'm using the definition of w (not omega) from one of my older discrete- time control books, which defines w = exp(omega * Ts * i). But I tend to like to discard the omega and just use theta = omega * Ts. I do this because I want to rub the reader's nose in the fact that this is sampled time, which is just plain DIFFERENT from continuous time, no matter how much we'd like to pretend that we can approximate things. (This doesn't relieve one from knowing all the approximations -- it's just an attempt to keep the reader aware of which domain they're in. It's undoubtedly a symptom of deep-seated personality problems.) So w ends up being a number somewhere on the unit circle, which in sampled time is analogous to i * omega, which is somewhere on the imaginary axis. No results change -- just the symbols used in the intermediate math. -- www.wescottdesign.com