首页 数字信号处理第二章实验报告

数字信号处理第二章实验报告

举报
开通vip

数字信号处理第二章实验报告 实  验  报  告 课    程:数字信号处理 专业班级: 学生姓名: 学    号: 年月   日 2.1对M=2,运行上述程序,生成输入x[n]=s1[n]+s2[n]的输出信号。输入x[n]的哪个分量被该离散时间系统抑制? % 程序 P2_1 % 一个M点滑动平均滤波器的仿真 % 产生输入信号 n = 0:100; s1 = cos(2*pi*0.05*n); % 一个低频正弦 s2 = cos(2*pi*0.47*n); % 一个高频正弦 x = s1+s2; % M点滑动平均滤波器的实现 M = ...

数字信号处理第二章实验报告
实  验  报  告 课    程:数字信号处理 专业班级: 学生姓名: 学    号: 年月   日 2.1对M=2,运行上述程序,生成输入x[n]=s1[n]+s2[n]的输出信号。输入x[n]的哪个分量被该离散时间系统抑制? % 程序 P2_1 % 一个M点滑动平均滤波器的仿真 % 产生输入信号 n = 0:100; s1 = cos(2*pi*0.05*n); % 一个低频正弦 s2 = cos(2*pi*0.47*n); % 一个高频正弦 x = s1+s2; % M点滑动平均滤波器的实现 M = input('滤波器所需的长度 = '); num = ones(1,M); y = filter(num,1,x)/M; clf; subplot(2,2,1); plot(n, s1); axis([0, 100, -2, 2]); xlabel('时间序号n'); ylabel('振幅'); title('低频正弦'); subplot(2,2,2); plot(n, s2); axis([0, 100, -2, 2]); xlabel('时间序号n'); ylabel('振幅'); title('高频正弦'); subplot(2,2,3); plot(n, x); axis([0, 100, -2, 2]); xlabel('时间序号n'); ylabel('振幅'); title('输入信号'); subplot(2,2,4); plot(n, y); axis([0, 100, -2, 2]); xlabel('时间序号n'); ylabel('振幅'); title('输出信号');  axis; 图形显示如下: 答:输入部分 的高频成分 成分被抑制了。 2.3对滤波器长度M和正弦信号s1[n]和s2[n]的频率取其他值,运行程序P2.1,算出结果。 n = 0:100; s1=cos(2*pi*0.02*n); s2=cos(2*pi*0.46*n); x = s1+s2; % M点滑动平均滤波器的实现 M = input('滤波器所需的长度 = '); num = ones(1,M); y = filter(num,1,x)/M; clf; figure, subplot(2,2,1); plot(n, s1); axis([0, 100, -2, 2]); xlabel('时间序号n'); ylabel('振幅'); title('低频正弦'); subplot(2,2,2); plot(n, s2); axis([0, 100, -2, 2]); xlabel('时间序号n'); ylabel('振幅'); title('高频正弦'); subplot(2,2,3); plot(n, x); axis([0, 100, -2, 2]); xlabel('时间序号n'); ylabel('振幅'); title('输入信号'); subplot(2,2,4); plot(n, y); axis([0, 100, -2, 2]); xlabel('时间序号n'); ylabel('振幅'); title('输出信号');  axis; num =[1,-ones(1,M-1)]; y = filter(num,1,x)/M; figure, subplot(2,2,1); plot(n, s1); axis([0, 100, -2, 2]); xlabel('时间序号n'); ylabel('振幅'); title('低频正弦'); subplot(2,2,2); plot(n, s2); axis([0, 100, -2, 2]); xlabel('时间序号n'); ylabel('振幅'); title('高频正弦'); subplot(2,2,3); plot(n, x); axis([0, 100, -2, 2]); xlabel('时间序号n'); ylabel('振幅'); title('输入信号'); subplot(2,2,4); plot(n, y); axis([0, 100, -2, 2]); xlabel('时间序号n'); ylabel('振幅'); title('输出信号');  axis; 图形显示如下: 答:运行结果如下图,可以看出输出信号保留了输入信号x[n]的高频分量,即保留了s2[n]分量,低频部分s1[n]被抑制了。 2.5用不同频率的正弦信号作为输入信号,计算每个输入信号的输出信号。输出信号是如何受到输入信号频率的影响的?从数学上对你的结论加以证明。 % 程序P2_2 % 产生一个正弦输入信号 clf; n = 0:200; f=input('Please input the value of f:') x = cos(2*pi*f*n); % 计算输出信号 x1 = [x 0 0];      % x1[n] = x[n+1] x2 = [0 x 0];      % x2[n] = x[n] x3 = [0 0 x];      % x3[n] = x[n-1] y = x2.*x2-x1.*x3; y = y(2:202); % 画出输入和输出信号 subplot(2,1,1) plot(n, x) xlabel('时间序列n');ylabel('振幅'); title('输入信号') subplot(2,1,2) plot(n,y) xlabel('时间信号n');ylabel('振幅'); title('输出信号'); 分别取F=0.05,F=0.47,F=0.5以及F=0,仿真结果如下所示: 证明:设输入信号为 ,则 以及 则 答:从图形中可以看出,输入频率越大,输出信号值越小。最后都逐渐趋于0。 2.7运行程序P2.3,对由加权输入得到的y[n]在与相同权系数下输出y1[n]和y2[n]相加得到的yt[n]进行比较,这两个序列是否相等?该系统是线性系统么? clf; n = 0:40; a = 2;b = -3; x1 = cos(2*pi*0.1*n); x2 = cos(2*pi*0.4*n); x = a*x1 + b*x2; num=[2.2403 2.4908 2.2403]; den = [1 -0.4 0.75]; ic = [0 0]; y1 = filter(num,den,x1,ic); y2 = filter(num,den,x2,ic); y = filter(num,den,x,ic); yt = a*y1 + b*y2; d = y - yt; subplot(3,1,1) stem(n,y); ylabel('振幅'); title('加权输入: a \cdot x_{1}[n] + b \cdot x_{2}[n]的输出'); subplot(3,1,2) stem(n,yt); ylabel('这幅'); title('加权输出: a \cdot y_{1}[n] + b \cdot y_{2}[n]'); subplot(3,1,3) stem(n,d); xlabel('时间序号 n');ylabel('振幅'); title('差信号'); 图形显示如下: 答:该仿真结果说明这两个序列相等,该系统是线性系统。 2.9当初始条件非零时重做习题Q2.7。 令ic = [10 20];则仿真结论如下所示: 答:该仿真结果说明这两个序列不相等,该系统不是线性系统。 2.11假定另一个系统为y[n]=x[n]x[n-1],修改程序P2.3,计算这个系统的输出序列y1[n],y2[n]和y[n]。比较y[n]和yt[n]。这两个序列是否相等?该系统是线性系统吗? n=0:40; a=2;b=-3; x11=[0  cos(2*pi*0.1*n) 0];x12=[0 0 cos(2*pi*0.1*n)]; x21=[0 cos(2*pi*0.4*n) 0]; x22=[0 0 cos(2*pi*0.4*n)]; y1=x11.*x12;y2=x21.*x22; yt=a*y1+b*y2; y=(a*x11+b*x21).*(a*x12+b*x22); d=y-yt; subplot(3,1,1) stem([0 n 0],y); ylabel('振幅'); title('加权输入: a \cdot x_{1}[n] + b \cdot x_{2}[n]的输出'); subplot(3,1,2) stem([0 n 0],yt); ylabel('这幅'); title('加权输出: a \cdot y_{1}[n] + b \cdot y_{2}[n]'); subplot(3,1,3) stem([0 n 0],d); xlabel('时间序号 n');ylabel('振幅'); title('差信号'); 图形显示如下: 答:这两个序列不相等,该系统不是线性系统。 2.13采用三个不同的延时变量D的值重做习题Q2.12。 D=2;D=6;D=12;显示图形如下: 答:该系统是时不变系统,满足y[n-D]=yd[n]。 2.15在非零的初始条件下重做习题Q2.12,该系统是时不变系统吗? clf; n = 0:40; D = 10;a = 3.0;b = -2; x = a*cos(2*pi*0.1*n) + b*cos(2*pi*0.4*n); xd = [zeros(1,D) x]; num = [2.2403 2.4908 2.2403]; den = [1 -0.4 0.75]; ic = [5 10]; y = filter(num,den,x,ic); yd = filter(num,den,xd,ic); d = y - yd(1+D:41+D); subplot(3,1,1) stem(n,y); ylabel('??·ù'); title('ê?3? y[n]'); grid; subplot(3,1,2) stem(n,yd(1:41)); ylabel('??·ù'); title('óéóú?óê±ê?è? x[n-10]μ?ê?3?'); grid; subplot(3,1,3) stem(n,d); xlabel('ê±??Dòo? n'); ylabel('??·ù'); title('2??μD?o?'); grid; 图形显示如下: 答:该仿真结果说明该系统是时变系统。 2.17考虑另一个系统:y[n]=nx[n]+x[n-1],修改程序P2.4,以仿真上面的系统并确定该系统是否为时不变系统。 clf; n = 0:40; D = 10;a = 3.0;b = -2; x = a*cos(2*pi*0.1*n) + b*cos(2*pi*0.4*n); xd = [zeros(1,D) x]; nd=0:length(xd)-1; y=(n.*x)+[0 x(1:40)]; yd=(nd.*xd)+[0 xd(1:length(xd)-1)]; d = y - yd(1+D:41+D); subplot(3,1,1) stem(n,y); ylabel('振幅'); title('输出 y[n]'); grid; subplot(3,1,2) stem(n,yd(1:41)); ylabel('振幅'); title('由于延时输入 x[n-10]的输出'); grid; subplot(3,1,3) stem(n,d); xlabel('时间序号 n'); ylabel('振幅'); title('差值信号'); grid; 图形显示如下: 答:从仿真结果看,该系统是时变系统。 2.19运行程序P2.5,生成式(2.15)所给的离散系统的冲激响应。 clf; N=40; num=[2.2403 2.4908 2.2403]; den=[1 -0.4 0.75]; y=impz(num,den,N); %画出冲激相应 stem(y); xlabel('时间序号n');ylabel('振幅'); title('冲激响应');grid; 图形显示如下: 2.21利用filter命令编写一个MATLB程序,生成式(2.17)给出的因果线性时不变系统的冲激响应,计算并画出前40个的样本。把你的结果和习题Q2.20中得到的结果相比较。 clf; N = 40; num = [0.9 -0.45 0.35 0.002]; den = [1.0 0.71 -0.46 -0.62]; % input: unit pulse x = [1 zeros(1,N-1)]; % output y = filter(num,den,x); % Plot the impulse response % NOTE: the time axis will be WRONG; h[0] will % be plotted at n=1; but this will agree with % the INCORRECT plotting that was also done % by program P2_5. stem(y); xlabel('Time index n'); ylabel('Amplitude'); title('Impulse Response'); grid; 图形显示如下: 答:两题结果一样。 2.23运行程序P2.6,计算输出序列y[n]和y2[n]以及差值信号d[n]。y[n]和y2[n]相等吗? % Program P2_6 % Cascade Realization clf; x = [1 zeros(1,40)]; % Generate the input n = 0:40; % Coefficients of 4th order system den = [1 1.6 2.28 1.325 0.68]; num = [0.06 -0.19 0.27 -0.26 0.12]; % Compute the output of 4th order system y = filter(num,den,x); % Coefficients of the two 2nd order systems num1 = [0.3 -0.2 0.4];den1 = [1 0.9 0.8]; num2 = [0.2 -0.5 0.3];den2 = [1 0.7 0.85]; % Output y1[n] of the first stage in the cascade y1 = filter(num1,den1,x); % Output y2[n] of the second stage in the cascade y2 = filter(num2,den2,y1); % Difference between y[n] and y2[n] d = y - y2; % Plot output and difference signals subplot(3,1,1); stem(n,y); ylabel('Amplitude'); title('Output of 4th order Realization'); grid; subplot(3,1,2); stem(n,y2) ylabel('Amplitude'); title('Output of Cascade Realization'); grid; subplot(3,1,3); stem(n,d) xlabel('Time index n');ylabel('Amplitude'); title('Difference Signal'); grid; 图形显示如下: 答:y(n)和y2(n)相等。 2.25用任意的非零初始向量ic,ic1和ic2来重做习题Q2.23。 clf; x=sin(2*pi*0.2*n); % Generate the input n = 0:40; % Coefficients of 4th order system den = [1 1.6 2.28 1.325 0.68]; num = [0.06 -0.19 0.27 -0.26 0.12]; xi=[1 2 3 4]; % Compute the output of 4th order system y = filter(num,den,x,xi); % Coefficients of the two 2nd order systems num1 = [0.3 -0.2 0.4];den1 = [1 0.9 0.8]; num2 = [0.2 -0.5 0.3];den2 = [1 0.7 0.85]; xi1=[1 2]; % Output y1[n] of the first stage in the cascade y1 = filter(num1,den1,x,xi1); xi2=[3 4]; % Output y2[n] of the second stage in the cascade y2 = filter(num2,den2,y1,xi2); % Difference between y[n] and y2[n] d = y - y2; % Plot output and difference signals subplot(3,1,1); stem(n,y); ylabel('Amplitude'); title('Output of 4th order Realization'); grid; subplot(3,1,2); stem(n,y2) ylabel('Amplitude'); title('Output of Cascade Realization'); grid; subplot(3,1,3); stem(n,d) xlabel('Time index n');ylabel('Amplitude'); title('Difference Signal'); grid; 图形显示如下: 答:y(n)和y2(n)不相等。 2.27用任意非零初始向量ic,ic1和ic2来重做习题Q2.26。 % Program P2.27 % Cascade Realization clf; x = [1 zeros(1,40)]; % Generate the input n = 0:40; % Coefficients of 4th order system den = [1 1.6 2.28 1.325 0.68]; num = [0.06 -0.19 0.27 -0.26 0.12]; ic=[4 10 2 12] % Compute the output of 4th order system y = filter(num,den,x,ic); % Coefficients of the two 2nd order systems num1 = [0.3 -0.2 0.4];den1 = [1 0.9 0.8]; num2 = [0.2 -0.5 0.3];den2 = [1 0.7 0.85]; % Output y1[n] of the first stage in the cascade y1 = filter(num2,den2,x,ic(1:2)); % Output y2[n] of the second stage in the cascade y2 = filter(num1,den1,y1,ic(3:4)); % Difference between y[n] and y2[n] d = y - y2; % Plot output and difference signals subplot(3,1,1); stem(n,y); ylabel('Amplitude'); title('Output of 4th order Realization'); grid; subplot(3,1,2); stem(n,y2) ylabel('Amplitude'); title('Output of Cascade Realization'); grid; subplot(3,1,3); stem(n,d) xlabel('Time index n');ylabel('Amplitude'); title('Difference Signal'); grid; 图形显示如下: 答:由结果 关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf 明,两个输出结果有没差别。有差别证明级联的顺序不可以互换,这里是一个验证程序。 2.29修改程序P2.7,计算长度为15的序列h[n]和长度为10的序列x[n]的卷积,重做问题Q2.28。h[n]和x[n]的样本值你自己给定。 % Program P2.29 clf; h = [3 2 1 -2 1 0 -4 0 3 1 5 4 0 3 5];  % impulse response x = [1 -2 3 -4 3 2 1 5 6 1];        % input sequence y = conv(h,x); n = 0:23; subplot(2,1,1); stem(n,y); xlabel('Time index n'); ylabel('Amplitude'); title('Output Obtained by Convolution'); grid; x1 = [x zeros(1,14)]; y1 = filter(h,1,x1); subplot(2,1,2); stem(n,y1); xlabel('Time index n'); ylabel('Amplitude'); title('Output Generated by Filtering'); grid; 图形显示如下: 答:x[n]后面补零数应为x(n)和h[n]序列的长度之和减一,为14. 2.31使用命令break的目的是什么? 答:使用命令break是使当在k未到最后一个数值是此时 的值已经小于 时,跳出for循环。 2.33考虑用差分方程 描述的离散时间系统。修改程序P2.8,计算并画出上述系统的冲激响应。该系统稳定吗? % values of the impulse response samples clf; num = [1 -4 3]; den = [1 -1.7  1]; N = 200; h = impz(num,den,N+1); parsum = 0; for k = 1:N+1; parsum = parsum + abs(h(k)); if abs(h(k)) < 10^(-6), break, end end % Plot the impulse response n = 0:N; stem(n,h) xlabel('Time index n'); ylabel('Amplitude'); % Print the value of abs(h(k)) disp('Value =');disp(abs(h(k))); 图形显示如下: 答:该系统不稳定。 2.35修改程序P2.9,将输入序列改变成扫频正弦序列(长度为301、最低频率为0、最高频率为0.5)。那个滤波器能更好的抑制输入信号x[n]的高频分量? % Program P2_9 % Generate the input sequence clf; n = 0:300; a=pi/600; arg=a*n.*n; x=cos(arg); %x1 = cos(2*pi*10*n/256); %x2 = cos(2*pi*100*n/256); %x = x1+x2; % Compute the output sequences num1 = [0.5 0.27 0.77]; y1 = filter(num1,1,x); % Output of System #1 den2 = [1 -0.53 0.46]; num2 = [0.45 0.5 0.45]; y2 = filter(num2,den2,x); % Output of System #2 % Plot the output sequences subplot(2,1,1); plot(n,y1);axis([0 300 -2 2]); ylabel('Amplitude'); title('Output of System #1'); grid; subplot(2,1,2); plot(n,y2);axis([0 300 -2 2]); xlabel('Time index n'); ylabel('Amplitude'); title('Output of System #2'); grid; 图形显示如下: 答:由输出结果图形可以看出:y2滤波器能更好地抑制输入信号x[n]的高频分量。
本文档为【数字信号处理第二章实验报告】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_353097
暂无简介~
格式:doc
大小:97KB
软件:Word
页数:0
分类:工学
上传时间:2019-08-15
浏览量:24