数字信号处理课程设计
学院:信息工程学院 专业:09通信工程
姓名:伍国超
学号: 0967119224
指导老师:张超
第一章 ...............................................................................................3 第二章 ...............................................................................................5 第三章 ...............................................................................................7 第四章 .............................................................................................10 第五章 .............................................................................................15
第一章
(2) x(n)=(0.9) n [sin(0.25πn)+cos(0.25πn)] A=0.9; w=pi/4; n=-5:5; y=A.^n.*[sin(w.*n)+cos(w.*n)]; stem(n,y);
1.510.50-0.5-1-1.5-2-5-4-3-2-1012345
(4) 已知x(t)=e –2 tu (t), y(t)=e - tu (t) , 求:x(t) * y(t) t=0:0.01:5; u=(t>=0); x=exp(-2.*t).*u; y=exp(-1.*t).*u; q=1:1001; z=conv(x,y); plot(q,z);
302520151050020040060080010001200
第二章
11. 利用DFT计算序列x(n)u(n)的频谱;
2n
N=60; n=0:N-1; u=(n>=0); x=(1/2).^n.*u X=fft(x,N); omega=2*pi/N*(n-N/2); subplot(2,1,1); stem(omega,abs(fftshift(X))); axis([-pi,pi,0,4]); ylabel(\'Magnitude\'); xlabel(\'Frequency (rad)\' ); subplot(2,1,2); stem(omega,angle(fftshift(X))); axis([-pi,pi,-1,1]); ylabel(\'Phase\'); xlabel(\'Frequency (rad) \' );
43210-1Magnitude-0.500.511.5Frequency (rad)22.5310.5Phase0-0.5-1-1-0.500.511.5Frequency (rad) 22.53
3. 有限长序列x(n)cos(频谱。 要求:
(1) 确定DFT计算的各参数;
(2) 进行理论值与计算值比较,分析各信号频谱分析的计算精度;
(3) 详细列出利用DFT分析离散信号频谱的步骤;
(4) 写出实验原理。
N1=32;N2=60;N3=120; n=0:31; n1=0:N1-1; n2=0:N2-1; n3=0:N3-1; x=cos(3*pi/8*n); X1=fft(x,N1); omega1=2*pi/N1*(n1-N1/2); subplot(6,2,1); stem(omega1,abs(fftshift(X1))); ylabel(\'Magnitude\'); xlabel(\'Frequency (rad)\' ); subplot(6,2,2); stem(omega1,angle(fftshift(X1))); ylabel(\'Phase\'); xlabel(\'Frequency (rad) \' ); X2=fft(x,N2); omega2=2*pi/N2*(n2-N2/2); subplot(6,2,3); stem(omega2,abs(fftshift(X2))); ylabel(\'Magnitude\'); xlabel(\'Frequency (rad)\' ); subplot(6,2,4); stem(omega2,angle(fftshift(X2))); ylabel(\'Phase\'); xlabel(\'Frequency (rad) \' ); X3=fft(x,N3); omega3=2*pi/N3*(n3-N3/2); subplot(6,2,5); stem(omega3,abs(fftshift(X3))); ylabel(\'Magnitude\'); xlabel(\'Frequency (rad)\' ); subplot(6,2,6); stem(omega3,angle(fftshift(X3))); ylabel(\'Phase\'); xlabel(\'Frequency (rad) \' );
38n), 0≤n≤31,分别用N=32,N=60,N=120点DFT计算其
第三章
1.已知一个LTI系统的差分方程为:
y[n]-1.143*y[n-1]+0.4128*y[n-2]=0.0675*x[n]+0.1349*x[n-1]+0.0675*x[n-2]
1、(1)初始条件y(-1)=1,y(-2)=2,输入x(n)=u(n),计算系统的零输入响应 N=11; n=0:N-1; x=[n>=0]; b=[0.0675,0.1349,0.0675];a=[1,-1.143,0.4128]; zi=filtic(b,a,[1,2]); y=filter(b,a,zi); stem(y)
(2)当下面三个信号分别通过系统,分别计算系统的响应:
1.输入信号x1[n]=cos((pi/10)*n)*u[n] N=11; n=0:N-1 x1=cos((pi/10)*n) b=[0.0675,0.1349,0.0675];a=[1,-1.143,0.4128]; zi=filtic(b,a,[1,2]); y=filter(b,a,x1) stem(n,y) n = 0
10 x1 =
Columns 1 through 9
1.0000
0.9511
0.8090
0.5878
0.3090
0.0000
-0.3090
-0.5878
-0.8090 Columns 10 through 11 -0.9511
-1.0000 y = Columns 1 through 9
0.0675
0.2762
0.5383
0.7142
0.7489
0.6426
0.4253
0.1395
-0.1709 Columns 10 through 11 -0.4659
-0.7124
2.输入信号:x2[n]=cos((pi/5)*n)*u[n] N=11; n=0:N-1 x2=cos((pi/5)*n) b=[0.0675,0.1349,0.0675];a=[1,-1.143,0.4128]; zi=filtic(b,a,[1,2]); y=filter(b,a,x2,zi) stem(n,y) n = 0
10 x2 =
Columns 1 through 8
1.0000
0.8090
0.3090
-0.3090
-0.8090
-1.0000
-0.8090 Columns 9 through 11
0.3090
0.8090
1.0000 y = Columns 1 through 8
0.3849
0.2166
0.2862
0.3132
0.1644
-0.1389
-0.4707
-0.3090 -0.6782
Columns 9 through 11
-0.6563
-0.3948
0.0172
3.输入信号:x3[n]=cos((7*pi/10)*n)*u[n] N=11; n=0:N-1 x3=cos((7*pi/10)*n) b=[0.0675,0.1349,0.0675];a=[1,-1.143,0.4128]; zi=filtic(b,a,[1,2]); y=filter(b,a,x3,zi) stem(n,y) n = 0
9 x3 = Columns 1 through 9
1.0000
-0.5878
-0.3090
0.9511
-0.8090
-0.0000 0.3090 Columns 10 through 11 0.5878
-1.0000 y = Columns 1 through 9
0.3849
0.1224
-0.0517
-0.1267
-0.0707
-0.0734 -0.0157 Columns 10 through 11
(3)系统特性分析
b=[0.0675,0.1349,0.0675];a=[1,-1.143,0.4128]; z=roots(b) p=roots(a)
0.8090 -0.0548 -0.9511 0.0127
zplane(b,a)
此系统为因果稳定系统
第四章
2.分别使用矩形窗、哈明窗、海宁窗设计一个N=10的FIR低通和高通滤波器,
截频为c3rad。
1) 作出各滤波器的单位脉冲响应
2) 作出各滤波器的幅频响应并比较各滤波器的通带纹波和阻带纹波。
3)若当输入为x(n)12cosn4cosn2,计算各滤波器的输出并作出响应波形。
N=10;M=N-1;wc=pi/3;
% LP % rectangular window
b1=fir1(M,wc/pi,boxcar(N)); [H1,w]=freqz(b1,wc,512); H1_db=20*log10(abs(H1));
% hamming window
b2=fir1(M,wc/pi,hamming(N));
[H2,w]=freqz(b2,wc,512); H2_db=20*log10(abs(H2));
% hanning window
b3=fir1(M,wc/pi,hanning(N)); [H3,w]=freqz(b3,wc,512); H3_db=20*log10(abs(H3));
figure(1) c=plot(w,H1_db,w,H2_db,\'y\',w,H3_db,\'r\');
figure(2) subplot(3,1,1);stem(n1,real(h1));axis([0 25 -0.2 0.2]); subplot(3,1,2);stem(n1,real(h2),\'y\');axis([0 25 -0.2 0.2]); subplot(3,1,3);stem(n1,real(h3),\'r\');axis([0 25 -0.2 0.2]);
% HP % rectangular window
b4=fir1(M,wc/pi,\'high\',boxcar(N+1)); [H4,w]=freqz(b4,wc,512);
H4_db=20*log10(abs(H4));
% hamming window
b5=fir1(M,wc/pi,\'high\',hamming(N+1)); [H5,w]=freqz(b5,wc,512); H5_db=20*log10(abs(H5));
% hanning window
b6=fir1(M,wc/pi,\'high\',hanning(N+1)); [H6,w]=freqz(b6,wc,512); H6_db=20*log10(abs(H6));
figure(3) c=plot(w,H4_db,w,H5_db,\'y\',w,H6_db,\'r\'); figure(4) subplot(3,1,1);stem(n1,real(h4));axis([0 25 -0.2 0.2]); subplot(3,1,2);stem(n1,real(h5),\'y\');axis([0 25 -0.2 0.2]); subplot(3,1,3);stem(n1,real(h6),\'r\');axis([0 25 -0.2 0.2]);
x=1+2*cos(pi/4*n1)+cos(pi/2*n1); y1=conv(x,h1); y2=conv(x,h2);
y3=conv(x,h3); y4=conv(x,h4); y5=conv(x,h5); y6=conv(x,h6); figure(5) subplot(3,2,1);stem(n2,y1);axis([0 50 -0.2 1]); subplot(3,2,2);stem(n2,y2);axis([0 50 -0.2 1]); subplot(3,2,3);stem(n2,y3);axis([0 50 -0.2 1]); subplot(3,2,4);stem(n2,y4);axis([0 50 -2 2]); subplot(3,2,5);stem(n2,y5);axis([0 50 -2 2]); subplot(3,2,6);stem(n2,y6);axis([0 50 -2 2]);
200-20-40-60-80-10000.511.522.533.5
0.20-0.20.20-0.20.20-0.2051015202505101520250510152025
100-10-20-30-40-50-60-7000.511.522.533.5
0.20-0.20.20-0.20.20-0.2051015202505101520250510152025
10.50010.50020-21020304050-220-20102030405010203040502010.50010203040500102030405001020304050
第五章
1.某随机信号由两余弦信号与噪声构成:
x[k]= cos (20πk) +cos (40πk) + s [k],s[k]为均值为0,方差为1的高斯白噪声。 (1) 绘出此随机信号的时域波形;
(2) 试分别用周期图法、平均周期图法和Welch法分析该序列的功率谱估计。 Fs = 1000; % 抽样频率 t = 0:1/Fs:1; % 抽样时间
xn = cos(20*pi*t) + cos(40*pi*t) + randn(size(t));
%粗略地估计xn的功率谱,做N=1024点FFT:
Pxx = abs(fft(xn,1024)).^2/1001; subplot(3,3,1);plot(t,xn); xlabel(\'随机信号\');grid on; subplot(3,3,2);plot([0:1023]*Fs/1024,10*log10(Pxx));xlabel(\'利用公式\'); grid on; window=boxcar(1001); [Pxx1,F1] = periodogram(xn,window,1024,Fs); subplot(3,3,3);plot(F1, 10*log10(Pxx1)); xlabel (\'利用函数periodogram\'); grid on; noverlap=500; [Pxx2,F2] = psd(xn, 1024,Fs, window, noverlap); subplot(3,3,4);plot(F2, 10*log10(Pxx2)); xlabel (\'利用函数psd\'); grid on; noverlap=500; [Pxx3,F3] = pwelch(xn, window\', noverlap, 1024,Fs); subplot(3,3,5);plot(F3, 10*log10(Pxx3)); xlabel (\'利用函数pwelch\'); grid on; 50-5500-500-50-10000.5随机信号10500利用公式10000500利用函数periodogram500-500-50-1000利用函数psd5000500利用函数pwelch