matlab butter stop,Matlab butter函数设计滤波器

butter函数:巴特沃斯模拟和数字滤波器设计

详细解释如下:

butter Butterworth digital and analog filter design.

[B,A] = butter(N,Wn) designs

an Nth order lowpass digital

Butterworth filter and returns

the filter coefficients in length

N+1 vectors B (numerator) and

A (denominator). The coefficients

are listed in descending

powers of z. The cutoff frequency

Wn must be 0.0

< Wn < 1.0, with 1.0 corresponding

to

half the sample rate.

If Wn is a two-element

vector, Wn = [W1 W2], butter returns an

order 2N bandpass filter with

passband W1 < W <

W2.

[B,A] = butter(N,Wn,'high')

designs a highpass filter.

[B,A] = butter(N,Wn,'low')

designs a lowpass filter.

[B,A] = butter(N,Wn,'stop') is

a bandstop filter if Wn = [W1 W2].

When used with three left-hand

arguments, as in

[Z,P,K] = butter(...), the

zeros and poles are returned in

length N column vectors Z and

P, and the gain in scalar K.

When used with four

left-hand arguments, as in

[A,B,C,D] = butter(...),

state-space matrices are returned.

butter(N,Wn,'s'),

butter(N,Wn,'high','s') and butter(N,Wn,'stop','s')

design analog Butterworth

filters. In this case, Wn is in [rad/s]

and it can be greater than

1.0

需要注意的是,Wn不能大于1,Wn = 1相当于fs/2。

例1:

t = 0:0.001:1;

x = sin(t*2*pi*200)+ sin(t*2*pi);

[b,a] = butter(10,0.2);

figure(1);

freqz(b,a);

y = filter(b,a,x);

figure(2)

subplot(2,1,1);

plot(x);

subplot(2,1,2);

plot(y);

结果:

a4c26d1e5885305701be709a3d33442f.png

a4c26d1e5885305701be709a3d33442f.png

例2:生成一个采样频率为2000,由50Hz、120Hz、200Hz、正弦信号及噪声信号组成的数字信号,滤掉小于150Hz的频率,计算并显示滤波前后的原始数据波形以及功率谱密度

close all

clear all

clc

Fs=2000;

Fa=Fs/2;

N=512;

t=0:1/Fs:1;

x=2*sin(t*2*pi*50)+sin(t*2*pi*120)+3*sin(t*2*pi*200)+randn(1,length(t));

% [b,a]=butter(10,[100/Fa 150/Fa],'stop');

[b,a]=butter(10,150/Fa,'high');

figure(1);freqz(b,a);

y=filter(b,a,x);

figure(2);

subplot(2,1,1);plot(x);

subplot(2,1,2);plot(y);

figure(3);

subplot(2,1,1);

[Y,f] = Spectrum_Calc(x,Fs);

P=Y.*conj(Y)/N; plot(f,Y);

figure(3);

subplot(2,1,2);

[Y,f] = Spectrum_Calc(y,Fs);

P=Y.*conj(Y)/N; plot(f,Y);

运行结果:

a4c26d1e5885305701be709a3d33442f.png

a4c26d1e5885305701be709a3d33442f.png

fourier变换的幅频图

a4c26d1e5885305701be709a3d33442f.png

功率谱密度图,这里需要将上面的plot(f,Y);换为plot(f,P);

a4c26d1e5885305701be709a3d33442f.png

从功率谱和幅频图上看,效果是很好的。

另外我还尝试了带阻滤波器,但是效果不好,无法得到预期图像。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值