stem(n,x3);
title('20.*0.5.^n.*([n>=4]-[n>=10])'); xlabel('n'); ylabel('x(n)');
x4=n.*n.*([n>=-5]-[n>=6])+10.*[n==0]+20.*0.5.^n.*([n>=4]-[n>=10]); subplot(2,2,4); stem(n,x4); title('x1+x2+x3'); xlabel('n'); ylabel('x(n)');
运行结果:
5
第二题第二小题
源代码:
n=-20:0.5:20; x1=cos(0.3.*pi.*n); x2=cos(0.4.*pi.*n); subplot(3,1,1); stem(n,x1);
title('cos(0.3.*pi.*n)');xlabel('n'); ylabel('x1(n)'); grid on; subplot(3,1,2); stem(n,x2);
title('cos(0.4.*pi.*n)');xlabel('n'); ylabel('x2(n)'); grid on;
n=-40:0.5:40; x1=cos(0.3.*pi.*n); subplot(3,1,3); stem(n,x1);
title('cos(0.3.*pi.*n)');xlabel('n'); ylabel('x1(n)'); grid on;
6
运行结果:
A小问:cos(0.3pin)(-20<=n<=20)的基本周期是20,cos(0.4pin)(-20<=n<=20)的基本周期是5。N和K的意义是:
答:由上图可以看出cos(0.3*pi*n)是周期序列,基本的周期是20.序列cos(0.4*pi*n)是周期为5的周期序列。对比两者可得N实际上是基波的周期,基波的频率为2*pi/N而K是一个任意的正整数与N互为素数。
B小问:cos(0.3pin)(-40<=n<=40)序列是周期的,周期是20。结论是周期只与cos(wn)中的w有关,在计算机中,pi被定义为有限长小数,所以周期相同。
答:此序列是非周期的,对比a组中的结论我们可得到一下结论:1)当2*pi/w0是整数或者有理数时,K取适当的整数值可以得到最小周期如前两个图所示;2)当2*pi/w0是一个无理数时,任何的K值都不能使得N为正整数,所以余弦序列是非周期的,如第三个图所示。
7
实验二:
第一题(书上有参考代码,不再赘述)
运行结果:
第二题:
源代码:
p=[0.25,0.25,0.25,0.25]; d=[1]; n=-5:0.5:20; x=[n==0]; x=double(x); h=filter(p,d,x); subplot(2,1,1); stem(n,h);
title('impulse response'); xlabel('time'); ylabel('amplitude'); x=[n>=0];
8
x=double(x); s=conv(x,h); subplot(2,1,2); n=-10:0.5:40; stem(n,s);
title('step response'); xlabel('time'); ylabel('amplitude');
运行结果:
理论计算结果及对比分析:
答:通过理论计算得到n=0,1,2,3,4五个点的结果分别为:
n=0: h(n)=0
n=1,2,3,4时 h(n)=0.25
利用得到的单位冲击响应函数求得卷积的结果(取五个点)分别为0,0.25,0. 5,0.75,1
对比图像,理论结果与实验结果一致
9