measure time from fft spectrogram
5 views (last 30 days)
trying to convert the time scale of a signal visualized on a spectrogram in sec/msec.
the spectrogram has been calculated using known values of
1) sampling frequency (20k)
2) window size (in samples) (1024)
3) overlap (0.9)
4) total duration of the recording in samples (tspec = 11755)
5) total duration of the recording in seconds (60)
calculation of the total duration in seconds: total duration (samples) / total duration (seconds)
-> length(tspec)/60 = 195.9167
calculation of the signal duration in sec = duration of signal in samples / 195.9167
is this correct or is there any smearing of the signal time units due to nfft and overlap ?
Greg Dionne on 13 May 2019
You can extract the time vector from the third output of the spectrogram function.
[S,F,T,Pxx] = spectrogram(X,...)
F is the frequency vector corresponding to the rows in S and Pxx.
T is the time vector corresponding to the columns of S and Pxx.
The time and frequencies correspond to the center of each estimate in S and Pxx; the resolution of the estimates in time and frequency are governed by the choice of window and overlap used. If there aren't enough samples to complete a full FFT at the end of the input signal, X, then the result is truncated.