DADiSP Worksheet Functions > Function Categories > Fourier Transforms and Signal Processing > SPECTRUM

 

SPECTRUM

Purpose:

Returns the normalized magnitude of the FFT.

Syntax:

SPECTRUM(series, len)

series

-

Any series or multi-column table.

len

-

Optional. An integer, the FFT length. Defaults to the length of the input series. If len > length(series), the series is padded with zeros.

Returns:

A real series or table.

Example:

W1: gsin(100, 0.01, 4)*5;setvunits("V")

W2: spectrum(W1)

 

Max(W2) occurs at 4 Hz. with an amplitude of 5. The length of W2 is 51 points.

Example:

W3: spectrum(W1, 2048)

 

Same as above except a 2048 point FFT is used to calculate the Spectrum, resulting in a 1025 point series.

 

image\spectrumpic.gif

Example:

fn := 1.0

W1: gsin(100,.01,fn);label(sprintf("Frequency: %g", fn))

W2: spectrum(W1, 1024)

fn:=1;while(fn<=100, fn++)

 

W2 displays a remarkably simple demonstration of aliasing errors due to undersampling the sinewave in W1.

Remarks:

The SPECTRUM is normalized so that a sinewave of amplitude A and frequency F yields a SPECTRUM of amplitude A at frequency F. If the input series is in Volts, the resulting SPECTRUM has units of Volts.

 

If len is larger than the length of series, the series is padded with zeros to length len before calculating the SPECTRUM. If len is less than the series length, the series is truncated to length len. If not specified, len defaults to a length of series.

 

The length of the final result is int(fftlen/2) + 1 where the last sample represents the Nyquist frequency.

 

The SPECTRUM is calculated by the FFT and has the following form:

 

spectrum(s) = 2*mag(fft(s))/length(s)

 

with frequency values from 0 to Fs/2 Hz., where Fs is the sampling rate of the data (i.e. rate(s)). The first value (DC component) and the last value (at Fs/2, the Nyquist frequency) are not scaled by 2 to preserve Parseval's theorem.

 

See AMPSPEC to compute the normalized complex amplitude spectrum.

 

See MAGSPEC to compute the magnitude of the normalized complex amplitude spectrum.

 

See POWSPEC to compute the power spectrum.

 

See PSD to compute the Power Spectral Density.

 

See SPECGRAM to compute a joint time-frequency distribution.

 

See WINFUNC for a list of windowing functions and amplitude correction schemes.

 

See NSPECTRUM to compute a N point spectrum by zero padding or time aliasing.

 

See DADiSP/FFTXL to optimize the underlying FFT computation.

See Also:

AMPSPEC

DADiSP/FFTXL

DFT

FFT

MAGSPEC

NSPECTRUM

PHASESPEC

POWSPEC

PSD

SPECGRAM

WINFUNC