基于matlab的低通巴特沃斯滤波器设计与使用 matlab低通滤波器函数

1. 代码

% For data sampled at 1000 Hz, design a lowpass filter with lessthan 3 dB
% of ripple in the passband, defined from 0 to 40 Hz, and at least60 dB of
% attenuation in the stopband, defined from 150 Hz to the Nyquistfrequency
% (500 Hz). Plot the filter's frequency response and implement thisfilter
% for a 1V DC signal corrupted by noise signal given as1000*sin(2*pi*150*t)

%% Filter Design
sa =1000;fn =sa/2;% Sampling frequency (1000Hz), Nyquist frequency(500Hz)
fp =40;fs =150;% Passband (0~40Hz), Stop band(150Hz-500Hz)

Wp =fp/fn;Ws = 150/fn;% Normalized passband (40/500), stopband (150/500)
Rp =3;Rs =60;% ripple less than 3 dB, attenuation larger than 60dB

[n,Wn] = buttord(Wp,Ws,Rp,Rs); % Returns n =5; Wn=0.0810;

[b,a] =butter(n,Wn);% Designde signs an order n lowpass digital
% Butterworth filter with normalized cutoff
% frequency Wn. It returns the filter coefficients
% in length n+1 row vectors b and a, with
% coefficients in descending powers of z.
% b(1) + b(2)*z^(-1) + ... + b(n+1)*z^(-n)
% -----------------------------------------
% 1 +a(2)*z^(-1) + ... + a(n+1)*z^(-n)

freqz(b,a,512,sa);% returns the frequency response vector h and
% the corresponding frequency vector f for
% the digital filter whose transfer function
% is determined by the (real or complex) numerator
% and denominator polynomials represented in
% the vectors b and a, respectively. The vectors h
% and f are both of length n. For this syntax,
% the frequency response is calculated using the
% sampling frequency specified by the scalar fs (in hertz).
% The frequency vector f is calculated in units of hertz(Hz).
% The frequency vector f has values ranging from 0 to fs/2Hz.
title('n=5 Butterworth Lowpass Filter');

%% Filter Implementation
t =0:(1/sa):0.5;% Sampling time series at sampling frequency sa(Hz)

x = ones(1,length(t));% DC signal 1V

n = 1000 *sin(2*pi*fs*t);% Sinewave sampled at 150Hz, with magnitude 1000V.
% Note that the designed filter can suppress
% the noise signal at 150Hz -60dB, which means
基于matlab的低通巴特沃斯滤波器设计与使用 matlab低通滤波器函数
% 20*log10(1/1000) = -60dB. This noise signal noise
% should be suppressed to a sine wave with magnitude
% equal to 1.

xn = x +n;% Corrupted Signal

y = filter(b, a,xn);% Implement designed filter

figure(1);
subplot(2,1,1);
plot(t, xn);
title('Before Filter');
xlim([0.1 0.5]);
subplot(2,1,2);
plot(t, y);
title('After Filter');
xlim([0.1 0.5]);

2. 实验结果

实验结果清晰的表明,原本幅度高达1000V的噪声信号已经被抑制到1V。信号衰减60dB。当我们将
Rs设为100时,原噪声信号被进一步衰减为幅度0.01V的微弱噪声信号。

  

爱华网本文地址 » http://www.413yy.cn/a/25101011/66788.html

更多阅读

英特尔My Wifi 技术如何使用 英特尔my wifi win10

英特尔My Wifi 技术如何使用——简介英特尔My Wifi 技术是一款能够在小区域内建立无线局域网的软件,非常的使用并且非常的简单,其实共享无线的软件有很多,但是一般正版系统上都有英特尔My Wifi 技术,那么我们就直接来分享一下英特尔My W

江怡讲座:维特根斯坦的生活世界根据录音收集

维特根斯坦,英国哲学家,数理逻辑学家。分析哲学的创始人之一。维特根斯坦是二十世纪最伟大、最有影响的西方哲学家之一。他的一生,可以说就是一个哲学的传奇故事。他和苏格拉底、斯宾诺莎、萨特的一生一样,本身就构成了哲学的一部分。维

声明:《基于matlab的低通巴特沃斯滤波器设计与使用 matlab低通滤波器函数》为网友潹銥膂亽分享!如侵犯到您的合法权益请联系我们删除