您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > 实验二信号的频域分析
实验二信号的频域分析一.实验目的1.通过MATLAB编程观察周期信号的合成过程,进一步了解周期信号的傅里叶级数分解特性。2.学习用MATLAB绘制周期信号的频谱的方法,观察周期信号的离散性、谐波性和收敛性。3.用MATLAB研究矩形波的频谱,观察周期变化和脉冲变化对频谱的影响。4.学习用MATLAB的符号运算功能计算傅里叶变换和反变换的方法。5.掌握用MATLAB绘制非周期信号频谱的数值方法。6.掌握信号的采集方法与过程以及信号恢复的原理与方法。二.实验内容1.题目:2-1已知信号周期如图所示。其中T=4s,A=1,试:1)画出两个周期信号的频谱图。2)求傅里叶级数最高谐波次数20的部分和波形,并比较。源程序:T=4N=20t=linspace(-T/2,T/2,1000)w0=2*pi/Tf=sawtooth(w0*t,1)fork=0:Na(k+1)=2/T*trapz(t,f.*cos(k*w0*t))b(k+1)=2/T*trapz(t,f.*sin(k*w0*t))endAn=a-j*bAn(1)=a(1)tt=[t-T,t,t+T]ff=[f,f,f]subplot(2,3,1);plot(tt,ff,'LineWidth',1.5);ylabel('f(t)')title('周期信号波形','Fontsize',8)subplot(2,3,2);h=stem(0:N,abs(An),'.');holdonh=stem(0:-1:-N,abs(An),'.')title('幅度频谱','Fontsize',8)xlabel('\omega');ylabel('F(j\omega)')subplot(2,3,3);h=stem(0:N,angle(An),'.');holdonh=stem(0:-1:-N,-angle(An),'.')title('相位频谱','Fontsize',8)xlabel('\omega');ylabel('\phi(j\omega)')f=sawtooth(w0*t,0.5)fork=0:Na(k+1)=2/T*trapz(t,f.*cos(k*w0*t))b(k+1)=2/T*trapz(t,f.*sin(k*w0*t))endAn=a-j*bAn(1)=a(1)tt=[t-T,t,t+T]ff=[f,f,f]subplot(2,3,4);plot(tt,ff,'LineWidth',1.5);ylabel('f(t)')title('周期信号波形','Fontsize',8)subplot(2,3,5);h=stem(0:N,abs(An),'.');holdonh=stem(0:-1:-N,abs(An),'.')title('幅度频谱','Fontsize',8)xlabel('\omega');ylabel('F(j\omega)')subplot(2,3,6);h=stem(0:N,angle(An),'.');holdonh=stem(0:-1:-N,-angle(An),'.')title('相位频谱','Fontsize',8)xlabel('\omega');ylabel('\phi(j\omega)')程序运行结果(截图):-10010-1-0.500.51f(t)周期信号波形-2002000.20.40.60.8幅度频谱F(j)-20020-2-1012相位频谱(j)-10010-1-0.500.51f(t)周期信号波形-2002000.51幅度频谱F(j)-20020-4-2024相位频谱(j)2.题目:2-2求下列信号的傅里叶变换。并比较1f(t)与2f(t)的幅度谱和相位谱,进行简单分析(令A=2,a=3)。a)(t)=Ae-atu(t)b)2f(t)=Aeatu(-t)源程序:ex2_2.m:CXHFT.mfunctiony=CXHFT(x,tn,wn);t1=tn(1);t2=tn(2);w1=wn(1);w2=wn(2);t=t1:0.01:t2;N=500;W=6*pi*2;k=-N:N;w=k*W/N;ft=eval([x]);fmax=max(ft);fmin=min(ft);df=(fmax-fmin)*0.1;F=ft*exp(-j*t'*w)*0.01;F1=abs(F);Fmax=max(F1);Fmin=min(F1);dF=(Fmax-Fmin)*0.1P1=angle(F)*180/pi;Pmax=max(P1);Pmin=min(P1);subplot(3,1,1),plot(t,ft,'linewidth',2),grid;ylabel('f(t)')title('连续信号f(t)的波形','FontSize',8);axis([t1,t2,fmin-df,fmax+df]);set(gca,'FontSize',8)subplot(3,1,2),plot(w,F1,'linewidth',2),grid;ylabel('F(jw)的模')title('连续信号的幅度频谱','FontSize',8);axis([w1,w2,Fmin-dF,Fmax+dF]);ifFmin=8F0=(Fmax-Fmin)/2;elseF0=0;endset(gca,'Ytick',[F0,Fmin,Fmax],'fontSize',8)subplot(3,1,3),plot(w,P1,'linewidth',2),grid;xlabel('\omega'),ylabel('相位(度)')axis([w1,w2,Pmin-45,Pmin+45]);title('连续信号的相位频谱','FontSize',8);ifPmin=8P0=(Pmax-Pmin)/2;elseP0=0;endifround(Pmin)~=round(Pmax)set(gca,'Ytick',[round(Pmin),P0,round(Pmax)],'FontSize',8)end(a)f='tripuls(t,4,0.5)';t=[-5,5];w=[-20,20];figure(10)CXHFT(f,t,w)f='2*exp(-3*t).*u(t)';t=[-2,2];w=[-30,30];figure(2)CXHFT(f,t,w)symstwfu=sym('2*exp(-3*t)*Heaviside(t)');F1=fourier(fu)pretty(F1)(b)f='tripuls(t,4,0.5)';t=[-5,5];w=[-20,20];figure(10)CXHFT(f,t,w)f='2*exp(3*t).*u(-t)';t=[-2,2];w=[-30,30];figure(2)CXHFT(f,t,w)symstwfu=sym('2*exp(3*t)*Heaviside(-t)');F1=fourier(fu)程序运行结果(截图):-2-1.5-1-0.500.511.52012f(t)连续信号f(t)的波形-30-20-10010203000.05390.6751F(jw)的模连续信号的幅度频谱-30-20-100102030-76相位(度)连续信号的相位频谱-5-4-3-2-101234500.51f(t)连续信号f(t)的波形-20-15-10-505101520002F(jw)的模连续信号的幅度频谱-20-15-10-505101520-180相位(度)连续信号的相位频谱-2-1.5-1-0.500.511.52012f(t)连续信号f(t)的波形-30-20-10010203000.05390.6751F(jw)的模连续信号的幅度频谱-30-20-100102030-76相位(度)连续信号的相位频谱-5-4-3-2-101234500.51f(t)连续信号f(t)的波形-20-15-10-505101520002F(jw)的模连续信号的幅度频谱-20-15-10-505101520-180相位(度)连续信号的相位频谱3.题目:2-3用MATLAB的符号运算功能计算下列信号的傅里叶变换与反变换。a)f(t)=|1|2teb)f(t)=te2cos(2t)u(t)c)F(jω)=21jd)F(jω)=221je源程序:symstwf1=sym('exp(-2*abs(t-1))');F1=fourier(f1)pretty(F1)f1=ifourier(F1,t)f2=sym('exp(-2*t)*cos(2*pi*t)*Heaviside(t)')F2=fourier(f2)pretty(F2)f2=ifourier(F2,t)f3=j*w/(1+w.^2)F3=fourier(f3)pretty(F3)f3=ifourier(F3,t)f4=sym('exp(-1*j*2*w)/(1+w^2)')F4=fourier(f4)pretty(F4)f4=ifourier(F4,t)程序运行结果(截图):F1=fourier(exp(-2*abs(t-1)),t,w)fourier(exp(-2|t-1|),t,w)f1=exp(-2*abs(t-1))f2=exp(-2*t)*cos(2*pi*t)*Heaviside(t)F2=(w*i+2)/(w*i+2+2*i*pi)/(w*i+2-2*i*pi)wi+2-------------------------------------(wi+2+2ipi)(wi+2-2ipi)f2=exp(-2*t)*cos(2*pi*t)*heaviside(t)f3=i*w/(1+w^2)F3=pi*(-exp(t)*heaviside(-t)+exp(-t)*heaviside(t))pi(-exp(t)heaviside(-t)+exp(-t)heaviside(t))f3=i*t/(t^2+1)f4=exp(-1*j*2*w)/(1+w^2)F4=fourier(exp(-2*j*w)/(1+w^2),w,t)exp(-2jw)fourier(-----------,w,t)21+wf4=fourier(exp(-2*j*w)/(1+w^2),w,t)*dirac(t)4.题目:在1/2~1/10之间选择若干个不同Ts值,反复执行范例程序Program2_7,保存执行程序所得到的图形,分析抽样频率如何响应已抽样信号频谱。源程序:tmax=4;dt=0.01;t=0:dt:tmax;Ts=1/8;ws=2*pi/Ts;w0=20*pi;dw=0.1;w=-w0:dw:w0;n=0:1:tmax/Ts;x=exp(-4*t).*u(t);xn=exp(-4*n*Ts);subplot(2,2,1),plot(t,x),title('Acontinuous-timesignalx(t)'),xlabel('Timet'),axis([0,tmax,0,1]),gridon;subplot(2,2,3),stem(n,xn,'.'),title('Thesampledversionx[n]ofx(t)'),xlabel('Timeindexn'),axis([0,tmax/Ts,0,1]),gridon;Xa=x*exp(-j*t'*w)*dt;X=0;fork=-8:8;X=X+x*exp(-j*t'*(w-k*ws))*dt;endsubplot(2,2,2),plot(w,abs(Xa)),title('Magnitudespectrumofx(t)'),gridon,axis([-60,60,0,1.8*max(abs(Xa))]);subplot(2,2,4),plot(w,abs(X)),title('Magnitudespectrumofx[n]'),xlabel('Frequencyinradians/s'),gridon,axis([
本文标题:实验二信号的频域分析
链接地址:https://www.777doc.com/doc-2458596 .html