Last active
April 1, 2022 16:37
-
-
Save yichao0319/3d5ffd3d5c88a8a55910cf1d0da6f39f to your computer and use it in GitHub Desktop.
matlab:spectrogram
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Spectrogram takes the STFT of the signal | |
win = floor(Fs/32); | |
noverlap = floor(win/4); % 75% overlap | |
Nfft = Fs; | |
% P matrix contains the power spectral density of each segment of the STFT | |
[S,F,T,P] = spectrogram(data, win, noverlap, Nfft, Fs); | |
fh = figure(1); clf; | |
imagesc(T, F, real(S)); | |
colorbar; | |
ax = gca; ax.YAxis.Exponent = 0; | |
set(gca,'YDir','normal') | |
ylim([17500 18500]); | |
xlabel('Time (s)'); | |
ylabel('Frequency (Hz)'); | |
title('Time-Frequency plot of a Audio signal'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment