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));
![](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
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!