(2)调用butter函数设计出巴特沃斯滤波器,格式为[b,a]=butter(N,Wc,options)
输入参数:
N和Wc是buttord函数返回的参数,含义见上。
Options=’low’,’high’,’bandpass’,’stop’,分别对应低通、高通、带通、带阻,默认情况下为低通或带通。
输出参数:
b和a为设计出的IIR数字滤波器H(s)的分子多项式和分母多项式的系数矩阵。
2.
(1)ChebyshevI型滤波器设计
ChebyshevI型滤波器为通带纹波控制器:
在通带呈现纹波特性,在阻带单调衰减。
[N,Wc]=cheb1ord(Wp,Ws,Ap,As)
[b,a]=cheby1(N,Ap,Wc,options)
参数含义与butter中参数一致。
2.
(2)ChebyshevII型滤波器设计
ChebyshevII型滤波器为阻带纹波控制器:
在阻带呈现纹波特性。
[N,Wc]=cheb2ord(Wp,Ws,Ap,As)
[b,a]=cheby2(N,As,Wc,options)
3.椭圆滤波器设计
椭圆滤波器在通阻带都呈现纹波特性。
[N,Wc]=ellipord(Wp,Ws,Ap,As)
[b,a]=ellip(N,Ap,As,Wc,options)
3.实验设备及材料
装有Matlab的计算机一台
4.实验方法步骤及注意事项
利用Matlab中的函数分析并绘出常用基本信号的波形。
注意事项:
(1)在使用MATLAB时应注意中英输入法的切换,在中文输入法输入程序时得到的程序是错误的;
(2)MATLAB中两个信号相乘表示为x.*u,中间有个‘.’,同样两个信号相除也是如此;
(3)使用MATLAB编写程序时,应新建一个m文件,而不是直接在Comandante窗口下编写程序;
在使用MATLAB编程时,应该养成良好的编写习惯。
5.实验数据处理方法
比较法画图法
6.参考文献
陈后金,等.《数字信号处理》.2版【M】.北京:
高等教育出版社,2010
张德丰,等.《MATLAB数值计算与方法》.北京:
机械工业出版社,2010
二.实验报告
1.实验现象与结果
1.信号
确定设计指标,实现各种IIR数字滤波器以实现以下信号处理。
(1)设计IIR低通滤波器,滤除
的成分。
%低通滤波器
[N,Wc]=buttord(0.250,0.677,3,60)
[b,a]=butter(N,Wc,'low')
freqz(b,a);
axis([0,1,-120,0]);
gridon
title('巴特沃斯低通数字滤波器')
(2)设计IIR高通滤波器,滤除
的成分。
%高通滤波器
[N,Wc]=buttord(0.250,0.677,3,60)
[b,a]=butter(N,Wc,'high')
freqz(b,a);
axis([0,1,-120,0]);
gridon
title('巴特沃斯高通数字滤波器')
(3)设计IIR带通滤波器,滤除
的成分
%带通滤波器
Wp=[0.250.67];Ws=[0.25-0.030.67+0.03];
Rp=3;Rs=60;
[N,Wc]=buttord(Wp,Ws,Rp,Rs)
[b,a]=butter(N,Wc,'bandpass')
freqz(b,a);
axis([0,1,-120,0]);
gridon
title('巴特沃斯带通数字滤波器')
N=
40
Wc=
0.24990.6701
b=
Columns1through7
0.00000-0.000000.00000-0.0000
Columns8through14
00.00000-0.000000.00000
Columns15through21
-0.000000.00000-0.000100.0003
Columns22through28
0-0.000700.00170-0.00370
Columns29through35
0.00720-0.012500.01950-0.0276
Columns36through42
00.03530-0.040800.04290
Columns43through49
-0.040800.03530-0.027600.0195
Columns50through56
0-0.012500.00720-0.00370
Columns57through63
0.00170-0.000700.00030-0.0001
Columns64through70
00.00000-0.000000.00000
Columns71through77
-0.000000.00000-0.000000.0000
Columns78through81
0-0.000000.0000
a=
1.0e+005*
Columns1through7
0.0000-0.00010.0003-0.00110.0030-0.00740.0160
Columns8through14
-0.03180.0585-0.10080.1637-0.25190.3692-0.5174
Columns15through21
0.6952-0.89801.1176-1.34271.5597-1.75421.9125
Columns22through28
-2.02342.0794-2.07732.0188-1.90981.7596-1.5798
Columns29through35
1.3828-1.18030.9828-0.79850.6332-0.49020.3705
Columns36through42
-0.27340.1970-0.13860.0953-0.06390.0419-0.0268
Columns43through49
0.0167-0.01020.0061-0.00350.0020-0.00110.0006
Columns50through56
-0.00030.0002-0.00010.0000-0.00000.0000-0.0000
Columns57through63
0.0000-0.00000.0000-0.00000.0000-0.00000.0000
Columns64through70
-0.00000.0000-0.00000.0000-0.00000.0000-0.0000
Columns71through77
0.0000-0.00000.0000-0.00000.0000-0.00000.0000
Columns78through81
-0.00000.0000-0.00000.0000
(4)设计IIR带阻滤波器,滤除
的成分。
%带阻滤波器
Wp=[0.250.67];Ws=[0.25-0.030.67+0.03];
Rp=3;Rs=60;
[N,Wc]=buttord(Wp,Ws,Rp,Rs)
[b,a]=butter(N,Wc,'stop')
freqz(b,a);
axis([0,1,-120,0]);
gridon
title('巴特沃斯带阻数字滤波器')
N=
40
Wc=
0.24990.6701
b=
1.0e+005*
Columns1through7
0.0000-0.00000.0000-0.00000.0000-0.00000.0000
Columns8through14
-0.00000.0000-0.00000.0000-0.00000.0000-0.0000
Columns15through21
0.0001-0.00010.0003-0.00070.0015-0.00290.0056
Columns22through28
-0.01020.0179-0.03050.0502-0.07980.1227-0.1828
Columns29through35
0.2636-0.36860.4998-0.65760.8396-1.04091.2534
Columns36through42
-1.46601.6661-1.84011.9753-2.06102.0904-2.0610
Columns43through49
1.9753-1.84011.6661-1.46601.2534-1.04090.8396
Columns50through56
-0.65760.4998-0.36860.2636-0.18280.1227-0.0798
Columns57through63
0.0502-0.03050.0179-0.01020.0056-0.00290.0015
Columns64through70
-0.00070.0003-0.00010.0001-0.00000.0000-0.0000
Columns71through77
0.0000-0.00000.0000-0.00000.0000-0.00000.0000
Columns78through81
-0.00000.0000-0.00000.0000
a=
1.0e+005*
Columns1through7
0.0000-0.00010.0003-0.00110.0030-0.00740.0160
Columns8through14
-0.03180.0585-0.10080.1637-0.25190.3692-0.5174
Columns15through21
0.6952-0.89801.1176-1.34271.5597-1.75421.9125
Columns22through28
-2.02342.0794-2.07732.0188-1.90981.7596-1.5798
Columns29through35
1.3828-1.18030.9828-0.79850.6332-0.49020.3705
Columns36through42
-0.27340.1970-0.13860.0953-0.06390.0419-0.0268
Columns43through49
0.0167-0.01020.0061-0.00350.0020-0.00110.0006
Columns50through56
-0.00030.0002-0.00010.0000-0.00000.0000-0.0000
Columns57through63
0.0000-0.00000.0000-0.00000.0000-0.00000.0000
Columns64through70
-0.00000.0000-0.00000.0000-0.00000.0000-0.0000
Columns71through77
0.0000-0.00000.0000-0.00000.0000-0.00000.0000
Columns78through81
-0.00000.0000-0.00000.0000
2.某带通滤波器的设计指标为
(1)用脉冲响应不变法设计各种滤波器:
%脉冲响应不变法设计巴特沃斯带通模拟滤波器
Wp=[0.30.6];Ws=[0.20.72];
Ap=2;As=42;Fs=1;
[N,Wc]=buttord(Wp,Ws,Ap,As);
[b,a]=butter(N,Wc,'bandpass');
freqz(b,a);
axis([0,1,-120,0]);
gridon
title('脉冲响应不变法巴特沃斯带通模拟滤波器');
%脉冲响应不变法设计巴特沃斯带通数字滤波器
Wp=[0.30.6];Ws=[0.20.72];
Ap=2;As=42;Fs=1;
[N,Wc]=buttord(Wp,Ws,Ap,As);
[b,a]=butter(N,Wc,'bandpass');
h=freqz(b,a,w);
axis([0,1,-120,0]);
[numd,dend]=impinvar(b,a,Fs);
w=linspace(0,pi,512);
norm=max(abs(h));
a=a/norm;
plot(w/pi,20*log10(abs(h)/norm));
gridon
title('脉冲响应不变法巴特沃斯带通数字滤波器')
%脉冲响应不变法设计切比雪夫1型带通模拟滤波器
Wp=[0.30.6];Ws=[0.20.72];
Ap=2;As=42;Fs=1;
[N,Wc]=cheb1ord(Wp,Ws,Ap,As);
[b,a]=cheby1(N,Ap,Wc,'bandpass');
freqz(b,a);
axis([0,1,-120,0]);
gridon
title('脉冲响应不变法切比雪夫1型带通模拟滤波器');
%脉冲响应不变法设计切比雪夫1型带通数字滤波器
Wp=[0.30.6];Ws=[0.20.72];
Ap=2;As=42;Fs=1;
[N,Wc]=cheb1ord(Wp,Ws,Ap,As);
[b,a]=cheby1(N,As,Wc,'bandpass');
w=linspace(0,pi,512);
h=freqz(b,a,w);
axis([0,1,-120,0]);
[numd,dend]=impinvar(b,a,Fs);
w=linspace(0,pi,512);
norm=max(abs(h));
a=a/norm;
plot(w/pi,20*log10(abs(h)/norm));
gridon
title('脉冲响应不变法切比雪夫1型带通数字滤波器');
%脉冲响应不变法设计切比雪夫2型带通模拟滤波器
Wp=[0.30.6];Ws=[0.20.72];
Ap=2;As=42;Fs=1;
[N,Wc]=cheb2ord(Wp,Ws,Ap,As);
[b,a]=cheby2(N,As,Wc,'bandpass');
freqz(b,a);
axis([0,1,-120,0]);
gridon
title('脉冲响应不变法切比雪夫2型带通模拟滤波器');
%脉冲响应不变法设计切比雪夫2型带通数字滤波器
Wp=[0.30.6];Ws=[0.20.72];
Ap=2;As=42;Fs=1;
[N,Wc]=cheb2ord(Wp,Ws,Ap,As);
[b,a]=cheby2(N,As,Wc,'bandpass');
w=linspace(0,pi,512);
h=freqz(b,a,w);
axis([0,1,-120,0]);
[numd,dend]=impinvar(b,a,Fs);
norm=max(abs(h));
a=a/norm;
plot(w/pi,20*log10(abs(h)/norm));
gridon
title('脉冲响应不变法切比雪夫2型带通数字滤波器');
%脉冲响应不变法设计椭圆带通模拟滤波器
Wp=[0.30.6];Ws=[0.20.72];
Ap=2;As=42;Fs=1;
[N,Wc]=ellipord(Wp,Ws,Ap,As);
[b,a]=ellip(N,Ap,As,Wc,'bandpass');
freqz(b,a);
axis([0,1,-120,0]);
gridon
title('脉冲响应不变法椭圆带通模拟滤波器');
%脉冲响应不变法设计椭圆型带通数字滤波器
Wp=[0.30.6];Ws=[0.20.72];
Ap=2;As=42;Fs=1;
[N,Wc]=ellipord(Wp,Ws,Ap,As);
[b,a]=ellip(N,Ap,As,Wc,'bandpass');
h=freqz(b,a,w);
axis([0,1,-120,0]);
[numd,dend]=impinvar(b,a,Fs);
w=linspace(0,pi,512);
norm=max(abs(h));
a=a/norm;
plot(w/pi,20*log10(abs(h)/norm));
gridon
title('脉冲响应不变法椭圆带通数字滤波器');
(2)用双线性变换法设计各种滤波器:
%双线性变换法设计巴特沃斯带通模拟滤波器
%下列八个程序中约定WWp为数字频率
WWp=[0.30.6];WWs=[0.20.72];
Wp=tan(WWp/2);Ws=tan(WWs/2);
Ap=2;As=42;Fs=1;
[N,Wc]=buttord(Wp,Ws,Ap,As);
[b,a]=butter(N,Wc,'bandpass');
freqz(b,a);
axis([0,1,-120,0]);
gridon
title('双线性变换法巴特沃斯带通模拟滤波器');
%双线性变换法设计巴特沃斯带通数字滤波器
WWp=[0.30.6];WWs=[0.20.72];
Wp=tan(WWp/2);Ws=tan(WWs/2);
Ap=2;As=42;Fs=1;
[N,Wc]=buttord(Wp,Ws,Ap,As);
[b,a]=butter(N,Wc,'bandpass');
h=freqz(b,a,w);
axis([0,1,-120,0]);
[numd,dend]=impinvar(b,a,Fs);
w=linspace(0,pi,512);
norm=max(abs(h));
a=a/norm;
plot(w/pi,20*log10(abs(h)/norm));
gridon
title('双线性变换法巴特沃斯带通数字滤波器')
%双线性变换法设计切比雪夫1型带通模拟滤波器
WWp=[0.30.6];WWs=[0.20.72];
Wp=tan(WWp/2);Ws=tan(WWs/2);
Ap=2;As=42;Fs=1;
[N,Wc]=cheb1ord(Wp,Ws,Ap,As);
[b,a]=cheby1(N,Ap,Wc,'bandpass');
freqz(b,a);
axis([0,1,-120,0]);
gridon
title('双线性变换法切比雪夫1型带通模拟滤波器');
%双线性变换法设计切比雪夫1型带通数字滤波器
WWp=[0.30.6];WWs=[0.20.72]