Why does the magnitude response of freqz change with the value of the input argument n?

3 views (last 30 days)
I am using the freqz command, and the second argument, n, is documented as N-point frequency response. Therefore, I take it to mean that as n gets larger, the resolution of the frequency response should get finer and more smooth. But when I run this command, this is not what happens. Instead, I see the magnitude values changing. This makes no sense, and the documentation is quite poor.

Accepted Answer

Cyrus
Cyrus on 4 Nov 2018
OH OH OHHHH, I think I found the problem. it should be the third input argument. When I had it as the second, it was changing the actual FIR filter itself!
freqz(B,1,n)

More Answers (2)

Cyrus
Cyrus on 4 Nov 2018
Edited: Cyrus on 4 Nov 2018
To be more clear, when I run freqz(B) the amplitude is nearly 1 until the cutoff, and then falls off to zero - as it should. It's a low pass filter of order 80 using fir1.
When I do freqz(B,2000), the amplitude from zero to the cutoff is now no where near 1, its down to 0.00003. This makes no sense.

Cyrus
Cyrus on 4 Nov 2018
Edited: Cyrus on 4 Nov 2018
Run this code and change freqz(B) to instead say freqz(B,2000) and see what happens:
rps2Hz = 1/(2*pi);
fs = 1000;
M = 15;
fpass = 0:0.1:fs/(2*M);
frej = fs/(2*M):0.1:fs/2;
order = 80;
wn = 1/M;
B = fir1(order,wn,hamming(order+1));
[h,w] = freqz(B);
figure(2);
plot(fs*w*rps2Hz,abs(h),'linewidth',2.0);
xlabel('freq (Hz)');
ylabel('Amplitude');

Tags

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!