Matlab操作实验报告.docx
《Matlab操作实验报告.docx》由会员分享,可在线阅读,更多相关《Matlab操作实验报告.docx(10页珍藏版)》请在冰豆网上搜索。
![Matlab操作实验报告.docx](https://file1.bdocx.com/fileroot1/2022-12/11/37270082-d74b-464e-8365-c1aa3d8e467a/37270082-d74b-464e-8365-c1aa3d8e467a1.gif)
Matlab操作实验报告
数字信号处理Matlab操作实验报告
实验一
1.1实验要求
指定一序列进行以下操作:
补零、重复原序列本身,分别画出对应幅度谱
1.2程序设计
(1)末尾补零法
>>x=ones(1,16)
x=
Columns1through13
1111111111111
Columns14through16
111
>>figure;stem(x)
>>y=[ones(1,16),zeros(1,16)]
y=
Columns1through13
1111111111111
Columns14through26
1110000000000
Columns27through32
000000
>>figure;stem(y)
>>y=fft(x,32);
>>figure;stem(abs(y))
(2)重复原序列本身
>>x=ones(1,16);
>>figure;stem(x)
>>y=fft(x,32)
y=
Columns1through4
16.00001.0000-10.1532i01.0000-3.2966i
Columns5through8
01.0000-1.8709i01.0000-1.2185i
Columns9through12
01.0000-0.8207i01.0000-0.5345i
Columns13through16
01.0000-0.3033i01.0000-0.0985i
Columns17through20
01.0000+0.0985i01.0000+0.3033i
Columns21through24
01.0000+0.5345i01.0000+0.8207i
Columns25through28
01.0000+1.2185i01.0000+1.8709i
Columns29through32
01.0000+3.2966i01.0000+10.1532i
>>figure;stem(y)
>>figure;stem(abs(y))
实验二
2.1实验要求
设计一个巴特沃斯型和切比雪夫Ⅰ型数字低通滤波器,把
提取出来,要求通带衰减小于1dB,阻带衰减大于15dB。
画出所设计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*
Columns1through7
0.02220.15550.46640.77730.77730.46640.1555
Column8
0.0222
a=
Columns1through7
1.0000-4.76359.9850-11.87888.6336-3.82450.9543
Column8
-0.1033
>>y=freqz(b,a);
>>f=0:
Fs/2/512:
Fs/2-Fs/2/512;
>>plot(f,abs(y))
(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.10000.49980.99970.99970.49980.1000
a=
1.0000-4.23647.4629-6.80733.2088-0.6249
>>y=freqz(b,a);
>>f=0:
Fs/2/512:
Fs/2-Fs/2/512;
>>plot(f,abs(y))
2.3实验分析
(1)最初波形
(从上至下,分别对应
以及
)
>>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);
右为经过巴特沃斯滤波器后恢复的波形
右为经过切比雪夫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)));
(1、x的幅度谱2、x滤波后的幅度谱3、x1滤波前的幅度谱)