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

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

实验三周期信号的傅里叶级数分析及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/1801439850948 1984*pi)*cos(1/2*pi*n)+cos(9007199254740991/18014398509481984*pi)*sin(1/2* pi*n))/(-81129638414606681695789005144063+18014398509481984*n+81129638 414606681695789005144064*n^2)/pi

bn =

9.3:

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

tao=input('tao=');

Nf=input('Nf=');

syms x n k

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

相关文档
最新文档