声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1808|回复: 5

[滤波] 我编了个滤波器,滤波效果很差,哪位能指点一下怎么修改?

[复制链接]
发表于 2010-9-12 10:19 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
我编了个滤波器,滤波效果很差,哪位能指点一下怎么修改?问题出在哪?
%滤波器设计
%x=sin(2*pi*5*t)+2*sin(2*pi*10*t)+randn(size(t))
clc;clear;
fs=1000;
t=0:1/fs:2;
x=sin(2*pi*5*t)+2*sin(2*pi*10*t)+randn(size(t));
fcuts=[3 4 6 7 8 9 11 12];
mags=[0 1 0 1 0];
devs=[0.01 0.01 0.01 0.01 0.01];
[n,wn,beta,ftype]=kaiserord(fcuts,mags,devs,fs);
b=fir1(n,wn,ftype,kaiser(n+1,beta),'scale');
h=filter(b,1,x);
subplot(211)
plot(t,x);
subplot(212)
plot(t,h);
untitled.jpg
回复
分享到:

使用道具 举报

 楼主| 发表于 2010-9-12 10:54 | 显示全部楼层
用其他方法了一个,效果更差了。请哪位高手指正一下。
另外,这种多通带滤波,应该首选什么方法?
clc;clear;
fs=1000
t=0:1/fs:2;
x=sin(2*pi*5*t)+2*sin(2*pi*10*t)+randn(size(t));
wn1=[0.008 0.022];
wn2=[0.012 0.018];
[b,a]=butter(34,wn1,'bandpass');  %频率4到11带通
x1=filter(b,a,x);
[n,m]=butter(34,wn2,'stop');    %频率6到9带阻
x2=filter(n,m,x1);
subplot(311)
plot(t,x);
subplot(312)
plot(t,x1);
subplot(313)
plot(t,x2);
我是个新手,望哪位高手指点一下,急!!
untitled.jpg
发表于 2010-10-12 16:31 | 显示全部楼层
帮顶,嘿嘿……
发表于 2010-10-12 20:10 | 显示全部楼层
那位高手看看,指点一下啊,关注中。
发表于 2010-10-12 20:38 | 显示全部楼层
好像是有问题。滤波效果不好。
发表于 2010-10-12 21:09 | 显示全部楼层

其主要原因是滤波器的要求很高,采样频率1000Hz,在5和10Hz附近有2个带通滤波器,所以计算出来的滤波器阶数为N=2234阶,滤波器的延迟为N/2,所以将有1117个样点的延迟,这便使滤波后的波形要在1117个样点后才有输出。解决方法是考虑了信号的延迟,我把程序修改如下:
fs=1000;
t=0:1/fs:3;
x=sin(2*pi*5*t)+2*sin(2*pi*10*t)+randn(size(t));
fcuts=[3 4 6 7 8 9 11 12];
mags=[0 1 0 1 0];
devs=[0.01 0.01 0.01 0.01 0.01];
[n,wn,beta,ftype]=kaiserord(fcuts,mags,devs,fs);
b=fir1(n,wn,ftype,kaiser(n+1,beta),'scale');
h=filter(b,1,x);
subplot(211)
plot(t(1:1500),x(1:1500)); ylim([-5 5]); grid;
subplot(212)
plot(t(1118:2617),h(1118:2617)); xlim([1118/fs 2617/fs]); grid;
这样滤波器输出和输入就对应起来了。
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-21 21:53 , Processed in 0.091189 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表