Improve STFT Plot Clarity
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Abo
am 22 Apr. 2025
Kommentiert: Mathieu NOE
am 22 Apr. 2025
Hi,
I'm analyzing a time-domain signal using STFT and want to improve the clarity of the spectrogram. Here's my code:
load('D.mat')
nfft_custom = 1024*5;
wlen = nfft_custom;
win = hann(wlen, 'periodic');
[S, f, t_stft] = stft(AAA, 100000, ...
'Window', win, ...
'OverlapLength', round(0.5 * wlen), ...
'FFTLength', nfft_custom);
stft_dB = 20*log10(abs(S) + eps);
imagesc(t_stft, f, stft_dB); axis xy; ylim([0 800]); caxis([-70 0]);
xlabel('Time (s)'); ylabel('Frequency (Hz)');
0 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 22 Apr. 2025
hello @Abo
and welcome back !
fist idea with STFT is to maximize the overlap , but anyway the STFT has not the best performance when you look for time AND frequency accuracy (cwt would be a better choice : look at the example in : CWT-Based Time-Frequency Analysis
to reduce the amount of fft computation I decided to downsample the data first with decimate (otherwise you are just doing a lot of computations and throw 90% at the garbage bin
to further improve the rendering with imagesc you can use the option : 'Interpolation', 'bilinear'
load('D.mat')
Fs = 100000;
% decimate the data
r = 8;
AAA =decimate(AAA,r);
size(AAA)
Fs = Fs/r
%% spectrogram
nfft_custom = 1024;
wlen = nfft_custom;
win = hann(wlen, 'periodic');
[S, f, t_stft] = stft(AAA, Fs,'Window', win,'OverlapLength', round(0.95 * wlen), ...
'FFTLength', nfft_custom,'FrequencyRange',"onesided");
stft_dB = 20*log10(abs(S) + eps);
imagesc(t_stft, f, stft_dB, 'Interpolation', 'bilinear');
axis xy;
colormap('jet');
ylim([0 800]);
caxis([-80 0]);
xlabel('Time (s)'); ylabel('Frequency (Hz)');
colorbar('vert');
2 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!