• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

[Matlab]四种IIR滤波器纹波特性对比

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

测试代码:

%FilterCompare.m
%对比相同阶数时四种IIR滤波器的波纹特性


close all;
clear;
clc;


fs = 1000; %Hz


%低通滤波器对比
N1 = 8;
wp = 50 / ( fs / 2);
ws = 100 / ( fs / 2);
alpha_p = 1;
alpha_s = 20;

[ b1,a1] = butter( N1 , ws , 'low' );
[ b2,a2] = cheby1( N1 , alpha_p , ws , 'low' );
[ b3,a3] = cheby2( N1 , alpha_s , ws , 'low' );
[ b4,a4] = ellip ( N1 , alpha_p,alpha_s , ws , 'low' );



[H1,w1] = freqz(b1,a1,1024*4);
[H2,w2] = freqz(b2,a2,1024*4);
[H3,w3] = freqz(b3,a3,1024*4);
[H4,w4] = freqz(b4,a4,1024*4);
w1 = w1/pi *fs/2;
w2 = w2/pi *fs/2;
w3 = w3/pi *fs/2;
w4 = w4/pi *fs/2;
figure(1);
plot(w1,abs(H1),'black','linewidth',0.5);
hold on;
plot(w2,abs(H2),'red','linewidth',0.5);
plot(w3,abs(H3),'green','linewidth',0.5);
plot(w4,abs(H4),'blue','linewidth',0.5);
xlim([0 500]);
ylim([0 1.1]);
legend({ 'butter' , 'cheby1' , 'cheby2' , 'ellip'});
title('同阶数(N=8),同截止频率(f_c=100Hz)的低通滤波器对比');


%高通滤波器
N1 = 8;
wp = 400 / ( fs / 2);
ws = 400 / ( fs / 2);
alpha_p = 1;
alpha_s = 20;
[ b1,a1] = butter( N1 , ws , 'high' );
[ b2,a2] = cheby1( N1 , alpha_p , ws , 'high' );
[ b3,a3] = cheby2( N1 , alpha_s , ws , 'high' );
[ b4,a4] = ellip( N1 , alpha_p,alpha_s , ws , 'high' );
[H1,w1] = freqz(b1,a1,1024*4);
[H2,w2] = freqz(b2,a2,1024*4);
[H3,w3] = freqz(b3,a3,1024*4);
[H4,w4] = freqz(b4,a4,1024*4);
w1 = w1/pi *fs/2;
w2 = w2/pi *fs/2;
w3 = w3/pi *fs/2;
w4 = w4/pi *fs/2;
figure(2);
plot(w1,abs(H1),'black','linewidth',0.5);
hold on;
plot(w2,abs(H2),'red','linewidth',0.5);
plot(w3,abs(H3),'green','linewidth',0.5);
plot(w4,abs(H4),'blue','linewidth',0.5);
xlim([0 500]);
ylim([0 1.1]);
legend({ 'butter' , 'cheby1' , 'cheby2' , 'ellip'});
title('同阶数(N=8),同截止频率(f_c=400Hz)的高通滤波器对比');



%带通滤波器

N1 = 8;
wp = [ 100 , 400 ] / ( fs / 2);
ws = [ 100 , 400 ] / ( fs / 2);
alpha_p = 1;
alpha_s = 20;
[ b1,a1] = butter( N1 , ws , 'bandpass' );
[ b2,a2] = cheby1( N1 , alpha_p , ws , 'bandpass' );
[ b3,a3] = cheby2( N1 , alpha_s , ws , 'bandpass' );
[ b4,a4] = ellip( N1 , alpha_p,alpha_s , ws , 'bandpass' );
[H1,w1] = freqz(b1,a1,1024*4);
[H2,w2] = freqz(b2,a2,1024*4);
[H3,w3] = freqz(b3,a3,1024*4);
[H4,w4] = freqz(b4,a4,1024*4);
w1 = w1/pi *fs/2;
w2 = w2/pi *fs/2;
w3 = w3/pi *fs/2;
w4 = w4/pi *fs/2;
figure(3);
plot(w1,abs(H1),'black','linewidth',0.5);
hold on;
plot(w2,abs(H2),'red','linewidth',0.5);
plot(w3,abs(H3),'green','linewidth',0.5);
plot(w4,abs(H4),'blue','linewidth',0.5);
xlim([0 500]);
ylim([0 1.1]);
legend({ 'butter' , 'cheby1' , 'cheby2' , 'ellip'});
title('同阶数(N=8),同截止频率(f_c_1=100Hz f_c_2 = 400Hz)的带通滤波器对比');



%带阻滤波器
N1 = 8;
wp = [ 100 , 400 ] / ( fs / 2);
ws = [ 100 , 400 ] / ( fs / 2);
alpha_p = 1;
alpha_s = 20;
[ b1,a1] = butter( N1 , ws , 'stop' );
[ b2,a2] = cheby1( N1 , alpha_p , ws , 'stop' );
[ b3,a3] = cheby2( N1 , alpha_s , ws , 'stop' );
[ b4,a4] = ellip( N1 , alpha_p,alpha_s , ws , 'stop' );
[H1,w1] = freqz(b1,a1,1024*4);
[H2,w2] = freqz(b2,a2,1024*4);
[H3,w3] = freqz(b3,a3,1024*4);
[H4,w4] = freqz(b4,a4,1024*4);
w1 = w1/pi *fs/2;
w2 = w2/pi *fs/2;
w3 = w3/pi *fs/2;
w4 = w4/pi *fs/2;
figure(4);
plot(w1,abs(H1),'black','linewidth',0.5);
hold on;
plot(w2,abs(H2),'red','linewidth',0.5);
plot(w3,abs(H3),'green','linewidth',0.5);
plot(w4,abs(H4),'blue','linewidth',0.5);
xlim([0 500]);
ylim([0 1.1]);
legend({ 'butter' , 'cheby1' , 'cheby2' , 'ellip'});
title('同阶数(N=8),同截止频率(f_c_1=100Hz f_c_2 = 400Hz)的带阻滤波器对比');

  

现象:

低通滤波器

高通滤波器

带通滤波器

带阻滤波器

 

验证结果:

1、巴特沃斯滤波器的通带和阻带均是单调变化,频率响应最为平滑,若通带边缘满足指标要求,则通带内会有富余量,并不经济,更有效的方法是将指标的精度要求均匀分布在通带或阻带内,这样能设计出阶数较低的滤波器(意会,意会);

2、切比雪夫Ⅰ型滤波器的幅度特性在通带范围内是等波纹的,在阻带范围内时单调的;

3、切比雪夫Ⅱ型滤波器的幅度特性在阻带范围内是等波纹的,在通带范围内时单调的;

4、椭圆滤波器的幅度特性在通带和阻带范围内均是等波纹的。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
delphi的取整函数round、trunc、ceil和floor发布时间:2022-07-18
下一篇:
UniCode问题的探讨,终于解决了编码的问题。--Delphi发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap