The short-time Fourier transform (STFT) is used to analyze how the frequency content of a nonstationary signal changes over time.

The STFT of a signal is calculated by sliding an *analysis window* of
length $$M$$ over the signal and calculating the discrete Fourier transform of the
windowed data. The window hops over the original signal at intervals of $$R$$ samples. Most window functions taper off at the edges to avoid spectral
ringing. If a nonzero overlap length $$L$$ is specified, overlap-adding the windowed segments compensates for the
signal attenuation at the window edges. The DFT of each windowed segment is added to a
matrix that contains the magnitude and phase for each point in time and frequency. The
number of columns in the STFT matrix is given by

where $${N}_{x}$$ is the length of the original signal $$x(n)$$ and the ⌊⌋ symbols denote the floor function. The number of rows in the matrix equals *N*_{DFT}, the number of DFT points, for centered and two-sided transforms and ⌊*N*_{DFT}/2⌋ + 1 for one-sided transforms.

The STFT matrix is given by $$X(f)=\left[\begin{array}{ccccc}{X}_{1}(f)& {X}_{2}(f)& {X}_{3}(f)& \cdots & {X}_{k}(f)\end{array}\right]$$ such that the $$m$$th element of this matrix is

where

$$g(n)$$ — Window function of length $$M$$.

$${X}_{m}(f)$$ — DFT of windowed data centered about time $$mR$$.

$$R$$ — Hop size between successive DFTs. The hop size is the difference between the window length $$M$$and the overlap length $$L$$.

The magnitude squared of the STFT yields the `spectrogram`

representation of the power spectral density of the function.