实验3用FFT对信号作频谱分析.docx
《实验3用FFT对信号作频谱分析.docx》由会员分享,可在线阅读,更多相关《实验3用FFT对信号作频谱分析.docx(10页珍藏版)》请在冰豆网上搜索。
实验3用FFT对信号作频谱分析
实验3用FFT对信号作频谱分析
实验三:
用FFT对信号作频谱分析
10.3.1实验指导
1(实验目的
学习用FFT对连续信号和时域离散信号进行谱分析的方法,了解可能出现的分析
误差及其原因,以便正确应用FFT。
2.实验原理
用FFT对信号作频谱分析是学习数字信号处理的重要内容。
经常需要进行谱分析的信号是模拟信号和时域离散信号。
对信号进行谱分析的重要问题是频谱分辨率D和分析误差。
频谱分辨率直接和FFT的变换区间N有关,因为FFT能够实现的频率分辨率是,因此要求。
可以根据此式选择FFT的变换区间N。
误差主要来自于用FFT作频谱分析时,得到的是离散谱,而信号(周期信号除外)是连续谱,只有当N较大时离散谱的包络才能逼近于连续谱,因此N要适当选择大一些。
周期信号的频谱是离散谱,只有用整数倍周期的长度作FFT,得到的离散谱才能代表周期信号的频谱。
如果不知道信号周期,可以尽量选择信号的观察时间长一些。
对模拟信号进行谱分析时,首先要按照采样定理将其变成时域离散信号。
如果是模拟周期信号,也应该选取整数倍周期的长度,经过采样后形成周期序列,按照周期序列的谱分析进行。
3(实验步骤及内容
(1)对以下序列进行谱分析。
选择FFT的变换区间N为8和16两种情况进行频谱分析。
分别打印其幅频特性曲线。
并进行对比、分析和讨论。
(2)对以下周期序列进行谱分析。
选择FFT的变换区间N为8和16两种情况分别对以上序列进行频谱分析。
分别打印其幅频特性曲线。
并进行对比、分析和讨论。
feelfreetolistentotheirvoicesandhelpthemassessolveproblems,wewereofficiallyopenedonMay10"12345"Mayorcalls,formulatedrulesandregulations,equippedwithafull-timestaff,a24-houron-dutysystem,peopletocalltoreceive,reply,action,reminders,feedbackandsoon.Byyearend,handledthecrowdcalls1076,94.7%feedbackrate.ByMayorcallsactivecoordinationtosolvealargenumberofbearsontheimmediateinterestsofthepeopleandissuesofgreatlives,butalsoforleadershipresearchanddecisiontocollectalotofgoodideasandsuggestions,byallsectorsofthecommunityalike.Second,startMunicipalGovernmentAffairsHallbuilt.OnMay11,webuiltandlaunchedthecity-governmentlobby,weresettledin12departments,strictimplementationoffirstaskingdutysystem,servicesystem,systemofgratuitous,"receiving,internalcoordination,headofthewindowhandle,limitedtimeconcluded"one-stopservice.Bytheendoftodaytoacceptvarioustypesof3,273,originallyofupto100%.RunningGovernmentAffairsHall,theconvenienceofthemasses,promotingopenGovernment,improvetheinvestmentenvironmentandsolvetheirpracticalproblems,andsodidalotofwork,masses,servethecommunityfortheGovernmenttoplayaverygood"window,link,model".Third,createacitygovernmentpublicaffairsnetwork.WerelyontheGovernmentWebsite,wascompletedonMay24,theprovince'sfirstpublicaffairsnetwork.Over
(3)对模拟周期信号进行谱分析
选择采样频率,变换区间N=16,32,64三种情况进行谱分析。
分别打印其幅频特性,并进行分析和讨论。
4(思考题
(1)对于周期序列,如果周期不知道,如何用FFT进行谱分析,
(2)如何选择FFT的变换区间,(包括非周期信号和周期信号)(3)当N=8时,和的幅频特性会相同吗,为什么,N=16呢,5(实验报告要求
(1)完成各个实验任务和要求。
附上程序清单和有关曲线。
(2)简要回答思考题。
=====================================================================
===========
%第10章实验3程序exp3.m
%用FFT对信号作频谱分析
clearall;closeall
%实验内容
(1)===================================================
x1n=[ones(1,4)];%产生序列向量x1(n)=R4(n)M=8;xa=1:
(M/2);xb=(M/2):
-1:
1;x2n=[xa,xb];%产生长度为8的三角波序列x2(n)
x3n=[xb,xa];
feelfreetolistentotheirvoicesandhelpthemassessolveproblems,wewereofficiallyopenedonMay10"12345"Mayorcalls,formulatedrulesandregulations,equippedwithafull-timestaff,a24-houron-dutysystem,peopletocalltoreceive,reply,action,reminders,feedbackandsoon.Byyearend,handledthecrowdcalls1076,94.7%feedbackrate.ByMayorcallsactivecoordinationtosolvealargenumberofbearsontheimmediateinterestsofthepeopleandissuesofgreatlives,butalsoforleadershipresearchanddecisiontocollectalotofgoodideasandsuggestions,byallsectorsofthecommunityalike.Second,startMunicipalGovernmentAffairsHallbuilt.OnMay11,webuiltandlaunchedthecity-governmentlobby,weresettledin12departments,strictimplementationoffirstaskingdutysystem,servicesystem,systemofgratuitous,"receiving,internalcoordination,headofthewindowhandle,limitedtimeconcluded"one-stopservice.Bytheendoftodaytoacceptvarioustypesof3,273,originallyofupto100%.RunningGovernmentAffairsHall,theconvenienceofthemasses,promotingopenGovernment,improvetheinvestmentenvironmentandsolvetheirpracticalproblems,andsodidalotofwork,masses,servethecommunityfortheGovernmenttoplayaverygood"window,link,model".Third,createacitygovernmentpublicaffairsnetwork.WerelyontheGovernmentWebsite,wascompletedonMay24,theprovince'sfirstpublicaffairsnetwork.Over
X1k8=fft(x1n,8);%计算x1n的8点DFT
X1k16=fft(x1n,16);%计算x1n的16点DFT
X2k8=fft(x2n,8);%计算x1n的8点DFT
X2k16=fft(x2n,16);%计算x1n的16点DFT
X3k8=fft(x3n,8);%计算x1n的8点DFT
X3k16=fft(x3n,16);%计算x1n的16点DFT
%以下绘制幅频特性曲线
subplot(2,2,1);mstem(X1k8);%绘制8点DFT的幅频特性图title('(1a)8点DFT[x_1(n)]');xlabel('ω/π');ylabel('幅度');axis([0,2,0,1.2*max(abs(X1k8))])subplot(2,2,3);mstem(X1k16);%绘制16点DFT的幅频特性图title('(1b)16点DFT[x_1(n)]');xlabel('ω/π');ylabel('幅度');axis([0,2,0,1.2*max(abs(X1k16))])figure
(2)
subplot(2,2,1);mstem(X2k8);%绘制8点DFT的幅频特性图title('(2a)8点DFT[x_2(n)]');xlabel('ω/π');ylabel('幅度');axis([0,2,0,1.2*max(abs(X2k8))])subplot(2,2,2);mstem(X2k16);%绘制16点DFT的幅频特性图title('(2b)16点DFT[x_2(n)]');xlabel('ω/π');ylabel('幅度');axis([0,2,0,1.2*max(abs(X2k16))])subplot(2,2,3);mstem(X3k8);%绘制8点DFT的幅频特性图title('(3a)8点DFT[x_3(n)]');xlabel('ω/π');ylabel('幅度');axis([0,2,0,1.2*max(abs(X3k8))])subplot(2,2,4);mstem(X3k16);%绘制16点DFT的幅频特性图feelfreetolistentotheirvoicesandhelpthemassessolveproblems,wewereofficiallyopenedonMay10"12345"Mayorcalls,formulatedrulesandregulations,equippedwithafull-timestaff,a24-houron-dutysystem,peopletocalltoreceive,reply,action,reminders,feedbackandsoon.Byyearend,handledthecrowdcalls1076,94.7%feedbackrate.ByMayorcallsactivecoordinationtosolvealargenumberofbearsontheimmediateinterestsofthepeopleandissuesofgreatlives,butalsoforleadershipresearchanddecisiontocollectalotofgoodideasandsuggestions,byallsectorsofthecommunityalike.Second,startMunicipalGovernmentAffairsHallbuilt.OnMay11,webuiltandlaunchedthecity-governmentlobby,weresettledin12departments,strictimplementationoffirstaskingdutysystem,servicesystem,systemofgratuitous,"receiving,internalcoordination,headofthewindowhandle,limitedtimeconcluded"one-stopservice.Bytheendoftodaytoacceptvarioustypesof3,273,originallyofupto100%.RunningGovernmentAffairsHall,theconvenienceofthemasses,promotingopenGovernment,improvetheinvestmentenvironmentandsolvetheirpracticalproblems,andsodidalotofwork,masses,servethecommunityfortheGovernmenttoplayaverygood"window,link,model".Third,createacitygovernmentpublicaffairsnetwork.WerelyontheGovernmentWebsite,wascompletedonMay24,theprovince'sfirstpublicaffairsnetwork.Over
title('(3b)16点DFT[x_3(n)]');xlabel('ω/π');ylabel('幅度');axis([0,2,0,1.2*max(abs(X3k16))])
%实验内容
(2)周期序列谱分析==================================
N=8;n=0:
N-1;%FFT的变换区间N=8
x4n=cos(pi*n/4);
x5n=cos(pi*n/4)+cos(pi*n/8);X4k8=fft(x4n);%计算x4n的8点DFT
X5k8=fft(x5n);%计算x5n的8点DFT
N=16;n=0:
N-1;%FFT的变换区间N=16
x4n=cos(pi*n/4);
x5n=cos(pi*n/4)+cos(pi*n/8);X4k16=fft(x4n);%计算x4n的16点DFT
X5k16=fft(x5n);%计算x5n的16点DFT
figure(3)
subplot(2,2,1);mstem(X4k8);%绘制8点DFT的幅频特性图title('(4a)8点DFT[x_4(n)]');xlabel('ω/π');ylabel('幅度');axis([0,2,0,1.2*max(abs(X4k8))])subplot(2,2,3);mstem(X4k16);%绘制16点DFT的幅频特性图title('(4b)16点DFT[x_4(n)]');xlabel('ω/π');ylabel('幅度');axis([0,2,0,1.2*max(abs(X4k16))])subplot(2,2,2);mstem(X5k8);%绘制8点DFT的幅频特性图title('(5a)8点DFT[x_5(n)]');xlabel('ω/π');ylabel('幅度');axis([0,2,0,1.2*max(abs(X5k8))])feelfreetolistentotheirvoicesandhelpthemassessolveproblems,wewereofficiallyopenedonMay10"12345"Mayorcalls,formulatedrulesandregulations,equippedwithafull-timestaff,a24-houron-dutysystem,peopletocalltoreceive,reply,action,reminders,feedbackandsoon.Byyearend,handledthecrowdcalls1076,94.7%feedbackrate.ByMayorcallsactivecoordinationtosolvealargenumberofbearsontheimmediateinterestsofthepeopleandissuesofgreatlives,butalsoforleadershipresearchanddecisiontocollectalotofgoodideasandsuggestions,byallsectorsofthecommunityalike.Second,startMunicipalGovernmentAffairsHallbuilt.OnMay11,webuiltandlaunchedthecity-governmentlobby,weresettledin12departments,strictimplementationoffirstaskingdutysystem,servicesystem,systemofgratuitous,"receiving,internalcoordination,headofthewindowhandle,limitedtimeconcluded"one-stopservice.Bytheendoftodaytoacceptvarioustypesof3,273,originallyofupto100%.RunningGovernmentAffairsHall,theconvenienceofthemasses,promotingopenGovernment,improvetheinvestmentenvironmentandsolvetheirpracticalproblems,andsodidalotofwork,masses,servethecommunityfortheGovernmenttoplayaverygood"window,link,model".Third,createacitygovernmentpublicaffairsnetwork.WerelyontheGovernmentWebsite,wascompletedonMay24,theprovince'sfirstpublicaffairsnetwork.Over
subplot(2,2,4);mstem(X5k16);%绘制16点DFT的幅频特性图title('(5b)16点DFT[x_5(n)]');xlabel('ω/π');ylabel('幅度');axis([0,2,0,1.2*max(abs(X5k16))])
%实验内容(3)模拟周期信号谱分析===============================
figure(4)
Fs=64;T=1/Fs;
N=16;n=0:
N-1;%FFT的变换区间N=16
x6nT=cos(8*pi*n*T)+cos(16*pi*n*T)+cos(20*pi*n*T);%对x6(t)16点采样X6k16=fft(x6nT);%计算x6nT的16点DFT
%将零频率移到频谱中心X6k16=fftshift(X6k16);
Tp=N*T;F=1/Tp;%频率分辨率F
k=-N/2:
N/2-1;fk=k*F;%产生16点DFT对应的采样点频率(以零频率为中心)
subplot(3,1,1);stem(fk,abs(X6k16),'.');boxon%绘制8点DFT的幅频特性图
title('(6a)16点|DFT[x_6(nT)]|');xlabel('f(Hz)');ylabel('幅度');axis([-N*F/2-1,N*F/2-1,0,1.2*max(abs(X6k16))])
N=32;n=0:
N-1;%FFT的变换区间N=16
x6nT=cos(8*pi*n*T)+cos(16*pi*n*T)+cos(20*pi*n*T);%对x6(t)32点采样X6k32=fft(x6nT);%计算x6nT的32点DFT
X6k32=fftshift(X6k32);%将零频率移到频谱中心
Tp=N*T;F=1/Tp;%频率分辨率F
k=-N/2:
N/2-1;fk=k*F;%产生16点DFT对应的采样点频率(以零频率为中心)
feelfreetolistentotheirvoicesandhelpthemassessolveproblems,wewereofficiallyopenedonMay10"12345"Mayorcalls,formulat