短時傅里葉變換,short-time fourier transformation,有時也叫加窗傅里葉變換,時間窗口使得信號只在某一小區間內有效,這就避免了傳統的傅里葉變換在時頻局部表達能力上的不足,使得傅里葉變換有了局部定位的能力。
1. spectrogram:matlab 下的 stft
How can I compute a short-time Fourier transform (STFT) in MATLAB?
stft 不同於 ft 之處在於,多了時間的概念,對信號
fs = 1000;
t = 0:1/fs:2;
y = sin(128*pi*t) + sin(256*pi*t);
figure;
win_sz = 128;
han_win = hanning(win_sz); % 選擇海明窗
nfft = win_sz;
nooverlap = win_sz - 1;
[S, F, T] = spectrogram(y, window, nooverlap, nfft, fs);
imagesc(T, F, log10(abs(S)))
set(gca, 'YDir', 'normal')
xlabel('Time (secs)')
ylabel('Freq (Hz)')
title('short time fourier transform spectrum')
2. cwt:連續小波變換
Time-Frequency Analysis of Modulated Signals
小波變換進一步拓展了時頻局部分析的能力。
[cfs,f] = cwt(quadchirp,'bump',fs);
helperCWTTimeFreqPlot(cfs,tquad,f,'surf','CWT of Quadratic Chirp','Seconds','Hz')
這里選擇的是 bump 型小波,選擇該類型的原因在於,當信號震盪劇烈,且更關注信號局部瞬變的時頻分析。
load quadchirp;
fs = 1000;
[S,F,T] = spectrogram(quadchirp,100,98,128,fs);
helperCWTTimeFreqPlot(S,T,F,'surf','STFT of Quadratic Chirp','Seconds','Hz')
這里可以進一步對比 STFT(短時傅里葉變換)和 CWT(連續小波變換)在時頻分析上的精細化刻畫能力。