《短时傅里叶变换matlab程序计算机matlab计算机matlab.pdf》由会员分享,可在线阅读,更多相关《短时傅里叶变换matlab程序计算机matlab计算机matlab.pdf(3页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、短时傅里叶变换mat I ab程 序(总2页)本页仅作为文档封面,使用时可以删除 This document is for reference only-rar21 year.March function SpeczFreq=STFT(Sig,nLevel,WinLen,SampFreq)%计算离散信号的短时傅里叶变换;%Sig待分析信号;%nLevel频率轴长度划分(默认值512);%WinLen汉宁窗长度(默认值64);%SampFreq信号的采样频率(默认值1);讦(nargin 1),errorfAt least one parameter required!1);end;Sig=re
2、al(Sig);SigLe n=length(Sig);if(nargin 4)z SampFreq=l;end 讦(nargin 3),WinLen=64;end if(nargin 2),n Level=513;end nLevel=ceil(nLevel/2)*2+l;WinLen=ceil(WinLen/2)*2+l;WinFun=exp(-6*linspace(-l,l/WinLen).A2);WinFun=WinFun/norm(WinFun);Lh=(WinLen-l)/2;Ln 二(n Level-l)/2;Spec=zeros(n Level,SigL en);wait=wa
3、itbar(O/Under calculation,please wait.1);for iLoop=l:SigLen,waitbar(iLoop/SigLen,wait);iLeft二min(iLoopl 丄h 丄n);iRight=min(gLen-iLoop丄 h,Ln);ilndex=-iLeft:iRight;ilndexl=il ndex+iLoop;ilndex2=ilndex+Lh+l;lndex=ilndex+L n+1;Spec(lndex,iLoop)=Sig(ilndexl).*conj(WinFun(ilndex2);end;close(wait);Spec=fft(
4、Spec);Spec=abs(Spec(l:(end-l)/2/:);Freq=linspace(0/,(nLevel-l)/2)*SampFreq;t=(O:(SigLen-l)/SampFreq;elf set(gcf;Posit ion1,20 100 500 430);setfgcf/Color/w1);axesfTosition,!);长度划分默认值汉宁窗长度默认值信号的采样频率默认值讦讦二二丄丄丄时频谱图时域波形频谱mesh(t,Freq,Spec);axis(min(t)max(t)0 max(Freq)J);colorbar xlabel(t/s);ylabelff/Hz);title(STFT 时频谱图);axes(,Position,);plot(t,Sig);axis tight ylabelCx(t);title/时域波形J;axesfPositionJ);PSP=abs(fft(Sig);Freq=linspace(0,l,SigLe n)*SampFreq;plot(PSP(l:end/2),Freq(l:end/2);titled 频谱!);长度划分默认值汉宁窗长度默认值信号的采样频率默认值讦讦二二丄丄丄时频谱图时域波形频谱