# How to plot the poles and zeros of this Bandpass Filter in MATLAB?

So I'm trying to design a band pass filter in MATLAB (with a center frequency of 10kHz and a sampling frequency of 44kHz).

I have calculated the transfer function but I'm not sure how to enter this transfer function into MATLAB to generate a plot of the frequency and phase responses of the filter, and the poles and zeros.

It could also be that the transfer function is calculated wrong? I haven't seen the denominator have so many terms before so I'm not sure..

This is my first time posting on SE, so any help is appreciated.

PS: I kinda always thought that the poles of a band pass filter would be pi/2 always, so I guess I was wrong?

You've designed a second-order band pass filter, so the number of terms in the denominator is just fine (it's a second-order polynomial). Your design is OK, apart from the scaling, i.e., the maximum of the magnitude of the transfer function is not equal to $1$, which might be desirable.

Your transfer function has the form

$$H(z)=\frac{z^2-1}{(z-p)(z-p^*)}=\frac{z^2-1}{z^2-2zr\cos(\omega_p)+r^2}\tag{1}$$

where $p$ is a complex-valued pole:

$$p=re^{j\omega_p}\tag{2}$$

with radius $r$ and pole angle $\omega_p$. Note that in general the pole angle $\omega_p$ and the peak frequency $\omega_0$ (where the magnitude of the frequency response $H(e^{j\omega})$ achieves its maximum) are not equal. However, in your case they are almost identical because $\omega_p$ is relatively close to $\pi/2$. See this answer for more details on this matter.

If you want the frequency response peak value to be equal to $1$, you need to scale your transfer function by the factor $(1-r^2)/2$ (also explained in the answer quoted above).

The pole angle $\omega_p$ depends on the desired center frequency, so it can't always be equal to $\pi/2$ as you seem to have thought (even though in your calculations you chose it according to the desired center frequency).

The Matlab function freqz computes the complex frequency response of a discrete-time filter. For plotting the poles and zeros you can use the function zplane.

• Thanks a lot for the answer, Matt! I've read over both your responses and it helped me achieve the desired result. But I'm still confused about how to find the gain factor K so the peak gain is 1. By using (1−r^2)/2, I end up getting a peak gain of less than 1. Through trial and error (changing K and looking at the graphs each time), I found the value of K should be about 0.087. Here are all of my calculations for clarity: imgur.com/a/K7Rj6xX Any ideas on what I may be doing wrong? Thanks again! – NikhilSaxena Jun 24 '18 at 18:55
• @NikhilSaxena: Your filter coefficients are correct. The problem must be in the way you plot the frequency response. – Matt L. Jun 24 '18 at 19:06
• Ah that's good to know. Thank you! I've accepted and upvoted the answer now, but since my reputation is less than 15, the upvote won't be shown publicly :) – NikhilSaxena Jun 24 '18 at 19:32