[Matlab]四种IIR滤波器纹波特性对比
Posted Alimy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Matlab]四种IIR滤波器纹波特性对比相关的知识,希望对你有一定的参考价值。
测试代码:
%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、椭圆滤波器的幅度特性在通带和阻带范围内均是等波纹的。
以上是关于[Matlab]四种IIR滤波器纹波特性对比的主要内容,如果未能解决你的问题,请参考以下文章
心电信号基于matlab瞬时抑制心电信号IIR滤波含Matlab源码 1533期