I have the transfer function below which is for a IIR filter and trying to plot its frequency response for omega<pi. r=0.99 and theta=pi/3:
Here is my attempt at implementing it in MATLAB:
N=5000; W=(0:pi/(N-1):pi); r1=0.99; theta=pi/3; z= exp(j*W); num= (1-r1); den= (1-2*r1*cos(theta)*z.^(-1)+r1^(2)*z.^(-2)); TF=num./den; TFdb= 20*log10(TF); plot(W,TFdb)
Here is what I get:
Apparently it should look like this:
I am very new to this and can't tell what I'm doing wrong, would appreciate if anyone can help.