3、a,b)y=quad1(4funca,b,TOL,TRACE,p1,p2,...)其中fimc是一个字符串,表示被积函数4实验内容与方法(1)周期信号的傅里叶级数的Matlab实现①利用Matlab画出周期三角波信号的频谱。源程序如下:N=10;nl=-N:-l;cl=-4*j*sin(nl*pi/2)/piA2./nl.A2;c0=0;n2=l:N;c2=-4*j*sin(n2*pi/2)/piA2./nl.A2;cn=[clcOc2];n=-N:N;subplot211;stem(n,abs(cn));ylabel(1c
4、n的幅度');subplot212;stem(n,angle(cn));ylabel(1cn的木目位');xlabel(1omega/omega_01)程序运行结果如卜•图1所示0.50.4轻0.3M0.2CO0.1-1021046810半Iwuo-1图1②周期矩形脉冲幅度为1,脉冲宽度为tao=l,周期T=5*tao,试求出该信号的三角形式的傅里叶系数,并绘出各次谐波叠加的傅里叶综合波形图。源程序如下:%周期矩形脉冲函数的合成function[A_sym,B_sym]=CTFSchsymsymstnkx;T=5;tao=
5、0.2*T;a=0.5;ifnargin<4;Nf=6;endifnargin<5;Nn=32;endx=time_fun_x(t);AO=2*int(xztz-a,T-a)/T;As=int(2*x*cos(2*pi*n*t/T)/T,t,-a,T-a);Bs=int(2*x*sin(2*pi*n*t/T)/Tzt,-azT-a);A_sym(1)=double(vpa(AO,Nn));fork=l:NfA_sym(k+1)=double(vpa(subs(Asznzk),Nn));B_sym(k+1)=double(vpa
6、(subs(Bs,n,k),Nn));endifnargout==0c=A_sym;disp(c)d=B_sym;disp(d)t=-8*a:0.01:T-a;fl=0.2/2+0.187l.*cos(2*pi*l*t/5)+0.*sin(2*pi*l*t/5);f2=0.1514.*cos(2*pi*2*t/5)+0.*sin(2*pi*2*t/5);f3=0.1009.*cos(2*pi*3*t/5)+0.*sin(2*pi*3*t/5);f4=0.0468.*cos(2*pi*4*t/5)+0.*sin(2*pi*4*t
7、/5);f5=-0.0312.*cos(2*pi*6壮/5)+0・*sin(2*pi*6壮/5);f6=fl+f2;f7=f6+f3;f8=f7+f4+£5;subplot221plot(t,f1),holdony=ti(t);plot(tryr'r:')title(•周期矩形波的形成一基波*)axis([-4,4.5,-0.1zl.l])subplot222plot(t,f6),holdony=time_fun_e(t);plot(t,y,'r:')title(,周期矩形波的形成一一基波+二次谐波Taxis([-4,4.5,
8、-0.1,1.1])subplot223plot(tzf7)zholdony=time_f(t);plot(t,yz'r:')title(*慕波+二次谐波+三次谐波•)axis([-4z4.5Z-0.1,1.1])subplot224plot(t,f8),holdony=ti