I am software engineer studying DSP on my own. I came across this question in a graduate textbook and am not sure how to proceed.

Determine the frequency response for the filter:
H(z) = 1.5 / (1 + 3z^-1)

Clearly, this is a z-domain transfer function. How do I get the frequency response? I am thinking of converting it into a time-domain difference equation, calculating about 128 points, running it through MATLAB's FFT, plot it, and voila, the final curve would be the answer. Is that a right approach? Is there a more analytic/math-y answer?


The analytic way is to substitute the variable $z$ by $e^{j\omega}$ to get the frequency response $H(\omega)$ (with $\omega = \frac{2 \pi f}{F_s}$) - that is to say, the frequency response is the $z$ transform evaluated on the unit circle.

Note that matlab has a built-in function for plotting the frequency response straight from filter coefficients (freqz), whose source code can be seen. Have a look! The implementation does not even involve solving the difference equation or filtering an impulse - you can simply divide the FFT of the numerator sequence by the FFT of the denominator sequence - padded up to the desired number of frequency points.

  • $\begingroup$ How do you see the source code in Matlab? The other day I was looking for the implementation of fir1() but could not find it. $\endgroup$ – stackoverflowuser2010 May 15 '13 at 23:28
  • $\begingroup$ Type edit <functionname> from the command line. This only works for functions which are implemented as .m files (as opposed to built-in primitives). $\endgroup$ – pichenettes May 15 '13 at 23:46
  • $\begingroup$ Thanks. Going back to my original question, my approach (figuring out the difference equation, computing points, and plotting the FFT result) should give me the same result as freqz(), right? $\endgroup$ – stackoverflowuser2010 May 16 '13 at 1:12
  • $\begingroup$ Yes it would work. $\endgroup$ – pichenettes May 16 '13 at 7:01

First of all, your transfer function has a pole at $z=-3$, which means your filter is unstable and you will probably see your output going to infinity if your process anything with it.

However, in general, you can process an impulse with your difference equation and do an FFT (or freqz) of the resulting impulse response. That should give the same result as freqz of the transfer function (if your filter is not unstable).

You can also process an arbitrary input and determine the frequency response of the filter by taking the ratio of the frequency response of the output and frequency response of the input. If you do this by FFT then dependent on your filter choosing a window function can be important. If you get strange results then try a triangular or parzen window (they have less leakage than other common windows).

Edit: Maybe, in the first place, the idea of using an unstable filter is to prevent the use of your method (filtering some samples) to compute the frequency response. Although, the filter is unstable it gives a perfectly fine frequency response that doesn't 'blow up' because the pole is not actually directly on or in the near vicinity to the unit cirle if you use freqz or if you do it analytically. E.g

$|H(e^{j\omega})|^2 = H(e^{j\omega}) H^*(e^{j\omega}) = H(e^{j\omega}) H(e^{-j\omega}) = \frac{b^2}{1+a^2+2a\cos(\omega)}$ , where $b=1.5$ and $a=3$

You can't really tell from this expression that the underlying filter is unstable. But let's say that you 'like' the frequency response of this transfer function, is it then possible to find another transfer function which has exactly the same frequency response (amplitude response) but with pole(s) inside the unit circle?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.