I have designed a notch filter with MATLAB filter designer app. Then I generated the filter design function which gives me the filter object:
function Hd = filter_notch Fs=500; Fnotch=50; BW=1; Apass=1; [b, a] = iirnotch(Fnotch/(Fs/2), BW/(Fs/2), Apass); Hd = dfilt.df2(b, a);
Now, I use
freqz() to plot the response. However I get 2 different responses.
Mehtod 1. Direct plot with
Method 2. Manual plot with
h=freqz(filter_object, Physical_frequencies, F_sample)
>> fs=500; >> f_range=linspace(0,fs/2,2048); >> h=freqz(filter_notch,f_range,fs); >> hdb=20*log10(abs(h)); >> plot(f_range,hdb)
you can see the notch attenuations are different with above 2 methods, roughly -25dB vs -15dB. Why is that?
From MATLAB documents:
h = freqz(___,f,fs) returns the frequency response vector, h, at the physical frequencies supplied in f.