简体   繁体   English

带通滤波器matlab解释

[英]Bandpass filter matlab explanation

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 . 我希望X轴延伸到255,我能够使用xlim实现这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. wcw0是改变频段要改变的值,但是我无法得到我需要的频率的确切值,例如从12到250.如果你可以帮我解释,我觉得我可以完成它。

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. 您从freqz函数获得的W变量具有每个样本的弧度单位,并从0延伸到pi。 To get the frequency in Hz, you need to provide the sample rate, Fs and also the number of points you want, N. 要获得以Hz为单位的频率,您需要提供采样率,Fs以及您想要的点数N.

Replace your call to freqz with these lines: 用以下行替换你对freqz的调用:

N = 200; % 200 points in frequency vector
Fs = 100; % 100 Hz sample rate
[Happrox,W]=freqz(hBP,1, N, Fs);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM