Qu

stft

Builtin index · Signal processing

result = stft(x, nfft[, hop])

Input: x, nfft[, hop] · Output: result

What it is

x is a length-N real vector; nfft (number) is the frame/FFT size; hop (optional positional number -- hop= as a keyword is not accepted; default nfft/2, i.e. 50% overlap) is the sample stride between successive frame starts.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = stft(x, nfft[, hop])
x vectorx is a length-N real vector.
nfft[, hop] —not documented yet
result matrix or CMat
Returns an nfft×num_frames complex matrix (CMat, the full per-frame spectrum, not one-sided) — one column per frame, built from a periodic-Hann-windowed FFT per frame. abs(stft(x, ...)) is a spectrogram.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

  S = stft(x, 256, 128)
  spectrogram = abs(S)

from numerics-dsp

How it works

Short-time Fourier transform: stft(x, nfft[, hop]) -- a periodic-Hann-windowed FFT per frame, columns are frames. The default hop is 50% overlap (nfft/2). abs(stft(x, ...)) is a spectrogram.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.