信号与系统实验报告实验三周期信号的频谱分析学院专业班级学号指导教师实验报告评分:_______实验三 周期信号的频谱分析一、实验目的1、掌握连续时间周期信号的傅里叶级数的物理意义和分析方法;2、观察截短傅里叶级数而产生的“Gibbs 现象”,了解其特点以及产生的原因;3、掌握各种典型的连续时间非周期信号的频谱特征。
二、实验容实验前,必须首先阅读本实验原理,读懂所给出的全部例程序。
实验开始时,先在计算机上运行这些例程序,观察所得到的信号的波形图。
并结合例程序应该完成的工作,进一步分析程序中各个语句的作用,从而真正理解这些程序。
实验前,一定要针对下面的实验项目做好相应的实验准备工作,包括事先编写好相应的实验程序等事项。
Q3-1 编写程序Q3_1,绘制下面的信号的波形图:-+-=)5cos(51)3cos(31)cos()(000t t t t x ωωω∑∞==10)cos()2sin(1n t n n nωπ其中,ω0 = 0.5π,要求将一个图形窗口分割成四个子图,分别绘制cos(ω0t)、cos(3ω0t)、cos(5ω0t) 和x(t) 的波形图,给图形加title ,网格线和x 坐标标签,并且程序能够接受从键盘输入的和式中的项数。
抄写程序Q3_1如下: 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 time w0=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))')执行程序Q3_1所得到的图形如下:Q3-2给程序Program3_1增加适当的语句,并以Q3_2存盘,使之能够计算例题1中的周期方波信号的傅里叶级数的系数,并绘制出信号的幅度谱和相位谱的谱线图。
通过增加适当的语句修改Program3_1而成的程序Q3_2抄写如下:% Program3_1clear, close allT = 2; dt = 0.00001; t = -2:dt:2;x1 = u(t) - u(t-1-dt); x = 0;for m = -1:1 % Periodically extend x1(t) to form a periodic signalx = x + u(t-m*T) - u(t-1-m*T-dt);endw0 = 2*pi/T;N = 10; % The number of the harmonic componentsL = 2*N+1;for k = -N: N; % Evaluate the Fourier series coefficients akak(N+1+k) = (1/T)*x1*exp(-j*k*w0*t')*dt;endphi = angle(ak); % Evaluate the phase of aksubplot(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');执行程序Q3_2得到的图形Q3-3反复执行程序Program3_2,每次执行该程序时,输入不同的N值,并观察所合成的周期方波信号。
通过观察,你了解的吉伯斯现象的特点是:% Program3_3% This program is used to compute the Fourier series coefficients ak of a periodic square waveclear,close allT = 2; dt = 0.00001; t = -2:dt:2;x1 = u(t)-u(t-1-dt); x = 0;for m = -1:1x = x + u(t-m*T) - u(t-1-m*T-dt); % Periodically extend x1(t) to form a periodic signalendw0 = 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; % Synthesiz the periodic signal y(t) from the finite Fourier seriesy = 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=2通过观察我们了解到:如果一个周期信号在一个周期有断点存在,那么,引入的误差将除了产生纹波之外,还将在断点处产生幅度大约为9%的过冲(Overshot ),这种现象被称为吉伯斯现象(Gibbs phenomenon )。
即信号在不连续点附近存在一个幅度大约为9%的过冲,且所选谐波次数越多,过冲点越向不连续点靠近。
4、周期信号的傅里叶级数与GIBBS 现象给定如下两个周期信号:Q3-4 仿照程序Program3_1,编写程序Q3_4,以计算x 1(t)的傅里叶级数的系数。
程序Q3_4如下: clc,clear,close all T=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)); end w0=2*pi/T;t11-122-)(1t x )(2t x t22-12.02.0-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)');执行程序Q3_4所得到的x1(t)的傅里叶级数的ak从-10到10共21个系数如下:Q3-5仿照程序Program3_1,编写程序Q3_5,以计算x2(t) 的傅里叶级数的系数(不绘图)。
程序Q3_5如下:clc,clear,close allT=2;dt=0.00001;t=-3:dt:3;x=u(t+0.2)-u(t-0.2-dt);x2=0;for m=-1:1x2=x2+u(t+0.2-m*T)-u(t-0.2-m*T)-u(t-0.2-m*t-dt);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,x2);axis([-2.5 2.5 0 1.2]);grid on;title('The signal x2(t)');xlabel('Time t (sec)');ylabel('signal x2(t)');执行程序Q3_5所得到的x2(t)的傅里叶级数的ak从-10到10共21个系数如下:与你手工计算的ak相比较,是否相同,如有不同,是何原因造成的?Q3-6仿照程序Program3_2,编写程序Q3_6,计算并绘制出原始信号x1(t) 的波形图,用有限项级数合成的y1(t) 的波形图,以及x1(t) 的幅度频谱和相位频谱的谱线图。
编写程序Q3_6如下:%Program Q3_6%This program is used to evaluate the Fourier serier coefficients ak of a periodic squareclc,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:2 %Periodically extend x1(t) to form q periodic signalx1=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; %the number of the harmonic componentsL=2*N+1;for k=-N:N;ak(N+1+k)=(1/T)*x*exp(-j*k*w0*t')*dt;endphi=angle(ak); %Evaluate the phase of sky=0;for q=1:L; %Synthesiz the periodic signal y(t) from the finite Fourier seriesy=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');执行程序Q3_6,输入N = 10所得到的图形如下:反复执行程序Q3_6,输入不同的N值,观察合成的信号波形中,是否会产生Gibbs 现象?为什么?假定输入N=10,得到图形如下:所以不会产生Gibbs 现象,即与N 值无关。