离散LSI系统分析 下载本文

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('Inpulse Response'); ylabel('h[n+5]'); %output response [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); if nargin ~=3

disp('Usage:Y=stepseq(n0,n1,n2)'); elseif((n0n2)|(n1>n2))

error('arguments must satisfy n1<=n0<=2') end n=[n1:n2]; x=[(n-n0)>=0];

conv_m.m的源程序如下:

function[y,cy]=conv_m(x,nx,h,nh) if nargin~=4

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

nyb=nx(1)+nh(1);

nye=nx(length(x))+nh(length(x)); ny=[nyb:nye]; y=conv(x,h);

3.设h[n]?(0.9)nu[n],输入x[n]?u[n]?u[n?10],求系统输出y[n]?x[n]*h[n]:

n=-5:50;

u1=stepseq(0,-5,50);u2=stepseq(10,-5,50);%u1=u[n];u2=u[n-10] %input x[n] x=u1-u2;

%impluse response h[n] h=((0.9).^n).*u1;

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 Response'); ylabel('h[n]'); %output response [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); if nargin ~=3

disp('Usage:Y=stepseq(n0,n1,n2)'); elseif((n0n2)|(n1>n2))

error('arguments must satisfy n1<=n0<=2') end n=[n1:n2]; x=[(n-n0)>=0];

conv_m.m的源程序如下:

function[y,cy]=conv_m(x,nx,h,nh) if nargin~=4

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

nyb=nx(1)+nh(1);

nye=nx(length(x))+nh(length(x)); ny=[nyb:nye]; y=conv(x,h);

思考题:在此问题中h[n]为无限长序列,在计算卷积和时应如何处理? 解:取尽可能多的包含能量分布集中的具有代表性的点

4某离散时间线性时不变系统的差分方程为:y[n]?0.8[n?1]?x[n] a.计算n?[?10:50]时的系统冲激响应h[n] b.计算n?[?10:50]时的系统阶跃响应s[n]

a=[1,-0.8];b=1;n=[-10:50]; x=impseq(0,-10,50);

h=filter(b,a,x);%MATLAB固有函数filter表示系统方程ay=bx;x是冲击信号,则h就是冲击响应 subplot(2,1,1);stem(n,h);

title('Inpulse Response');xlabel('n');ylabel('h[n]'); x=stepseq(0,-10,50);

s=filter(b,a,x); %x是阶跃信号,则s就是阶跃响应 subplot(2,1,2);stem(n,s);

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

impseq.m的源程序如下:

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

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

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

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

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

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

stepseq.m的源程序如下:

function [x,n]=stepseq(n0,n1,n2); if nargin ~=3

disp('Usage:Y=stepseq(n0,n1,n2)'); elseif((n0n2)|(n1>n2))

error('arguments must satisfy n1<=n0<=2') end n=[n1:n2]; x=[(n-n0)>=0];