带通滤波器的matlab解释 [英] Bandpass filter matlab explanation

查看:244
本文介绍了带通滤波器的matlab解释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解带通滤波器,并且理解了这个理论或者基本思想。然而,我一直在尝试使用下面的代码,但是能够完全理解它,并将其模拟到我想要的工作状态。

  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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