# Calculating IIR Filter gain at given frequency

Let's consider an IIR filter with transfer function: $$H(z)$$.

Given the sampling frequency $$F_s$$ how can I calculate gain at say $$F$$ ?

When I was dealing with analog systems when I wanted to calculate gain at say $$F=0 Hz$$ (DC gain) I would simply put $$S=0$$ and I would find out what DC gain is.

Now I'm not sure if the same technique applies here.

My inital thought was to put $$z= e^{j2\pi}=1$$ into the equation but it won't work.

The problem boils down to finding $$|{H(z)}|$$ which I don't know how to do.

How can I approach this problem?

• You're on the right track... Set z = 1 In your case, the DC gain should be equal to 0.8 – Ben Jul 4 at 14:06
• Yes, I see that's right for 0Hz,but how would it be for 4000Hz? – Healow Jul 4 at 15:11
• set z = -1 as proposed in the answer below – Ben Jul 4 at 15:26
• w = 2*pi*f/fs = 2*pi*8000/4000 = 4*pi; e^j*4*pi = 1? I'm confused between 1 and -1 – Healow Jul 4 at 15:28
• Sorry I misundersootd, in that case z = 1 – Ben Jul 4 at 15:32

For continuous-time systems, you obtain the frequency response by evaluating the transfer function $$H(s)$$ on the imaginary axis $$s=j\omega$$ (assuming stability). In discrete-time, you get the $$\mathcal{Z}$$-transform instead of the Laplace transform, and the imaginary axis is replaced by the unit circle. So the frequency response is obtained by evaluating the transfer function $$H(z)$$ for $$z=e^{j\omega}$$. Note that for discrete-time systems, $$\omega$$ is a normalized frequency (in radians):

$$\omega=\frac{2\pi f}{f_s}\tag{1}$$

where $$f_s$$ is the sampling frequency.

Coming to you example, a frequency of $$8000$$ Hz with a sampling frequency of $$4000$$ Hz is the same as DC (Eq. $$(1)$$ should make that clear). Computing the frequency response at any frequency means to determine the desired $$\omega$$ from Eq. $$(1)$$, and then evaluate $$H(z)$$ with $$z=e^{j\omega}$$. In the case of DC ($$\omega=0$$) and Nyquist ($$\omega=\pi$$) this becomes especially easy: just evaluate $$H(1)$$ for DC, and $$H(-1)$$ for Nyquist.

For most other values of $$\omega$$, the frequency response is most likely complex-valued, so after computing $$H(e^{j\omega})$$ you just compute the magnitude of that complex number to obtain the gain at the given frequency. You don't need to find a general expression for $$|H(z)|$$.

• Ok, but when you say w=pi than it means e^j*pi which is -1? And you said it's like computing Z=1, but shouldn't it be -1? But when I compute with -1 i get gain of 0, is this correct? – Healow Jul 4 at 15:17
• @Healow: No, I said Nyquist ($\omega=\pi$) corresponds to $z=-1$ (and DC corresponds to $z=1$). Plugging values for $z$ into $H(z)$ should be easy enough, so I'll leave that up to you. A gain of zero is of course possible. – Matt L. Jul 4 at 15:29
• w = 2*pi*f/fs = 2*pi*8000/4000 = 4*pi; e^j*4*pi = 1? I'm confused between 1 and -1 – Healow Jul 4 at 15:30
• @Healow: If you read my answer, you'll see that I actually mention the fact that 8000 Hz with a sampling frequency of 4000 Hz is the same as DC, so $z=1$ is correct. – Matt L. Jul 4 at 15:32
• @Healow: No, you just evaluate $H(e^{j\omega})$ and then take the absolute value of the outcome. – Matt L. Jul 4 at 15:37