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

4 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Paul
Paul il 21 Nov 2022
Modificato: Paul il 21 Nov 2022
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)

Più risposte (0)

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by