内容发布更新时间 : 2024/11/6 7:32:50星期一 下面是文章的全部内容请认真阅读。
(3)反复执行程序Program3_2,每次执行该程序时,输入不同的N值,并观察所合成的周期方波信号。通过观察,你了解的吉伯斯现象的特点是:
程序如下:
clear,close all T = 2;
dt = 0.00001; t = -2:dt:2;
x1 = ut(t)-ut(t-1-dt); x = 0; for m = -1:1
x = x + ut(t-m*T) - ut(t-1-m*T-dt); end
w0 = 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; end
phi = 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=1
N=3
通过观察我们了解到:如果一个周期信号在一个周期有内断点存在,那么,引入的误差将除了产生纹波之外,还将在断点处产生幅度大约为9%的过冲(Overshot),这种现象被称为吉伯斯现象(Gibbs phenomenon)。即信号在不连续点附近存在一个幅度大约为9%的过冲,且所选谐波次数越多,过冲点越向不连续点靠近。
(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:2
x1=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; N=10; L=2*N+1;
for k=-N:N;
ak(N+1+k)=(1/T)*x*exp(-j*k*w0*t')*dt; end
phi=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 all T=2;
dt=0.00001; t=-3:dt:3;
x=ut(t+0.2)-ut(t-0.2-dt); x2=0;
for m=-1:1
x2=x2+ut(t+0.2-m*T)-ut(t-0.2-m*T)-ut(t-0.2-m*t-dt); end
w0=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; end
phi=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)');