短时傅里叶变换matlab程序Word下载.docx
《短时傅里叶变换matlab程序Word下载.docx》由会员分享,可在线阅读,更多相关《短时傅里叶变换matlab程序Word下载.docx(3页珍藏版)》请在冰点文库上搜索。
%WinLen汉宁窗长度(默认值64);
%SampFreq信号的采样频率(默认值1);
讦(nargin<
1),
errorfAtleastoneparameterrequired!
1);
end;
Sig=real(Sig);
SigLen=length(Sig);
if(nargin<
4)z
SampFreq=l;
end
3),
WinLen=64;
2),
nLevel=513;
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二(nLevel-l)/2;
Spec=zeros(nLevel,SigLen);
wait=waitbar(O/Undercalculation,pleasewait...1);
foriLoop=l:
SigLen,
waitbar(iLoop/SigLen,wait);
iLeft二min([iLoop・l丄h丄n]);
iRight=min(⑸gLen-iLoop丄h,Ln]);
ilndex=-iLeft:
iRight;
ilndexl=ilndex+iLoop;
ilndex2=ilndex+Lh+l;
lndex=ilndex+Ln+1;
Spec(lndex,iLoop)=Sig(ilndexl).*conj(WinFun(ilndex2));
end;
close(wait);
Spec=fft(Spec);
Spec=abs(Spec(l:
(end-l)/2/:
));
Freq=linspace(0/,(nLevel-l)/2)*SampFreq;
t=(O:
(SigLen-l))/SampFreq;
elf
set(gcf;
Position1,[20100500430]);
setfgcf/Color'
/w1);
axesfTosition'
!
]);
mesh(t,Freq,Spec);
axis([min(t)max(t)0max(Freq)J);
colorbar
xlabel('
t/s'
);
ylabelff/Hz'
title('
STFT时频谱图'
axes(,Position,,[]);
plot(t,Sig);
axistight
ylabelCx(t)'
);
title/时域波形J;
axesfPosition'
J]);
PSP=abs(fft(Sig));
Freq=linspace(0,l,SigLen)*SampFreq;
plot(PSP(l:
end/2),Freq(l:
end/2));
titled频谱!