How to evaluate frequency response of a filter using freqz()?
14 次查看(过去 30 天)
显示 更早的评论
I have a vector of length 25 which contains the impulse response of a filter.
I'm supposed to use freqz() to evaluate the frequency response of the filter, and plot the evaluated response with frequency in Hz and magnitude in dB.
I'm confused because freqz() can be used in two ways. If I assign it to some variables it will return the requency response vector h and the corresponding angular frequency vector w. I can then manually plot these, giving me the plot in image 1 below.
[h,w] = freqz(b,a); %here, b is the impulse response vector and a is 1
plot(h, abs(w));
But I can also call freqz() on its own and it will automatically plot the frequency response. (Image 2 below)
freqz(b,a);
Why do these plots seem to be completely different? Which one is the correct frequency response of the filter, plotted as frequency(Hz) against magnitude(dB)?


0 个评论
回答(2 个)
Paul
2021-5-18
Image 1 is plotted against against magnitude, not magnitude(dB). Just change the second input to plot() to be the db of the magnitude. Also, Image 1 is plotted against frequency whereas Image 2 is against normalized frequency. The two are related to each other by a factor of pi.
0 个评论
Star Strider
2021-5-18
This is not correct:
[h,w] = freqz(b,a); %here, b is the impulse response vector and a is 1
plot(h, abs(w));
It shouild be:
plot(w, abs(h))
so for example —
b = ones(1,3);
a = 1;
figure
freqz(b,a)
and using the output arguments —
[h,w] = freqz(b,a);
figure
subplot(2,1,1)
plot(w, mag2db(abs(h)))
grid
subplot(2,1,2)
plot(w, angle(h))
grid
Except for the normalisation from
this produces the plot from freqz.
this produces the plot from freqz. .
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Filter Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

