您的当前位置:首页正文

信号系统实验四

2020-08-20 来源:易榕旅网


《信号与系统》实验报告

实验名称:姓 名:学 院:专 业:班 级:学 号:指导教师:实验地址:实验日期:

离散线性时不变系统分析 崔兆文

计算机科学与工程学院 网络工程 网络152 092715206 秦湘平 N6-109 2018.5.7

1.设某LTI系统的h[n]=δ[n-5],输入x[n]=u[n]-u[n-5],求系统输出y[n]=x[n]*h[n]。 思考题:若y[n]=x[n]*δ[n-n0],试写出y[n]与x[n]的关系,并对比MATLAB仿真结果。

lab21a.m源程序 clear;clf;clc; n=[-5:20];

h=delta(n-5);x=stepseq(0,-5,20)-stepseq(5,-5,20); [y,ny]=conv_m(x,n,h,n)

subplot(2,2,1);stem(n,x);title('x[n]');xlabel('n');axis([-5,20,0,1,2]);grid on; subplot(2,2,2);stem(n,h);title('h[n]');xlabel('n');axis([-5,20,0,1,2]);grid on; subplot(2,2,3);stem(ny,y);title('y[n]');xlabel('n');axis([-5,20,0,1,2]);grid on;

stepseq.m源程序

function [x,n]=stepseq(n0,n1,n2)

%Generates x(n)=u(n-n0);n1<=n<=n2,n1<=n0<=n2 %[x,n]=stepseq(n0,n1,n2) if nargin ~=3

