您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 其它行业文档 > FFT实验(含FFT实现程序)
1/11实验报告实验名称:快速傅里叶变换一实验目的1在理论学习的基础上,通过本实验加深对快速傅立叶变换的理解;2熟悉并掌握按时间抽取FFT算法的程序;3了解应用FFT进行信号频谱分析过程中可能出现的问题,例如混淆、泄漏、栅栏效应等,以便在实际中正确应用FFT。二实验内容1仔细分析教材第六章‘时间抽取法FFT的FORTRAN程序’,编制出相应的用FFT进行信号分析的C语言程序或Matlab程序;2用FFT程序分析正弦信号,分别在以下情况进行分析并讨论所得的结果:a)信号频率F=50Hz,采样点数N=32,采样间隔T=0.000625sb)信号频率F=50Hz,采样点数N=32,采样间隔T=0.005sc)信号频率F=50Hz,采样点数N=32,采样间隔T=0.0046875sd)信号频率F=50Hz,采样点数N=32,采样间隔T=0.004se)信号频率F=50Hz,采样点数N=64,采样间隔T=0.000625sf)信号频率F=250Hz,采样点数N=32,采样间隔T=0.005sg)将c)信号后补32个0,做64点FFT三实验结果1在Matlab下编写如下的程序清单如下:%MyFft.m%-------用户界面,等待输入数据--------%------------------------------------index=input('请输入信号频率,采样点数,采样周期F,N,T:','s');index=str2num(index);F=index(1);%信号频率N=index(2);%采样点数2/11T=index(3);%采样周期%-------------原始数据定义-----------%------------------------------------x0=sin(2*pi*F*(0:N-1)*T);%-------------是否补零---------------%------------------------------------REPLY=input('是否补零?Y/N:','s');ifREPLY=='Y'COUNTS=input('补零后总点数:','s');N=str2num(COUNTS);x0(length(x0)+1:N)=0;end%--------------码位倒置--------------%------------------------------------revi=bitrevorder(1:N);x(1:N)=x0(revi(1:N));%--------------fft运算---------------%------------------------------------L=log2(N);%L表示蝶形算法的层数fori=1:Lgrp(i)=pow2(L-i);%grp为各层分组数wdt(i)=pow2(i-1);%wdt为各层两点蝶形元素的距离forj=1:grp(i)fork=1:wdt(i)real=cos(2*pi*(k-1)*grp(i)/N);imag=-sin(2*pi*(k-1)*grp(i)/N);w=complex(real,imag);temp=x(k+wdt(i)+(j-1)*N/grp(i))*w;x(k+wdt(i)+(j-1)*N/grp(i))=x(k+(j-1)*N/grp(i))-temp;x(k+(j-1)*N/grp(i))=x(k+(j-1)*N/grp(i))+temp;endendend3/11%--------------频率特性--------------%------------------------------------mag=abs(x);maxmag=max(mag);mag=mag/maxmag;f=(0:N-1)*(1/N/T);subplot(2,1,1);stem(0:N-1,mag);grid;axis([0,32,0,1])grid;xlabel('K(Frequency)')ylabel('|X|(normalized)')title('FFTMagnitudePart')2如上要求计算相应结果,得到FFT的结果如下:a)a),b),c),d)FFT结果如下:F=50HzN=32a)T=0.000625b)T=0.005c)T=0.0046875d)T=0.004X(0)001.1000.950X(1)0–16.000i01.1300.990-0.090iX(2)001.2101.110-0.180iX(3)001.3601.350-0.310iX(4)001.6301.870-0.520iX(5)002.1803.200-0.990iX(6)003.50011.380-3.690iX(7)0010.250-7.840+2.530iX(8)00–16.000i-10.150-3.080+0.950iX(9)00-3.400-2.000+0.570iX(10)00-2.070-1.540+0.390iX(11)00-1.520-1.290+0.280iX(12)00-1.240-1.1400+0.200iX(13)00-1.070-1.050+0.140i4/11X(14)00-0.970-0.990+0.090iX(15)00-0.920-0.960+0.040iX(16)00-0.910-0.950X(17)00-0.920-0.960-0.040iX(18)00-0.970-0.990-0.090iX(19)00-1.070-1.050-0.140iX(20)00-1.240-1.140-0.200iX(21)00-1.520-1.290-0.280iX(22)00-2.070-1.540-0.390iX(23)00-3.400-2.000-0.570iX(24)00+16.000i-10.150-3.080-0.950iX(25)0010.250-7.840-2.530iX(26)003.50011.380+3.690iX(27)002.1803.200+0.990iX(28)001.6301.870+0.520iX(29)001.3601.350+0.310iX(30)001.2101.110+0.180iX(31)0+16.000i01.1300.990+0.090ib)e),f),g)FFT结果如表e)F=50Hz,N=64,T=0.000625sf)F=250Hz,N=32,T=0.005sg)将c)信号后补32个0X(0)001.100X(1)000.000X(2)0-32.0000i01.130X(3)000.000X(4)001.210X(5)000.000X(6)001.3605/11X(7)000.000X(8)00–16.000i1.630X(9)000.000X(10)002.180X(11)000.000X(12)003.500X(13)000.000X(14)0010.250X(15)000.000X(16)00-10.150X(17)000.000X(18)00-3.400X(19)000.000X(20)00-2.070X(21)000.000X(22)00-1.520X(23)000.000X(24)00+16.000i-1.240X(25)000.000X(26)00-1.070X(27)000.000X(28)00-0.970X(29)000.000X(30)00-0.920X(31)000.000X(32)0——-0.910X(33)0——0.000X(34)0——-0.920X(35)0——0.0006/11X(36)0——-0.970X(37)0——0.000X(38)0——-1.070X(39)0——0.000X(40)0——-1.240X(41)0——0.000X(42)0——-1.520X(43)0——0.000X(44)0——-2.070X(45)0——0.000X(46)0——-3.400X(47)0——0.000X(48)0——-10.150X(49)0——0.000X(50)0——10.250X(51)0——0.000X(52)0——3.500X(53)0——0.000X(54)0——2.180X(55)0——0.000X(56)0——1.630X(57)0——0.000X(58)0——1.360X(59)0——0.000X(60)0——1.210X(61)0——0.000X(62)0+32.0000i——1.130X(63)0——0.0007/113作出各种情况下的幅频特性如图:a)F=50Hz,N=32,T=0.000625sb)F=50Hz,N=32,T=0.005sc)F=50Hz,N=32,T=0.0046875s05101520253000.51K(Frequency)|X|(normalized)FFTMagnitudePart00.20.40.60.811.21.41.61.8200.51Frequencyinpiunits|X|(normalized)DTFTMagnitudePart05101520253000.51K(Frequency)|X|(normalized)FFTMagnitudePart00.20.40.60.811.21.41.61.8200.51Frequencyinpiunits|X|(normalized)DTFTMagnitudePart8/11d)F=50Hz,N=32,T=0.004se)F=50Hz,N=64,T=0.000625s05101520253000.51K(Frequency)|X|(normalized)FFTMagnitudePart00.20.40.60.811.21.41.61.8200.51Frequencyinpiunits|X|(normalized)DTFTMagnitudePart05101520253000.51K(Frequency)|X|(normalized)FFTMagnitudePart00.20.40.60.811.21.41.61.8200.51Frequencyinpiunits|X|(normalized)DTFTMagnitudePart9/11f)F=250Hz,N=32,T=0.005sg)将c)信号后补32个0,做64点FFT010203040506000.51K(Frequency)|X|(normalized)FFTMagnitudePart00.20.40.60.811.21.41.61.8200.51Frequencyinpiunits|X|(normalized)DTFTMagnitudePart05101520253000.51K(Frequency)|X|(normalized)FFTMagnitudePart00.20.40.60.811.21.41.61.8200.51Frequencyinpiunits|X|(normalized)DTFTMagnitudePart10/11四结果分析1采样要满足Nyquist采样定理,才有可能得到良好的频域特性,在以上各项中,仅有f)没有满足采样条件,但是由于采样的原因,实际上在FFT中并未反映出来(即栅栏效应),但是DTFT中这样的欠采样影响是明显的(即频谱发生了混淆)。2FFT是在频域对DTFT的采样,若采样窗恰好为信号的整数周期,那么在DFT(即FFT)中能表现出良好的正弦特性(单谱线结构),反之若采样窗不是信号的整数周期,那么在FFT中则有其他频率分量出现。3应该说,采样信号的初始相位对FFT的结果也会有影响,但是本实验中未涉及,因此也不再做进一步的讨论。五小结通过本次FFT实验,我更好更深刻的理解了真个FFT的流程,对同时对各项影响因素对fft的影响有了更好的认识,也增进了对采样的理解。六附:DFTF程序清单functionX=pl
本文标题:FFT实验(含FFT实现程序)
链接地址:https://www.777doc.com/doc-7178236 .html