1.2方波信号的合成 思考:
(1)参考实验原理内容解释下面程序中“f1=f1+cos(pi*n*t)*sinc(n/2)”;观察N值改变时合成波形的变化。
答:当N值变大时,其合成波形越接近于方波。
1?1, |t|?1, |t|?1??2(2)参考下面程序分别对x1(t)??和x2(t)??1?0, 1?|t|?2?0, ?|t|?12?两个周期为2的方波进行
合成,注意比较:
①原方波与合成方波; ②两个方波合成有何不同;
③当傅里叶级数项数增加时合成方波的变化。 程序(1):
X1(t):
t=-9:0.002:11;
t1=-8.999:0.002:11;
x=[ones(1,1000),zeros(1,1000)]; x=[x,x,x,x,x]; subplot(3,1,1);
plot(t1,x,'linewidth',1.5); title('方波');
axis([-9,11,-0.5,1.5]); N=10; c0=0.5;
f1=c0*ones(1,length(t)) for n=1:N
f1=f1+cos(0.5*pi*n*t)*sinc(n/2); end
subplot(3,1,2);
plot(t,f1,'r','linewidth',1.5); title('N=10时');
axis([-9,11,-0.5,1.5]); N=20; c0=0.5;
f1=c0*ones(1,length(t)) for n=1:N
f1=f1+cos(0.5*pi*n*t)*sinc(n/2); end
5
subplot(3,1,3);
plot(t,f1,'r','linewidth',1.5); title('N=20时');
axis([-9,11,-0.5,1.5]);
输出(1):
程序(2): X2(t):
t=-9:0.001:11; t1=-4.499:0.001:5.5;
x=[ones(1,1000),zeros(1,1000)]; x=[x,x,x,x,x]; subplot(3,1,1);
plot(t1,x,'linewidth',1.5); title('方波');
axis([-4.5,5.5,-0.5,1.5]); N=10; c0=0.5;
f1=c0*ones(1,length(t)) for n=1:N
f1=f1+cos(pi*n*t)*sinc(n/2); end
subplot(3,1,2);
plot(t,f1,'r','linewidth',1.5); title('N=10时');
6
axis([-4.5,5.5,-0.5,1.5]); N=20; c0=0.5;
f1=c0*ones(1,length(t)) for n=1:N
f1=f1+cos(pi*n*t)*sinc(n/2); end
subplot(3,1,3);
plot(t,f1,'r','linewidth',1.5); title('N=20时');
axis([-4.5,5.5,-0.5,1.5]); grid;
输出(2):
四、实验分析
本次实验算是对周期函数的合成与分解做了一个复习,通过程序与图的结合,更加具体的理解了两个周期函数的合成和一个周期函数的分解是如何完成的。而且在实验中,对于一些在Matlab软件的使用能力感觉也有所提高,也知道了一些句子的含义,体会了Matlab程序的方便快捷。
7