Effacer les filtres
Effacer les filtres

correct way visualize short time fourier transform on each window

7 vues (au cours des 30 derniers jours)
konoha
konoha le 3 Mar 2022
I am trying to visulize the short time fourier transform by windows
the code from below is what i have currently, but i am not sure if i am doing it or not.
any corrections and suggestions are welcome, thanks in advance.
%%
fs = 8000;
t = 0:1/fs:1;
signal = sin(2*pi*10*t) + 0.5*sin(2*pi*3*t);
signal_sigure = figure;
plot(t,signal)
%%
[s1, f1, t1] = stft(signal, 'Window', hamming(128,'periodic'),'OverlapLength',64,'FFTLength',128);
stft_figure = figure;
spectrogram(signal, hamming(128,'periodic'), 64, 128, fs)
%%
overlap_length = 64;
temp_t = 0:t1(4);
stft_window_fig = figure;
subplot(4,1,1)
stft_freq = zeros(size(temp_t));
stft_freq(1:t1(1)*2) = abs(s1(:, 1));
plot(temp_t, stft_freq)
xlabel("t(ms)")
ylabel("$|ST\hat{f}|$",'interpreter','latex')
title("ST$\hat{f}(\xi, \tau=64)$",'interpreter','latex')
subplot(4,1,2)
stft_freq = zeros(size(temp_t));
stft_freq(t1(1)+1:t1(2)+overlap_length) = abs(s1(:, 2));
plot(temp_t, stft_freq)
xlabel("t(ms)")
ylabel('$|ST\hat{f}|$','interpreter','latex')
title("ST$\hat{f}(\xi, \tau=128)$",'interpreter','latex')
subplot(4,1,3)
stft_freq = zeros(size(temp_t));
stft_freq(t1(2)+1:t1(3)+overlap_length) = abs(s1(:, 3));
plot(temp_t, stft_freq)
xlabel("t(ms)")
ylabel("$|ST\hat{f}|$",'interpreter','latex')
title("ST$\hat{f}(\xi, \tau=194)$",'interpreter','latex')
subplot(4, 1, 4)
plot(t, signal)
xlabel("t(s)")
ylabel("f(t)")
title("f(t) = sin(2\pi10t)+0.5sin(2\pi3t)", 'interpreter','latex')

Réponses (1)

NATHANIEL ASIAK
NATHANIEL ASIAK le 3 Mar 2022
Yes, this looks right. You can however use a for loop to display the windows and then display the original signal in the last subplot. Hope this is helpful
This link gives an example on how to do this

Produits


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by