资源描述:
《吉布斯现象的matlab代码实现.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、第一题:代码clear;closeall;clc;t=-2:0.01:2;T=[15,25,51,101];fork=1:length(T)a=0;forn=1:2:T(k)b=exp(1i*n*pi*t)/n;a=a+b;endy=2*a/(1j*pi);x=0.5*square(pi*t);figure;p=plot(t,real(y),t,x);axis([-2,2,-0.8,0.8]);set(gca,'XTick',-2:1:2)set(gca,'YTick',-0.8:0.4:0.8)se
2、t(gca,'XTickLabel',{'-2','-1','0','1','2'})set(gca,'YTickLabel',{'-0.8','-0.4','0','0.4','0.8'})xlabel('自变量')ylabel('函数值')titlemsg=sprintf('吉布斯现象N=%d的合成波形',T(k));title(titlemsg)text(0,-0.5,'leftarrow方波函数','HorizontalAlignment','left')set(gcf,'Color','w
3、')%holdonEnd第二题代码clear;closeall;clc;t=-2:0.01:2;T=[15,25,51,101];fork=1:length(T)a=0;forn=1:2:T(k)b=exp(1i*n*pi*t)/n;a=a+b;endy=2*a/(1j*pi);x=0.5*square(pi*t);%figure;if(k==1)p=plot(t,real(y),'c',t,x,'k');elseif(k==2)p=plot(t,real(y),'m',t,x,'k');elseif
4、(k==3)p=plot(t,real(y),'r',t,x,'k');elseif(k==4)p=plot(t,real(y),'b',t,x,'k');endaxis([-2,2,-0.8,0.8]);set(gca,'XTick',-2:1:2)set(gca,'YTick',-0.8:0.4:0.8)set(gca,'XTickLabel',{'-2','-1','0','1','2'})set(gca,'YTickLabel',{'-0.8','-0.4','0','0.4','0.8'})
5、xlabel('自变量')ylabel('函数值')titlemsg=sprintf('吉布斯现象N=%d的合成波形',T(k));title(titlemsg)text(0,-0.5,'leftarrow方波函数','HorizontalAlignment','left')set(gcf,'Color','w')holdonEnd第三题1、傅里叶级数随着N增加,其合成的波形就就越接近方波2、随着N增加,波动就越向边缘点压缩靠近3、当选取的项数越多,在所合成的波形中出现的峰起越靠近原信号的不连续点第
6、四题1、一次谐波角频率2rad/s,三次6rad/s,五次10rad/s2、一次谐波的系数是4/,三次谐波的系数是4/,五次谐波的系数是4/3、N次谐波的系数是4/