郑君里,信号与系统,P99-100,傅里叶级数近似方波。
clc; clear; E = 1; Amp = E/2; n = 5; T = 1; w = 2*pi/T; t = -1:0.0001:1; % Generate the fourier function fun = zeros(size(t)); for i=1:n fun = fun + (2*E/pi) * (1/i)*sin(i*pi/2)*cos(i*w*t); end figure(1); plot(t, fun, 'r'); hold on; % Generate the step wave f=@(x)( -Amp*heaviside(x+3*T/4)+2*Amp*heaviside(x+T/4)-2*Amp*heaviside(x-T/4)+2*Amp*heaviside(x-3*T/4) ); fplot(f,[-1 1]);axis([-T T -0.8 0.8]) title(['傅里叶级数近似,n=',num2str(n)])
验证吉布斯现象:
当选取有限项傅里叶级数时,在所合成的波形中出现的峰起越靠近f(t)的不连续点,第五章证明当N很大时,峰起趋于一个常数,约等于总跳变的9%,并从不连续点开始以起伏震荡的形式逐渐衰减下去,此现象成为吉布斯现象。
通过matlab程序验证吉布斯现象。
clc; clear; E = 1; Amp = E/2; n = 50; T = 1; w = 2*pi/T; t = -1:0.0001:1; % Generate the fourier function for j=1:200 fun = zeros(size(t)); for i=1:j fun = fun + (2*E/pi) * (1/i)*sin(i*pi/2)*cos(i*w*t); end funmax(j) = max(fun)-0.5; end figure(1); plot(t, fun, 'r'); hold on; % Generate the step wave f=@(x)( -Amp*heaviside(x+3*T/4)+2*Amp*heaviside(x+T/4)-2*Amp*heaviside(x-T/4)+2*Amp*heaviside(x-3*T/4) ); ezplot(f,[-1 1]);axis([-T T -0.8 0.8]) figure(2); plot(funmax)
图片见:http://hi.baidu.com/yorkbluedream/blog/item/023cf5debeaaa755ccbf1a0f.html