信号与系统实验报告实验三周期信号的频谱分析实验报告评分:_______实验三周期信号的频谱分析实验目的:1、掌握连续时间周期信号的傅里叶级数的物理意义和分析方法;2、观察截短傅里叶级数而产生的“Gibbs现象”,了解其特点以及产生的原因;3、掌握各种典型的连续时间非周期信号的频谱特征。
实验内容:(1)Q3-1 编写程序Q3_1,绘制下面的信号的波形图:其中,0 = 0.5π,要求将一个图形窗口分割成四个子图,分别绘制cos( 0t)、cos(3 0t)、cos(5 0t)和x(t) 的波形图,给图形加title,网格线和x坐标标签,并且程序能够接受从键盘输入的和式中的项数。
程序如下:clear,%Clear all variablesclose all,%Close all figure windowsdt = 0.00001; %Specify the step of time variable t = -2:dt:4; %Specify the interval of timew0=0.5*pi; x1=cos(w0.*t); x2=cos(3*w0.*t);x3=cos(5*w0.*t);N=input('Type in the number of the harmonic components N=');x=0;for q=1:N;x=x+(sin(q*(pi/2)).*cos(q*w0*t))/q;endsubplot(221)plot(t,x1)%Plot x1axis([-2 4 -2 2]);grid on,title('signal cos(w0.*t)')subplot(222)plot(t,x2)%Plot x2axis([-2 4 -2 2]); grid on,title('signal cos(3*w0.*t))')subplot(223)plot(t,x3)%Plot x3axis([-2 4 -2 2])grid on,title('signal cos(5*w0.*t))')subplot(224)plot(t,x)%Plot xtaxis([-2 4 -2 2])grid on,title('signal xt')(2)给程序3_1增加适当的语句,并以Q3_2存盘,使之能够计算例题1中的周期方波信号的傅里叶级数的系数,并绘制出信号的幅度谱和相位谱的谱线图。
程序如下:% Program3_1 clear, close allT = 2;dt = 0.00001;t = -2:dt:2;x1 = ut(t) - ut(t-1-dt);x = 0;for m = -1:1x = x + ut(t-m*T) - ut(t-1-m*T-dt);endw0 = 2*pi/T;N = 10;L = 2*N+1;for k = -N: N;ak(N+1+k) = (1/T)*x1*exp(-j*k*w0*t')*dt; endphi = angle(ak);subplot(211)'k = -10:10;stem (k,abs(ak),'k');axis([-10,10,0,0.6]);grid on;title('fudupu');subplot(212);k = -10:10stem(k,angle(ak),'k');axis([-10,10,-2,2]);grid on;titie('xiangweipu');xlabel('Frequency index x');(3)反复执行程序Program3_2,每次执行该程序时,输入不同的N值,并观察所合成的周期方波信号。
通过观察,你了解的吉伯斯现象的特点是:程序如下:clear,close allT = 2;dt = 0.00001;t = -2:dt:2;x1 = ut(t)-ut(t-1-dt);x = 0; for m = -1:1x = x + ut(t-m*T) - ut(t-1-m*T-dt);endw0 = 2*pi/T;N = input('Type in the number of the harmonic components N = :');L = 2*N+1;for k = -N:1:N;ak(N+1+k) = (1/T)*x1*exp(-j*k*w0*t')*dt; endphi = angle(ak);y=0;for q = 1:L;y = y+ak(q)*exp(j*(-(L-1)/2+q-1)*2*pi*t/T); end;subplot(221),plot(t,x),title('The original signal x(t)'),axis([-2,2,-0.2,1.2]),subplot(223),plot(t,y),title('The synthesis signal y(t)'),axis([-2,2,-0.2,1.2]),xlabel('Time t'),subplot(222)k=-N:N;stem(k,abs(ak),'k.'),title('The amplitude |ak| of x(t)'),axis([-N,N,-0.1,0.6])subplot(224)stem(k,phi,'r.'),title('The phase phi(k) of x(t)'),axis([-N,N,-2,2]),xlabel('Index k')N=1N=3通过观察我们了解到:如果一个周期信号在一个周期有内断点存在,那么,引入的误差将除了产生纹波之外,还将在断点处产生幅度大约为9%的过冲(Overshot),这种现象被称为吉伯斯现象(Gibbs phenomenon)。
即信号在不连续点附近存在一个幅度大约为9%的过冲,且所选谐波次数越多,过冲点越向不连续点靠近。
(4)计算如图的傅里叶级数的系数程序如下:clc,clear,close allT=2;dt=0.00001;t=-3:dt:3;x=(t+1).*(u(t+1)-u(t))-(t-1).*(u(t)-u(t-1));x1=0; for m=-2:2x1=x1+(t+1-m*T).*(u(t+1-m*T)-u(t-m*T))-(t-1-m*T).*(u(t-m *T)-u(t-1-m*T));endw0=2*pi/T;N=10;L=2*N+1;for k=-N:N;ak(N+1+k)=(1/T)*x*exp(-j*k*w0*t')*dt;endphi=angle(ak);plot(t,x1);axis([-4 4 0 1.2]);grid on;title('The signal x1(t)'); xlabel('Time t (sec)'); ylabel('signal x1(t)');(5)仿照程序3_1,编写程序Q3_5,以计算x2(t) 的傅里叶级数的系数(不绘图)。
程序如下:clc,clear,close allT=2;dt=0.00001;t=-3:dt:3;x=ut(t+0.2)-ut(t-0.2-dt);x2=0;for m=-1:1x2=x2+ut(t+0.2-m*T)-ut(t-0.2-m*T)-ut(t-0.2-m*t-dt); endw0=2*pi/T;N=10;L=2*N+1for k=-N:N;ak(N+1+k)=(1/T)*x*exp(-j*k*w0*t')*dt;endphi=angle(ak);plot(t,x2);axis([-2.5 2.5 0 1.2]);grid on;title('The signal x2(t)');xlabel('Time t (sec)');ylabel('signal x2(t)');(6)仿照程序3_2,编写程序Q3_6,计算并绘制出原始信号x1(t) 的波形图,用有限项级数合成的y1(t) 的波形图,以及x1(t) 的幅度频谱和相位频谱的谱线图。
程序如下:clc,clear,close allT=2;dt=0.00001;t=-3:dt:3;x=(t+1).*(ut(t+1)-ut(t))-(t-1).*(ut(t)-ut(t-1));x1=0;for m=-2:2x1=x1+(t+1-m*T).*(ut(t+1-m*T)-ut(t-m*T))-(t-1-m*T).*(ut( t-m*t)-ut(t-1-m*t));endw0=2*pi/T;N=10;L=2*N+1;for k=-N:N;ak(N+1+k)=(1/T)*x*exp(-j*k*w0*t')*dt;endphi=angle(ak);y=0;for q=1:L;y=y+ak(q)*exp(j*(q-1-N)*w0*t);end;subplot(221)plot(t,x)%plot xaxis([-3 3 -0.2 1.2]);grid on;title('The original signal x(t)'); subplot(223)plot(t,y)%Plot yaxis([-3 3 -0.2 1.2]);grid on;title('The synthesis signal y(t)'); subplot(222);xlabel('Time i (sec)');subplot(222);k=-N:N;stem(k,abs(ak),'k');axis([-N N -0.1 0.6]);grid on;title('The amplitude spectrum of x(t)'); subplot(224);k=-N:N;stem(k,phi,'k');axis([-N N -2 2]);grid on;title('The phase spectrum of x(t)');xlabel('Frequency index k');实验心得:在实验的过程中,掌握连续时间周期信号的傅里叶级数的物理意义和分析方法,观察截短傅里叶级数而产生的“Gibbs现象”,了解其特点以及产生的原因,掌握各种典型的连续时间非周期信号的频谱特征。