您好,欢迎访问三七文档
实验三:周期信号的傅利叶级数分析及MATLAB实现学院:信息学院专业:通信工程(武警国防生)指导教师:肖琦姓名:梁由勇学号:20081060094成绩:实验目的:1.用MATLAB实现周期信号的傅利叶级数;2.用MATLAB实现周期信号(包括典型周期信号)的频谱分析;3.观察利用MATLAB生成的图形及结果,与信号与系统理论知识相连系,加深对信号与系统理论知识的深入理解。9.1已知周期半波余弦信号和周期全波余弦信号的波形分别如图所示(图略),用MATLAB编程求出它们的傅里叶系数,绘出其直流、一次、二次、三次、四次及五次谐波叠加后的波形图,并将其与原周期信号的时域波形进行比较,观察周期信号的分解与合成过程。解:%观察周期余弦半波信号的分解和合成%m:傅立叶级数展开的项数display('Pleaseinputthevalueofm(傅立叶级数展开的项数)');m=input('m=');t=-2.5*pi:0.01:2.5*pi;t1=-0.5*pi:0.01:0.5*pi;n=round(length(t)/5);f=[cos(t1)';zeros(n-1,1);cos(t1)';zeros(n-1,1);cos(t1)'];y=zeros(m+1,max(size(t)));y(m+1,:)=f';subplot((m+2),1,1)plot(t/pi,y(m+1,:));grid;axis([-2.52.5-0.51.5]);title('周期半波余弦信号');xlabel('t/pi','Fontsize',8);x=zeros(size(t));kk='1';%计算系数symstxnT=2*pi;fx=sym('cos(tx)');Nn=30;an=zeros(m+1,1);bn=zeros(m+1,1);A0=2*int(fx,tx,-T/4,T/4)/T;An=2*int(fx*cos(2*pi*(n+eps/2)*tx/T),tx,-T/4,T/4)/T;Bn=2*int(fx*sin(2*pi*(n+eps/2)*tx/T),tx,-T/4,T/4)/T;an(1)=double(vpa(A0,Nn));an(2)=0.5;fork=2:man(k+1)=double(vpa(subs(An,n,k),Nn));bn(k+1)=double(vpa(subs(Bn,n,k),Nn));end%计算直流分量pause;x=an(1)*cos(0*t)/2;plot(t/pi,y(m+1,:));holdon;信号与线性系统分析实验2plot(t/pi,x);grid;holdoff;axis([-2.52.5-0.51.5]);title('直流分量');xlabel('t/pi','Fontsize',8);%各次谐波叠加fork=1:mpause;x=x+an(k+1).*cos(k*t);y(k,:)=x;subplot((m+2),1,k+1);plot(t/pi,y(m+1,:));holdon;plot(t/pi,y(k,:));holdoff;grid;axis([-2.52.5-0.51.5]);title(strcat('第',kk,'次谐波叠加'));xlabel('t/pi','Fontsize',8);kk=strcat(kk,'、',num2str(k+1));endpause;subplot((m+2),1,m+2)plot(t/pi,y(1:m+1,:));grid;axis([-2.52.5-0.51.5]);title('各次谐波叠加波形');xlabel('t/pi','Fontsize',8);%End%观察周期余弦全波信号的分解和合成%m:傅立叶级数展开的项数display('Pleaseinputthevalueofm(傅立叶级数展开的项数);t=-2.5*pi:0.01:2.5*pi;t1=-0.5*pi:0.01:0.5*pi-0.01;n=round(length(t)/5);f=[cos(t1)';cos(t1)';cos(t1)';cos(t1)';cos(t1)';0];y=zeros(m+1,max(size(t)));y(m+1,:)=f';subplot(m+2,1,1)plot(t/pi,y(m+1,:));gridon;axis([-2.52.5-0.21.2]);title('周期全波余弦信号');xlabel('t/pi','Fontsize',8);x=zeros(size(t));kk='1';%计算系数信号与线性系统分析实验3symstxnT=pi;fx=sym('cos(tx)');Nn=32;an=zeros(m+1,1);bn=zeros(m+1,1);A0=2*int(fx,tx,-T/2,T/2)/T;An=2*int(fx*cos(2*pi*(n+eps/2)*tx/T),tx,-T/2,T/2)/T;Bn=2*int(fx*sin(2*pi*(n+eps/2)*tx/T),tx,-T/2,T/2)/T;an(1)=double(vpa(A0,Nn));fork=1:man(k+1)=double(vpa(subs(An,n,k),Nn));bn(k+1)=double(vpa(subs(Bn,n,k),Nn));end%求直流信号pause;x=an(1)*cos(0*t)/2;subplot(m+2,1,1)plot(t/pi,y(m+1,:));holdon;plot(t/pi,x);gridon;holdoff;axis([-2.52.5-0.21.2]);title('周期全波余弦信号');xlabel('t/pi','Fontsize',8);%各次谐波叠加fork=1:mpause;x=x+an(k+1).*cos(2*k*t);y(k,:)=x;subplot(m+2,1,k+1)plot(t/pi,y(m+1,:));holdon;plot(t/pi,y(k,:));holdoff;gridon;axis([-2.52.5-0.21.2]);title(strcat('第',kk,'次谐波叠加'));xlabel('t/pi','Fontsize',8);kk=strcat(kk,'、',num2str(k+1));endpause;subplot(m+2,1,m+2)plot(t/pi,y(1:m+1,:));gridon;axis([-2.52.5-0.21.2]);title('各次次谐波叠加波形');xlabel('t/pi','Fontsize',8);%End9.2试用MATLAB编程会出9.1中所示周期信号的幅度频谱,要求交互式输入信号周期,观察分析信号周期与频谱的关系。当周期T趋于无穷大时,频谱谱线将发生什么样的变化?信号与线性系统分析实验4解:symsTnt;display('PleaseinputthevalueofNF,T,tao');Nf=input('Nf=');T=input('T=');tao=input('tao=');an=2/T*int(2/T*t*cos(2*pi*n*t/T),t,0,tao);bn=2/T*int(2/T*t*sin(2*pi*n*t/T),t,0,tao);a1n=zeros(1,Nf+1);b1n=zeros(1,Nf+1);cn=zeros(1,Nf+1);cn(1)=1/2;fori=2:Nf+1a1n(i)=subs(an,n,i);b1n(i)=subs(bn,n,i);cn(i)=(a1n(i)^2+b1n(i)^2)^(1/2);endk=0:Nf;stem(k,cn);holdonplot(k,cn);title(strcat('幅度频谱,周期、时域信号分别为',num2str(T),'和',num2str(tao)));xlabel(strcat('谐波次数',k));运行:Pleaseinputthevalueofm(傅立叶级数展开的项数)Pleaseinputthevalueofm(傅立叶级数展开的项数)PleaseinputthevalueofNF,T,taoNf=30T=2*pitao=pitao=pi/2信号与线性系统分析实验5tao=pi/4固定tao=1,Nf=30改变T分别为2*pi,4*pi,8*pi图形分别如下:T=2*piT=8*pi信号与线性系统分析实验6T=4*pi9.3已知周期锯齿脉冲信号如图所示(图略),用MATLAB绘制其频谱,要求交互式设置信号周期和时域宽度,观察信号周期T及时域宽度对信号频谱的影响。解:在一个周期内)(..........0)0......(1)(Txxxtf而:110)cos()cos(2)(nnnntnbtnaatf首先求解其傅立叶系数:TdttfTa00)(2;TndttntfTa0)cos()(2TndttntfTb0)sin()(2编写.m文件如下:disp('pleaseinputthevalueofT,taoandNf');T=input('T=');tao=input('tao=');Nf=input('Nf=');symsxnkNn=32;An=zeros(Nf+1,1);Bn=zeros(Nf+1,1);f=x/tao;信号与线性系统分析实验7a0=2*int(f,x,0,tao)/T;an=2*int(f*cos(n*x),x,0,tao)/T;bn=2*int(f*sin(n*x),x,0,tao)/T;An(1)=double(vpa(a0,Nn));fork=1:NfAn(k+1)=double(vpa(subs(an,n,k),Nn));Bn(k+1)=double(vpa(subs(bn,n,k),Nn));endcn=sqrt(An.*An+Bn.*Bn);m=0:Nf;stem(m,cn);holdon;plot(m,cn);xlabel('·ù¶È\omega','fontsize',8);信号与线性系统分析实验8其次固定tao,改变T:
本文标题:信号与系统实验三
链接地址:https://www.777doc.com/doc-6019958 .html