数字信号处理Matlab操作实验报告
实验一
1.1 实验要求
指定一序列进行以下操作:补零、重复原序列本身,分别画出对应幅度谱
1.2 程序设计 (1)末尾补零法
>> x=ones(1,16) x =
Columns 1 through 13
1 1 1 1 1 1 1 1 1 1 1 1
Columns 14 through 16
1 1 1 >> figure;stem(x)
10.9
0.80.70.60.50.40.30.20.100
2
4
6
8
10
12
14
16
>> y=[ones(1,16),zeros(1,16)] y =
1
Columns 1 through 13
1 1 1 1 1 1 1 1 1 1 1 1 1
Columns 14 through 26
1 1 1 0 0 0 0 0 0 0 0 0 0
Columns 27 through 32
0 0 0 0 0 0 >> figure;stem(y)
10.90.80.70.60.50.40.30.20.10
>> y=fft(x,32);
>> figure;stem(abs(y))
1614121086420
(2)重复原序列本身
>> x=ones(1,16); >> figure;stem(x)
10.9
0.80.70.60.50.40.30.20.100
2
4
6
8
10
12
14
16
>> y=fft(x,32) y =
Columns 1 through 4
16.0000 1.0000 -10.1532i 0 1.0000 - 3.2966i
Columns 5 through 8
0 1.0000 - 1.8709i 0 1.0000 - 1.2185i
Columns 9 through 12
0 1.0000 - 0.8207i 0 1.0000 - 0.5345i
Columns 13 through 16
0 1.0000 - 0.3033i 0 1.0000 - 0.0985i
Columns 17 through 20
0 1.0000 + 0.0985i 0 1.0000 + 0.3033i
Columns 21 through 24
0 1.0000 + 0.5345i 0 1.0000 + 0.8207i
Columns 25 through 28
0 1.0000 + 1.2185i 0 1.0000 + 1.8709i
Columns 29 through 32
0 1.0000 + 3.2966i 0 1.0000 +10.1532i >> figure;stem(y)
15
10
5
-5
-10
-15
05101520253035
>> figure;stem(abs(y))
1614121086420
实验二
2.1实验要求
f1 10Hz,f2 100Hz,fs 500Hzx(t) cos(2 f1t) cos(2 f2t) x1(t) x2(t)
设计一个巴特沃斯型和切比雪夫Ⅰ型数字低通滤波器,把x1(t)提取出来,要求通带衰减小于1dB,阻带衰减大于15 dB。画出所设计DF的频响,分析滤波前后信号的频谱
2.2 实验设计 (1)巴特沃斯型
设置通带截止频率fc=35Hz,,阻带的起始频率fs=40Hz. >> Fs=500; >> T=1/Fs; >> fc=35; >> fs=50;
>> wc=fc*2*pi*T; >> ws=fs*2*pi*T; >> Wc=wc/pi; >> Ws=ws/pi;
>> [N,W]=buttord(Wc,Ws,1,15) N =
7 W =
0.1586
>> [b,a]=butter(N,W) b =
1.0e-003 *
Columns 1 through 7
0.0222 0.1555 0.4664 0.7773 0.7773 0.4664 0.1555
Column 8
0.0222 a =
Columns 1 through 7
1.0000 -4.7635 9.9850 -11.8788 8.6336 -3.8245 0.9543
Column 8
-0.1033
>> y=freqz(b,a);
>> f=0:Fs/2/512:Fs/2-Fs/2/512; >> plot(f,abs(y))
1.4
1.2
1
0.8
0.6
0.4
0.2
050100150200250
(2)切比雪夫I型滤波器
设置通带截止频率fc=40Hz,,阻带的起始频率fs=50Hz. >> Fs=500; >> T=1/Fs; >> fc=40; >> fs=50;
>> wc=fc*2*pi*T;
>> ws=fs*2*pi*T; >> Wc=wc/pi; >> Ws=ws/pi;
>> [N,W]=cheb1ord(Wc,Ws,1,15) N =
5 W =
0.1600
>> [b,a]=cheby1(N,1,W) b =
1.0e-003 *
0.1000 0.4998 0.9997 0.9997 0.4998 0.1000 a =
1.0000 -4.2364 7.4629 -6.8073 3.2088 -0.6249
>> y=freqz(b,a);
>> f=0:Fs/2/512:Fs/2-Fs/2/512; >> plot(f,abs(y))
10.9
0.80.70.60.50.40.30.20.100
50
100
150
200
250
2.3 实验分析 (1)最初波形
10.5
0-0.5-1
10.5
0-0.5-1
00.510510
21
0-1-2
00.10.20.30.40.50.60.70.80.91
(从上至下,分别对应x1(t),x2(t),以及x(t)) >> f1=10; >> f2=100; >> Fs=500; >> t=(1:500)/Fs;
>> x1=cos(2*pi*f1*t); >> x2=cos(2*pi*f2*t); >> x=x1+x2;
>> subplot(2,2,1);t=(1:500)/Fs;plot(t,x1); >> subplot(2,2,2);t=(1:500)/Fs;plot(t,x2);
>> subplot(2,1,2);t=(1:500)/Fs;plot(t,x);
(2)解调波形
>> Y=filter(b,a,x);
>> subplot(1,2,1);plot(t,x1); >> subplot(1,2,2);plot(t,Y);
10.8
0.60.40.2
0-0.2-0.4-0.6-0.8
-1
1
0.5
-0.5
-1
-1.5
右为经过巴特沃斯滤波器后恢复的波形
1
0.80.60.40.20-0.2-0.4-0.6-0.8-1
10.80.60.40.20-0.2-0.4-0.6-0.8-1
右为经过切比雪夫1型滤波器恢复后的波形
可以看出切比雪夫1型滤波器设计的优于巴特沃斯滤波器,主要两滤波的通带截止频率与阻带的起始频率不同,影响滤波特性。无论是哪种滤波器,对应的滤波后的幅度谱的条数减少,减少一半。 >> S=fft(x,512);
>> l=(0:255)/256*(Fs/2); >> s=fft(Y,512); >> A=fft(x1,512);
>> subplot(2,2,1);plot(l,abs(S(1:256))); >> subplot(2,2,2);plot(l,abs(s(1:256))); >> subplot(2,1,2);plot(l,abs(A(1:256)));
250200
1501005000
100
200
300
250200
1501005000
100
200
300
250200
1501005000
50
100
150
200
250
(1、x的幅度谱 …… 此处隐藏:1169字,全部文档内容请下载后查看。喜欢就下载吧 ……