实验三 周期信号的傅里叶级数分析及MATLAB实现

更新时间:2023-12-04 08:14:01 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

实验三周期信号的傅里叶级数分析及MATLAB实现

一、实验目的:

1.利用MATLAB实现周期信号的分解与合成,并图示仿真结果;

2.用MATLAB实现周期信号的频谱,画图观察和分析周期信号的频谱;

3.通过MATLAB对周期信号频谱的仿真,进一步加深对周期信号频谱理论知识的理解。

二、实验内容

9.1(a):程序:

display('Please input the value of m(傅里叶级数展开项数)'); m=input('m='); t=-3*pi:0.01:3*pi; n=round(length(t)/4);

f=cos(t).*(heaviside(t+2.5*pi)-heaviside(t+1.5*pi)+heaviside(t+0.5*pi)-heaviside(t-0.5*pi)+heaviside(t-1.5*pi)-heaviside(t-2.5*pi)); y=zeros(m+1,max(size(t))); y(m+1,:)=f'; figure(1);

plot(t/pi,y(m+1,:)); grid;

axis([-3 3 -1 1.5]); title('半波余弦');

xlabel('单位:pi','Fontsize',8); x=zeros(size(t)); kk='1'; syms tx n T=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; for k=2:m

An(k+1)=double(vpa(subs(an,n,k),Nn)); Bn(k+1)=double(vpa(subs(bn,n,k),Nn));

end

y(1,:)=1/pi;

y(2,:)=1/pi+1/2*cos(t); x=1/pi+1/2*cos(t); for k=2:6 pause;

x=x+(-2*cos(pi*k/2)/pi/(k^2-1))*cos(k*t); y((k+1),:)=x;

plot(t/pi,y(m+1,:)); hold on;

plot(t/pi,y((k+1),:)); hold off; grid;

axis([-3 3 -1 1.5]);

title(strcat('第',kk,'次谐波叠加')); xlabel('单位:pi','Fontsize',8); kk=strcat(kk,'`',num2str(k)); end pause;

plot(t/pi,y(m+1,:)); grid;

axis([-3 3 -1 1.5]); title('谐波叠加');

xlabel('单位:pi','Fontsize',8); a0 = 2/pi an =

162259276829213363391578010288128*(-sin(9007199254740991/18014398509481984*pi)*cos(1/2*pi*n)+cos(9007199254740991/18014398509481984*pi)*sin(1/2*pi*n))/(-81129638414606681695789005144063+18014398509481984*n+81129638414606681695789005144064*n^2)/pi bn = 0

9.3:

display('Please input the value of T,tao and Nf'); T=input('T=');

tao=input('tao='); Nf=input('Nf='); syms xnk Nn=32;

An=zeros(Nf+1,1); Bn=zeros(Nf+1,1); f=x/tao;

a0=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)); for k=1:Nf

An(k+1)=double(vpa(subs(an,n,k),Nn)); Bn(k+1)=double(vpa(subs(bn,n,k),Nn)); end

cn=sqrt(An.*An+Bn.*Bn); m=0:Nf;

stem(m,cn); hold on; plot(m,cn);

xlabel('幅度谱\\omega','Fontsize',8)

Please input the value of T,tao and Nf T=10 tao=2 Nf=30

Please input the value of T,tao and Nf T=50 tao=2 Nf=30

Please input the value of T,tao and Nf T=100 tao=2 Nf=30

Please input the value of T,tao and Nf T=10 tao=1 Nf=30

Please input the value of T,tao and Nf T=10 tao=3 Nf=30

Please input the value of T,tao and Nf T=10 tao=5 Nf=30

实验小结:

频带宽度于时域宽度成反比,时域宽度越大频带越窄,周期越大频谱越密。 在傅立叶级数的项数取得很大时,间断点处尖峰下的面积非常小以至于趋近于零,因而在均方的意义上合成波形与原波形的真值没有区别。

本文来源:https://www.bwwdw.com/article/liwt.html

Top