湖南大学信号与系统实验三报告.docx
《湖南大学信号与系统实验三报告.docx》由会员分享,可在线阅读,更多相关《湖南大学信号与系统实验三报告.docx(39页珍藏版)》请在冰豆网上搜索。
![湖南大学信号与系统实验三报告.docx](https://file1.bdocx.com/fileroot1/2022-12/14/aefcffc4-34e3-4850-acf8-19cd26add3aa/aefcffc4-34e3-4850-acf8-19cd26add3aa1.gif)
湖南大学信号与系统实验三报告
实验报告要求:
1、根据信号相应的数学表达式编写程序,以及绘制各种频谱图。
2、简述上机调试程序的方法。
3、根据实验的结果观察,归纳、总结周期信号频谱的特征。
4、分析所画频谱图与理论计算的一致性,并总结出离散频谱图中横坐标的标注方法。
5、简述实验心得体会及其他。
代码:
t=-2:
0.005:
10;
y=square(2*pi*t,50);
y1=4/pi*(sin(2*pi*t));
fori=3:
2:
7
y1=y1+4/pi*(1/i*sin(2*pi*i*t));
end
subplot(2,2,1);
plot(t,y);
holdon;
plot(t,y1);
axis([-210-22]);
title('七次分解');
y2=4/pi*(sin(2*pi*t));
fori=3:
2:
21
y2=y2+4/pi*(1/i*sin(2*pi*i*t));
end
subplot(2,2,2);
plot(t,y);
holdon;
plot(t,y2);
axis([-210-22]);
title('二十一次分解');
y3=4/pi*(sin(2*pi*t));
fori=3:
2:
41
y3=y3+4/pi*(1/i*sin(2*pi*i*t));
end
subplot(2,2,3);
plot(t,y);
holdon;
plot(t,y3);
axis([-210-22]);
title('四十一次分解');
代码:
clear
symstaoTtWn;
W=2*pi/T;
A0=int(1,t,0,tao)/T;
An=2*int(1*cos(n*W*t),t,0,tao)/T;
Bn=2*int(1*sin(n*W*t),t,0,tao)/T;
Cn=sqrt(An^2+Bn^2)
T=4;
tao=1;
n=1:
25;
A0=subs(A0,{'T''tao'},{Ttao})
Cn=subs(Cn,{'T''tao'},{Ttao});
Cn=subs(Cn,'n',n);
An=subs(An,{'T''tao'},{Ttao});
An=subs(An,'n',n);
Bn=subs(Bn,{'T''tao'},{Ttao});
Bn=subs(Bn,'n',n);
C=[A0Cn]
n=0:
25;
stem(n,abs(C))
f=A0;
fori=1:
25
f=f+An(i)*cos(i*(2*pi/T)*t)+Bn(i)*sin(i*(2*pi/T)*t);
end
t=0:
10;
f=subs(f,'t',t)
plot(t,f)
代码:
clear
symstaoTtWn;
W=2*pi/T;
A0=int(1,t,-tao/2,tao/2)/T;
An=2*int(1*cos(n*W*t),t,0,tao)/T;
T=16;
tao=4;
n=1:
25;
a0=subs(A0,{'T''tao'},{Ttao})
an=subs(An,{'T''tao'},{Ttao});
an=subs(an,'n',n);
A=[a0an]
n=0:
25;
figure
subplot(3,1,1)
stem(n,abs(A))
title('ÖÜÆÚT=16²»±ä£¬¶øÂö¿í¦Ó·Ö±ðΪ4£¬2£¬1ʱµÄƵÆ×')
T=16;
tao=2;
n=1:
25;
a0=subs(A0,{'T''tao'},{Ttao})
an=subs(An,{'T''tao'},{Ttao});
an=subs(an,'n',n);
A=[a0an]
n=0:
25;
subplot(3,1,2)
stem(n,abs(A))
T=16;
tao=1;
n=1:
25;
a0=subs(A0,{'T''tao'},{Ttao})
an=subs(An,{'T''tao'},{Ttao});
an=subs(an,'n',n);
A=[a0an]
n=0:
25;
subplot(3,1,3)
stem(n,abs(A))
T=2;
tao=0.5;
n=1:
25;
a0=subs(A0,{'T''tao'},{Ttao})
an=subs(An,{'T''tao'},{Ttao});
an=subs(an,'n',n);
A=[a0an]
n=0:
25;
figure
subplot(3,1,1)
stem(n,abs(A))
title('Âö¿í¦Ó=0.5²»±ä£¬¶øÖÜÆÚT·Ö±ðΪ2£¬5£¬9ʱµÄƵÆ×')
T=5;
tao=0.5;
n=1:
25;
a0=subs(A0,{'T''tao'},{Ttao})
an=subs(An,{'T''tao'},{Ttao});
an=subs(an,'n',n);
A=[a0an]
n=0:
25;
subplot(3,1,2)
stem(n,abs(A))
T=9;
tao=0.5;
n=1:
25;
a0=subs(A0,{'T''tao'},{Ttao})
an=subs(An,{'T''tao'},{Ttao});
an=subs(an,'n',n);
A=[a0an]
n=0:
25;
subplot(3,1,3)
stem(n,abs(A))
代码:
clear
symstaoTtWn;
W=2*pi/T;
A0=int(2*t,t,-1/2,1/2)/T+int(-2*t+2,t,1/2,1)/T;
An=2*int(2*t*cos(n*W*t),t,-1/2,1/2)/T+2*int((-2*t+2)*cos(n*W*t),t,1/2,1)/T;
Bn=2*int(2*t*sin(n*W*t),t,-1/2,1/2)/T+2*int((-2*t+2)*sin(n*W*t),t,1/2,1)/T;
Cn=sqrt(An^2+Bn^2)
T=2;
%tao=1;
n=1:
25;
A0=subs(A0,{'T'},{T})
Cn=subs(Cn,{'T'},{T});
Cn=subs(Cn,'n',n);
An=subs(An,{'T''tao'},{Ttao});
An=subs(An,'n',n);
Bn=subs(Bn,{'T''tao'},{Ttao});
Bn=subs(Bn,'n',n);
Dn=atan(-Bn./An);
D=[0,Dn]
C=[A0Cn]
n=0:
25;
subplot(2,1,1)
stem(n,abs(C))
title('幅度普')
subplot(2,1,2)
stem(n,abs(D))
title('密度普×')
clear
symstaoTtWn;
W=2*pi/T;
A0=int(cos(pi*t),t,-1/2,1/2)/T;
An=2*int(cos(pi*t)*cos(n*2*pi*t),t,-1/2,1/2)/T;
Bn=2*int(sin(pi*t)*sin(n*2*pi*t),t,-1/2,1/2)/T;
Cn=sqrt(An^2+Bn^2);
T=1;
%tao=1;
n=1:
25;
A0=subs(A0,{'T'},{T})
Cn=subs(Cn,{'T'},{T});
Cn=subs(Cn,'n',n);
An=subs(An,{'T'},{T});
An=subs(An,'n',n);
A=[A0An]
Bn=subs(Bn,{'T''tao'},{Ttao});
Bn=subs(Bn,'n',n);
Dn=atan(-Bn./An);
D=[0,Dn];
C=[A0Cn];
n=0:
25;
subplot(2,1,1);
stem(n,abs(A))
title('幅度普');
subplot(2,1,2);
stem(n,abs(D));
title('密度谱');
实验四傅立叶变换
实验目的:
(1)、掌握傅立叶变换的方法及物理意义;
(2)、掌握典型非周期信号的频谱特征,以及傅立叶变换的数值方法和符号方法;
(3)、掌握用MATLAB编写非周期信号傅立叶变换及逆变换的方法;
(4)、通过对非周期信号频谱的绘制,验证傅立叶变换的性质,加深对傅立叶变换性质的理
解。
>>r=0.02;
t=-5:
r:
5;
N=200;
W=2*pi*1;
k=-N:
N;
w=k*W/N;
f1=exp(-2*t).*Heaviside(t);%定义f(t)
F=r*f1*exp(-j*t'*w);%求f(t)的傅里叶变换F(jω)
F1=abs(F);%求F(jω)的幅度
P1=angle(F);%求F(jω)的相位
subplot(3,1,1);
plot(t,f1);
grid;
xlabel('t');
ylabel('f(t)');
title('f(t)');
subplot(3,1,2);
plot(w,F1);
xlabel('w');
grid;
ylabel('F(jw)');
subplot(3,1,3);
plot(w,P1*180/pi);
grid;
xlabel('w');
ylabel('P(度)');
r=0.02;
t=-2:
r:
8;
N=200;
W=2*pi*1;
k=-N:
N;
w=k*W/N;
f1=exp(-2*(t-3)).*Heaviside(t-3);%定义f(t)
F=r*f1*exp(-j*t'*w);%求f(t)的傅里叶变换F(jω)
F1=abs(F);%求F(jω)的幅度
P1=angle(F);%求F(jω)的相位
subplot(3,1,1);
plot(t,f1);
grid;
xlabel('t');
ylabel('f(t)');
title('f(t)');
subplot(3,1,2);
plot(w,F1);
xlabel('w');
grid;
ylabel('F(jw)');
subplot(3,1,3);
plot(w,P1*180/pi);
grid;
xlabel('w');
ylabel('相位频谱');
r=0.02;
t=-8:
r:
8;
N=200;
W=2*pi*1;
k=-N:
N;
w=k*W/N;
f1=(t+2).*(heaviside(t+2)-heaviside(t+1))+(heaviside(t+1)-heaviside(t-1))+(-1)*(t-2).*(heaviside(t-1)-heaviside(t-2));%定义f(t)
F=r*f1*exp(-j*t'*w);%求f(t)的傅里叶变换F(jω)
F=real(F);
F1=abs(F);%求F(jω)的幅度
P1=angle(F);%求F(jω)的相位
subplot(3,1,1);
plot(t,f1);
axis([-8,8,0,1.5])
grid;
xlabel('t');
ylabel('f(t)');
title('f(t)');
subplot(3,1,2);
plot(w,F1);
axis([-8,8,-1,4])
xlabel('w');
grid;
ylabel('F(jw)');
subplot(3,1,3);
plot(w,P1*180/pi);
axis([-8,8,-1,200])
grid;
xlabel('w');
ylabel('相位频谱');
r=0.02;
t=-8:
r:
8;
N=200;
W=2*pi*1;
k=-N:
N;
w=k*W/N;
f1=(1/3)*(t+2).*(heaviside(t+2)-heaviside(t-1))+(-1)*(t-2).*(heaviside(t-1)-heaviside(t-2));%定义f(t)
F=r*f1*exp(-j*t'*w);%求f(t)的傅里叶变换F(jω)
F=real(F);
F1=abs(F);%求F(jω)的幅度
P1=angle(F);%求F(jω)的相位
subplot(3,1,1);
plot(t,f1);
axis([-8,8,0,1.5])
grid;
xlabel('t');
ylabel('f(t)');
title('f(t)');
subplot(3,1,2);
plot(w,F1);
axis([-8,8,-1,4])
xlabel('w');
grid;
ylabel('F(jw)');
subplot(3,1,3);
plot(w,P1*180/pi);
axis([-8,8,-1,200])
grid;
xlabel('w');
ylabel('相位频谱');
r=0.02;
t=-1:
r:
4;
N=200;
W=2*pi*1;
k=-N:
N;
w=k*W/N;
f1=exp((-1)*t).*(heaviside(t)-heaviside(t-1));%定义f(t)
F=r*f1*exp(-j*t'*w);%求f(t)的傅里叶变换F(jω)
F=real(F);
F1=abs(F);%求F(jω)的幅度
P1=angle(F);%求F(jω)的相位
subplot(3,1,1);
plot(t,f1);
axis([-1,4,0,1.2])
grid;
xlabel('t');
ylabel('f(t)');
title('f(t)');
subplot(3,1,2);
plot(w,F1);
axis([-5,5,-1,1])
xlabel('w');
grid;
ylabel('F(jw)');
subplot(3,1,3);
plot(w,P1*180/pi);
axis([-8,8,-1,200])
grid;
xlabel('w');
ylabel('相位频谱');
R=0.02;t=-2:
R:
2;
f=Heaviside(t+(1/2))-Heaviside(t-(1/2));
W1=2*pi*5;
N=500;k=0:
N;W=k*W1/N;
F=f*exp(-j*t'*W)*R;
F=real(F);
W=[-fliplr(W),W(2:
501)];%Ðγɸº°ëÖá¼°Õý°ëÖáµÄ2N+1¸öƵÂʵãW
F=[fliplr(F),F(2:
501)];%ÐγɶÔÓ¦ÓÚWµÄF(jw)µÄÖµ
subplot(2,1,1);plot(t,f);
xlabel('t');ylabel('f(t)');
title('f(t)=u(t+(1/2))-u(t-(1/2))');
subplot(2,1,2);plot(W,F);
xlabel('w');ylabel('F(w)');
R=0.02;t=-2:
R:
2;
f=Heaviside(t+1)-Heaviside(t-1);
W1=2*pi*5;%ƵÂÊ¿í¶È
N=500;k=0:
N;W=k*W1/N;%²ÉÑùÊýΪN,WΪƵÂÊÕý°ëÖáµÄ²ÉÑùµã
F=f*exp(-j*t'*W)*R;%ÇóF(jw)
F=real(F);
W=[-fliplr(W),W(2:
501)];%Ðγɸº°ëÖá¼°Õý°ëÖáµÄ2N+1¸öƵÂʵãW
F=[fliplr(F),F(2:
501)];%ÐγɶÔÓ¦ÓÚWµÄF(jw)µÄÖµ
subplot(2,1,1);plot(t,f);
xlabel('t');ylabel('f(t)');
title('f(t)=u(t+1)-u(t-1)');
subplot(2,1,2);plot(W,F);
xlabel('w');ylabel('F(w)');
R=0.02;t=-2:
R:
2;
f=Heaviside(t+(1/4))-Heaviside(t-(1/4));
W1=2*pi*5;%ƵÂÊ¿í¶È
N=500;k=0:
N;W=k*W1/N;%²ÉÑùÊýΪN,WΪƵÂÊÕý°ëÖáµÄ²ÉÑùµã
F=f*exp(-j*t'*W)*R;%ÇóF(jw)
F=real(F);
W=[-fliplr(W),W(2:
501)];%Ðγɸº°ëÖá¼°Õý°ëÖáµÄ2N+1¸öƵÂʵãW
F=[fliplr(F),F(2:
501)];%ÐγɶÔÓ¦ÓÚWµÄF(jw)µÄÖµ
subplot(2,1,1);plot(t,f);
xlabel('t');ylabel('f(t)');
title('f(t)=u(t+(1/4))-u(t-(1/4))');
subplot(2,1,2);plot(W,F);
xlabel('w');ylabel('F(w)');
R=0.02;t=-5:
R:
5;
f=heaviside(t);
W1=2*pi*5;%频率宽度
N=500;k=0:
N;W=k*W1/N;%采样数为N,W为频率正半轴的采样点
F=f*exp(-j*t'*W)*R;%求F(jw)
F=real(F);
W=[-fliplr(W),W(2:
501)];%形成负半轴及正半轴的2N+1个频率点W
F=[fliplr(F),F(2:
501)];%形成对应于W的F(jw)的值
subplot(2,1,1);plot(t,f);
xlabel('t');ylabel('f(t)');
title('f(t)');
axis([-3,3,0,1.5])
subplot(2,1,2);plot(W,F);
xlabel('w');ylabel('F(w)');
r=0.02;
t=-5:
r:
5;
N=200;
W=2*pi*1;
k=-N:
N;
w=k*W/N;
f1=2*exp((-3)*t).*Heaviside(t);%定义f(t)
F=r*f1*exp(-j*t'*w);%求f(t)的傅里叶变换F(jω)
F1=abs(F);%求F(jω)的幅度
P1=angle(F);%求F(jω)的相位
subplot(3,1,1);
plot(t,f1);
grid;
xlabel('t');
ylabel('f(t)');
title('f(t)');
subplot(3,1,2);
plot(w,F1);
xlabel('w');
grid;
ylabel('F(jw)');
subplot(3,1,3);
plot(w,P1*180/pi);
grid;
xlabel('w');
ylabel('P(度)');
r=0.02;
t=-5:
r:
5;
N=200;
W=2*pi*1;
k=-N:
N;
w=k*W/N;
f1=2*exp(3*t).*Heaviside(-t);%定义f(t)
F=r*f1*exp(-j*t'*w);%求f(t)的傅里叶变换F(jω)
F1=abs(F);%求F(jω)的幅度
P1=angle(F);%求F(jω)的相位
subplot(3,1,1);
plot(t,f1);
grid;
xlabel('t');
ylabel('f(t)');
title('f(t)');
subplot(3,1,2);
plot(w,F1);
xlabel('w');
grid;
ylabel('F(jw)');
subplot(3,1,3);
plot(w,P1*180/pi);
grid;
xlabel('w');
ylabel('P(度)');
R=0.05;t=-2:
R:
2;
f=Heaviside(t+1)-Heaviside(t-1);%f(t)µÄʱÓò¿í¶ÈΪ2£¬tµÄÈ¡Öµ·¶Î§·Å´óΪ-2µ½2
subplot(421)
plot(t,f)
xlabel('t');
ylabel('f(t)');
y=R*conv(f,f);%Çóy(t)=f(t)*f(t),±¾Àýy(t)µÄʱ¿íΪf(t)µÄʱ¿íÁ½±¶
n=-4:
R:
4;%nµÄÈ¡Öµ·¶Î§ÎªtµÄÈ¡Öµ·¶Î§µÄÁ½±¶£¬Îª-4µ½+4
subplot(422);
plot(n,y);
xlabel('t');
ylabel('y(t)=f(t)*f(t)');
axis([-33-13]);
W1=2*pi*5;
N=200;
k=-N:
N;
W=k*W1/N;
F=f*exp(-j*t'*W)*R;%Çóf(t)µÄ¸µÀïÒ¶±ä»»F(j¦Ø)
F=real(F);
Y=y*exp(-j*n'*W)*R;%Çóy(t)µÄ¸µÀïÒ¶±ä»»Y(j¦Ø)
Y=real(Y);
%F1=F.*F%ÇóF(j¦Ø)¡ÁF(j¦Ø)
subplot(423);
plot(W,F);
xlabel('w');
ylabel('F(jw)');
subplot(424);
F2=abs(F);
plot(W,F2);
subplot(425)
P1=angle(F);
plot(W,P1);
subplot(426)
plot(W,Y);
xlabel('w');
ylabel('Y(jw)');
axis([-202004]);
subplot(4,2,7)
Y2=abs(Y);
plot(W,Y2);
subplot(428);
P2=angle(Y);
plot(W,P2);
symstw;
f1=ifourier(1/(1+w^2),t)
f2=ifourier(2*sin(3*(w-2*pi))/(w-2*pi),t)
f3=ifourier(cos(4*w+pi/3),t)
f1=
((pi*heaviside(t))/exp(t)+pi*heaviside(-t)*exp(t))/(2*pi)
f2=