资源描述
close all;clear all
%======内容1:调用filter解差分方程,由系统对u(n)的响应判断稳定性
A=[1,-0.9];B=[0.05,0.05];
x1n=[1 1 1 1 1 1 1 1 zeros(1,50)];
x2n=ones(1,128);
hn=impz(B,A,58); %求系统单位脉冲响应h(n)
subplot(2,2,1);stem(hn);
title('(a) 系统单位脉冲响应h(n)');
y1n=filter(B,A,x1n);
subplot(2,2,2);stem(y1n);
title('(b) 系统对R8(n)的响应y1(n)');
y2n=filter(B,A,x2n);
subplot(2,2,4);stem(y2n);
title('(c) 系统对u(n)的响应y2(n)');
%===内容2:调用conv函数计算卷积============================
x1n=[1 1 1 1 1 1 1 1 ]; %产生信号x1(n)=R8(n)
h1n=[ones(1,10) zeros(1,10)];
h2n=[1 2.5 2.5 1 zeros(1,10)];
y21n=conv(h1n,x1n);
y22n=conv(h2n,x1n);
figure(2)
subplot(2,2,1);stem(h1n);
title('(d) 系统单位脉冲响应h1(n)');
subplot(2,2,2);stem(y21n);
title('(e) h1(n)与R8(n)的卷积y21(n)');
subplot(2,2,3); stem(h2n);
title('(f) 系统单位脉冲响应h2(n)');
subplot(2,2,4);stem(y22n);
title('(g) h2(n)与R8(n)的卷积y22(n)');
%=========内容3:谐振器分析========================
un=ones(1,256);
n=0:255;
xsin=sin(0.014*n)+sin(0.4*n);
A=[1,-1.8237,0.9801];B=[1/100.49,0,-1/100.49];
y31n=filter(B,A,un);
y32n=filter(B,A,xsin);
figure(3)
subplot(2,1,1);stem(y31n);
title('(h) 谐振器对u(n)的响应y31(n)');
subplot(2,1,2);stem(y32n);
title('(i) 谐振器对正弦信号的响应y32(n)');
展开阅读全文