disp('Usage:Y=stepseq(nO,n1,n2) return;

elseif((n0n2)|(n1>n2))

error('arguments must satisfy n1<=n0<=n2') end

n=[n1:n2]; x=[(n-n0)>=0];

conv_m.m源程序

function[y,ny]=conv_m(x,nx,h,nh)

%modified convolution routine for signal processing %[y,ny]=conv_m(x,nx,h,nh) %y=convolution result %ny=support of y

%x=first signal on support nx %nx=support of x

%h=second signal on support nh %nh=support of h if nargin~=4

disp('Usage:Y=conv_m(x,nx,h,nh)'); return; end;

nyb=nx(1)+nh(1);%ny's beginning

nye=nx(length(x))+nh(length(h));%ny's end ny=[nyb:nye]%ny

y=conv(x,h);%Convolution and polynomial multiplication;

delta源程序

function y=delta(x) y=(x==0); 效果图:

2.设某LTI系统的h[n]= ﹛

n0n50其他,输入信号为x[n]=﹛

1,0n50其他,

a.求输出y1[n]=x[n]*h[n];

b.求输出y2[n]=x[n]*h[n+5]。

思考题:若y[n]=x[n]*h[n],y1[n]=x[n-n1]*h[n-n2],试写出y1[n]与y[n]的关系。

lab22a.m源程序 n=-5:20;

u1=stepseq(0,-5,200;u2=stepseq(6,-5,20);%u1=u[n];u2=u[n-6] %input x[n] x=u1-u2;

%impulse response h[n] h=n.*x;

subplot(3,1,1);stem(n,x);axis[-5,20,0,2];title('Input Sequence');ylabel('x[n]'); subplot(3,1,2);stem(n,h);axis[-5,20,0,6];title('Inpulse Resquence');ylabel('h[n]'); %output response

[y1,ny]=conv_m(x,n,h,n);

subplot(3,1,3);stem(ny,y1);title(‘Output Sequence”);xlabel(‘n’);ylabel(‘y_1[n]’);

效果图:

lab22b.m的源程序如下: n=-10:20;

u1=stepseq(0,-10,20);u2=stepseq(6,-10,20); x=u1-u2;

u3=stepseq(-5,-10,20);u4=stepseq(1,-10,20); x1=u3-u4; h=(n+5).*x1;

subplot(3,1,1);stem(n,x);axis([-10,20,0,2]);title(‘Input Sequence’);ylabel(‘x[n]’);

subplot(3,1,2);stem(n,h);axis([-10,20,0,6]);title(‘Impluse Response’);ylabel(‘h[n+5]’); [y2,ny]=conv_m(x,n,h,n);

Subplot(3,1,3);stem(ny,y2);title(‘Output Sequence’);xlabel(‘n’);ylabel(‘y_2[n]’); 效果图:

Stepseq.m源程序

function [x,n]=stepseq(n0,n1,n2)

%Generates x(n)=u(n-n0);n1<=n<=n2,n1<=n0<=n2 %[x,n]=stepseq(n0,n1,n2) if nargin ~=3

disp('Usage:Y=stepseq(nO,n1,n2) return;

elseif((n0n2)|(n1>n2))

error('arguments must satisfy n1<=n0<=n2') end

n=[n1:n2]; x=[(n-n0)>=0];

conv_m.m源程序:

function[y,ny]=conv_m(x,nx,h,nh)

%modified convolution routine for signal processing %[y,ny]=conv_m(x,nx,h,nh) %y=convolution result %ny=support of y

%x=first signal on support nx %nx=support of x

%h=second signal on support nh %nh=support of h if nargin~=4

disp('Usage:Y=conv_m(x,nx,h,nh)'); return; end;

nyb=nx(1)+nh(1);%ny's beginning

nye=nx(length(x))+nh(length(h));%ny's end ny=[nyb:nye]%ny

y=conv(x,h);%Convolution and polynomial multiplication;

3. 设h[n]=(0.9)nu[n],输入x[n]=u[n]-u[n-10],求系统输出y1[n]=x[n]*h[n]. 思考题:在此问题中,h[n]为无限长序列,在计算卷积和时应该如何处理?

lab23.m的源程序如下: n=-5:50;

u1=stepseq(0,-5,50);u2=stepseq(10,-5,50); x=u1-u2;

h=((0.9).^n).*u1;

subplot(3,1,1);stem(n,x);axis([-5,50,0,2]);title(‘Input Sequence’);ylabel(‘x[n]’);

subplot(3,1,2);stem(n,h);axis([-5,50,0,2]);title(‘Impulse Response’);ylabel(‘h[n]’); [y,ny]=conv_m(x,n,h,n);

Subplot(3,1,3);stem(ny,y);title(‘Output Sequence’);xlabel(‘n’);ylabel(‘y[n]’); 效果图:

Stepseq.m源程序

function [x,n]=stepseq(n0,n1,n2)

%Generates x(n)=u(n-n0);n1<=n<=n2,n1<=n0<=n2 %[x,n]=stepseq(n0,n1,n2) if nargin ~=3

disp('Usage:Y=stepseq(nO,n1,n2) return;

elseif((n0n2)|(n1>n2))

error('arguments must satisfy n1<=n0<=n2') end

n=[n1:n2]; x=[(n-n0)>=0];

conv_m.m源程序

function[y,ny]=conv_m(x,nx,h,nh)

%modified convolution routine for signal processing %[y,ny]=conv_m(x,nx,h,nh) %y=convolution result %ny=support of y

%x=first signal on support nx %nx=support of x

%h=second signal on support nh %nh=support of h if nargin~=4

disp('Usage:Y=conv_m(x,nx,h,nh)');

return; end;

nyb=nx(1)+nh(1);%ny's beginning

nye=nx(length(x))+nh(length(h));%ny's end ny=[nyb:nye]%ny

y=conv(x,h);%Convolution and polynomial multiplication;

4. 某离散时间LTI系统的差分方程为:y[n]-0.8[y-1]=x[n] a.计算n=[-10:50]时的系统冲击响应h[n]; b.计算n=[-10:50]时的系统阶跃响应s[n]. 思考题:(1)写出该系统的单位脉冲响应的理论表达式,并与MATLAB仿真结果对比;

(2)写出h[n]与s[n]的相互关系,即如何用s[n]表示h[n],以及如何用h[n]表示s[n]。

lab24.m的源程序如下: a=[1,-0.8];b=1;n=[-10:50]; x=impseq(0,-10,50); h=filter(b,a,x);

subplot(2,1,1);stem(n,h);

title(‘Impulse Response’);xlabel(‘n’);ylabel(‘h[n]’); x=stepseq(0,-20,100); s=filter(b,a,x);

subplot(2,1,2);stem(n,s);

title(‘Step Response’);xlabel(‘n’);ylabel(‘s[n]’);

impseq.m的源程序如下: function [x,n]=impseq(n0.n1,n2) if nargin~=3

disp(‘Usage:Y=impseq(n0,n1,n2)’); return;

elseif((n0n2)|(n1error(‘arguments must satisfy n1<=n0<=n2’) end

n=[n1:n2]; x=[(n-n0)==0];

stepseq.m源程序

function [x,n]=stepseq(n0,n1,n2)

%Generates x(n)=u(n-n0);n1<=n<=n2,n1<=n0<=n2 %[x,n]=stepseq(n0,n1,n2) if nargin ~=3

disp('Usage:Y=stepseq(nO,n1,n2)

return;

elseif((n0n2)|(n1>n2))

error('arguments must satisfy n1<=n0<=n2') end

n=[n1:n2]; x=[(n-n0)>=0];

效果图:

实验小结:

本次实验学习了离散线性时不变系统分析的相关内容,主要考察了LTI系统一定条件下的系统输出。思考题感觉挺难的要注意很多方面。

因篇幅问题不能全部显示,请点此查看更多更全内容