correct way visualize short time fourier transform on each window
4 ビュー (過去 30 日間)
古いコメントを表示
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')
0 件のコメント
回答 (1 件)
NATHANIEL ASIAK
2022 年 3 月 3 日
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Fourier Analysis and Filtering についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!