Plotting the frequency response of a bandpass filter around a frequency fc

4 次查看(过去 30 天)
Hello, Im trying to get a plot of a bandpass filter for which I already have the h[n] expression, but Im plotting it in the range [-pi, pi] and that doesn't seem to accurately show the desired central frequency of the filter, and attempting to plot it between values like [-4000, 4000] led to a plot that was impossible to make anything out of. Ideally, I would have an easily readable plot, where finding the frequency around which the bandpass is functioning is easy, and in the x axis I would have a range of values in Hz. This is what I got:
w = -pi: 2*pi/120: pi
fc = 1477
fs = 8192
L = 40
n = 0:L-1
hn = (2/L)*cos((2*pi*fc*n)/fs)
H = freqz (hn, 1, w)
plot(w, abs(H));
Notice that the x axis goes from -pi to pi, and unless I've made a mistake somewhere else, I think thats why Im not getting a peak of the frequency response on fc = 1477. fs is the sampling frequency, L is the filter order

采纳的回答

Paul
Paul 2022-11-21
编辑:Paul 2022-11-21
The code as implemented uses the form of freqz with the w input in normalized frequency in units of rad. The w vector on input ranges from -pi to pi. To convert rad to Hz, fHz = w*fs//2/pi.
w = -pi: 2*pi/120: pi;
fc = 1477;
fs = 8192;
L = 40;
n = 0:L-1;
hn = (2/L)*cos((2*pi*fc*n)/fs);
H = freqz (hn, 1, w);
plot(w*fs/2/pi, abs(H));
xline(1477)
xline(-1477)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by