带通滤波器的matlab解释 [英] Bandpass filter matlab explanation
问题描述
clc;
关闭所有;
清除所有;
n = 0:300000;
delay = 10000;
wc = .2 * pi;
w0 = .4 * pi;
hLP =(wc / pi)* sinc((wc / pi)*(n-delay));
hBP = 2 * cos(n * w0)* hLP;
[Happrox,W] = freqz(hBP,1);
plot(W,abs(Happrox));
xlabel('频率');
ylabel('magnitude');
title('Band pass Filter');
运行此代码时,我得到了以下过滤器设计:
我想X轴扩展到255,我可以用 xlim
来实现。现在,当涉及到改变带通的频率限制时,我正面临着问题。这就是为什么我觉得我需要了解代码。请帮我解释一下。
wc
和 w0
是要修改的值如果你能帮我解释一下,我觉得我可以把它完成。
在此先感谢
从freqz函数获得的W变量每个样本的弧度单位,从0延伸到pi。为了得到频率为Hz,你需要提供采样率,Fs和你想要的点数N。
用这些行代替你的呼叫到freqz :
N = 200;频率矢量中的200个点
Fs = 100; %100 Hz采样率
[Happrox,W] = freqz(hBP,1,N,Fs);
I am trying to learn about bandpass filter, and I understood the theory, or the basic idea. However, I have been trying to work with the following code, but am able to understand it completely and mold it to the working I want it to.
clc;
close all;
clear all;
n=0:300000;
delay = 10000;
wc=.2*pi;
w0=.4*pi;
hLP=(wc/pi)*sinc((wc/pi)*(n-delay));
hBP=2*cos(n*w0).*hLP;
[Happrox,W]=freqz(hBP,1);
plot(W,abs(Happrox));
xlabel('frequency');
ylabel('magnitude');
title('Band pass Filter');
I got the following filter design when I run this code
I wanted the X axis to extended till 255 and I was able to achieve that using xlim
. Now, I am facing problems when it comes to altering the frequency limits of the bandpass. That is why I felt I need to understand the code. Please help me with an explanation.
wc
and w0
are the values to be altered for changing the frequency bands, but am not able to get the exact value of the frequency I require, for eg say from 12 to 250. If you can help me with an explanation, I feel I can get it done.
Thanks in advance
The W variable that you got from the freqz function has unites of radians per sample and extends from 0 to pi. To get the frequency in Hz, you need to provide the sample rate, Fs and also the number of points you want, N.
Replace your call to freqz with these lines:
N = 200; % 200 points in frequency vector
Fs = 100; % 100 Hz sample rate
[Happrox,W]=freqz(hBP,1, N, Fs);
这篇关于带通滤波器的matlab解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!