Plotting the frequency response of a bandpass filter around a frequency fc
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Juan Carlos Pérez Novoa
le 21 Nov 2022
Modifié(e) : Paul
le 21 Nov 2022
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));
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1201653/image.png)
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
0 commentaires
Réponse acceptée
Paul
le 21 Nov 2022
Modifié(e) : Paul
le 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)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multirate Signal Processing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!