stft.m

来自「基于matlab的短时傅立叶变换」· M 代码 · 共 37 行

M
37
字号
clear;
clc;
[Y,FS,NBITS,OPTS] = wavread('背景小噪声.wav');
X = Y(1:264565);
L = length(X);
N = round(FS * 0.025); %窗口大小为25ms
LL = floor(L/N);%帧数
subplot(4,1,1);
plot(X);
title('飞船录音指令');
grid;
fs=4096;
x=zeros(1,L);
t=0:L-1;
x=fft(X);
x=fftshift(x);
subplot(4,1,2);
plot((t-L/2)*fs/L,abs(x));
Nw=20;
l=Nw/2;
Tn=(L-Nw)/l+1;      %39
nfft=32;
TF=zeros(Tn,nfft);
for i=1:Tn
b=hamming(2l);
xw=x((i-1)*l+1:i*l+l).*b';
temp=fft(xw,nfft);
temp=fftshift(temp);
TF(i,:)=temp;
end
subplot(4,1,3);
fnew=((1:nfft)-nfft/2)*fs/nfft;
tnew=(1:Tn)*l*Ts;
[F,T]=meshgrid(fnew,tnew);
mesh(F,T,abs(TF));
subplot(4,1,4);
contour(F,T,abs(TF));

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?