云文档网 - 专业文章范例文档资料分享平台

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

来源:网络收集 时间:2024-04-28 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xuecool-com或QQ:370150219 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

实 验

课 程:数字信号处理 专业班级: 学生姓名: 学 号:

年月

报 告

日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;

图形显示如下:

答:输入部分x?n?的高频成分x2?n?成分被抑制了。

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,仿真结果如下所示:

证明:设输入信号为x22?n??cos??n?,则x1?n?1??cos???n?1??以及x?n??cos???n?1??则

2y?n??x2?n??x1?n?x3?n??cos2?n??cos?ncos??sin?nsin????cos?ncos??sin?nsin???cos2?n?cos2?ncos2??sin2?nsin2??cos2?nsin2??sin2?nsin2??sin2?.答:从图形中可以看出,输入频率越大,输出信号值越小。最后都逐渐趋于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; 图形显示如下:

答:由结果表明,两个输出结果有没差别。有差别证明级联的顺序不可以互换,这里是一个验证程序。

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未到最后一个数值是此时S?K?的值已经小于10时,跳出

?6for循环。

2.33考虑用差分方程

y[n]?x[n]?4x[n?1]?3x[n?2]?1.7y[n?1]?y[n?2]

描述的离散时间系统。修改程序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]的高频分量。

百度搜索“yundocx”或“云文档网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,云文档网,提供经典综合文库数字信号处理第二章实验报告在线全文阅读。

数字信号处理第二章实验报告.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.yundocx.com/wenku/189879.html(转载请注明文章来源)
Copyright © 2018-2022 云文档网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:370150219 邮箱:370150219@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:7 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219