Prev Next stft

Short-Tine-Fourier-Transfrom (STFT)
Syntax y = stft(x,Nblk) (uses contiguous, non-overlapping blocks, i.e., Noffset=Nblk, RECTANGULAR window)
Syntax y = stft(x,Nblk,Noffset) (uses an arbitrary offset, RECTANGULAR window)
Syntax y = stft(x,Nblk,Noffset,wintype) (specifies a window other than KAISER or GAUSSIAN)
Syntax y = stft(x,Nblk,Noffset,wintype,winparam) (specifies a KAISER or GAUSSIAN window)
Include: include spt\stft.oms
See Also fmmod , pmmod , quadmod

ARGUMENTS:  
   INPUTS:
      x        = VECTOR, any numerical type. Represents input
                 data. Coerced to COMPLEX for local processing.
                 Must have rowdim(x)>=2 or 'novalue' is returned.
      Nblk     = SCALAR, any numerical type. Block length for
                 individual fourier transforms. Coerced to INTEGER
                 for local processing. Must be Nblk>=2,
                 int(Nblk)<=rowdim(x).
      Noffset  = SCALAR, any numerical type. Offset for overlapping
                 blocks. Coerced to INTEGER for local processing.
                 Noffset>=1, Noffset<=rowdim(x).
      wintype  = CHAR. One of ["RECTANGULAR"|"TRIANGULAR"|
                 "HAMMING"|"HANNING"|"NUTTALL"|"BLACKMAN"|
                 "GAUSSIAN"|"KAISER"].
      winparam = SCALAR, any numerical type. Parameter used by
                 GAUSSIAN or KAISER window functions. Coerced to
                 DOUBLE for local processing.
   RETURN: MATRIX, type COMPLEX, of rowdim=NBLK. STFT of the input arranged as DFTs in columns.

Description

Performs a SHORT-TIME-FOURIER-TRANSFORM (STFT) on an input matrix.

The STFT accepts a vector of input data and returns a matrix of discrete fourier transforms arranged as columns of the matrix. The input data 'x' is transformed in segments of 'Nblk' elements at a time, each segment starting at increasing integer multiples of 'Noffset'. The intrinsic 'dft()' function is used for the fourier transform and the returned matrix is of type COMPLEX. A window function may be specified which will be applied to each block of data processed. Row vectors may be input and are treated as if they were column vectors.

The STFT may be thought of as producing a frequency versus time anlaysis of sampled time data. Each column of the returned matrix represents the frequency spectrum of the input at a particular time into the record, averaged over a short block of data. This matrix may be contour or mesh plotted to view the time progressing frequency content of the record, analyzed for frequency or amplitude charateristics at selected times, or processed in many other ways.

Example

Plot the short term Fourier Transform of a simple FM modulated carrier. The magnitude of the resulting segments is plotted as a contour plot to visualize the progress of the waveform through time.

#--- System parameters ---
N  = 1024;                 # Record length
fs = double(N);            # Sampling Rate
dt = 1/fs;                 # Sampling interval

#--- An FM waveform ---

fc = fs/8;                 # Carrier freq
fm = 4;                    # Modulation freq
pc = 0d0;                  # Phase offset

t  = timeaxis(dt,N);       # Time vector
m  = cos(2*PI*fm*t);       # Modulation waveform
kf = 40d0;                 # Modulator sensitivity

x = fmmod(m,kf,fc,pc,fs);  # Create the FM waveform

#--- Do the stft() ---

Nblk    = N/16;            # Block size
Noffset = Nblk/4;          # Offset
wintype = "HAMMING";       # Window type
y       = stft(x,Nblk,Noffset,wintype);

U = rowdim(y);
u = {seq(U/2)+U/2, seq(U/2)};
y = y(u,:); # Swap halves for normal display