Signal Processing Toolbox
periodogram

Power spectral density (PSD) using a periodogram

Syntax

• ```[Pxx,w] `= `periodogram(x)
[Pxx,w]` = `periodogram(x,window)
[Pxx,w]` = `periodogram(x,window,nfft)
[Pxx,f]` = `periodogram(x,window,nfft,fs)
[Pxx,...]` = `periodogram(x,...,'`range`')
periodogram(...)
```

Description

```[Pxx,w] = periodogram(x) ``` returns the power spectral density (PSD) estimate `Pxx` of the sequence `x` using a periodogram. The power spectral density is calculated in units of power per radians per sample. The corresponding vector of frequencies `w` is computed in radians per sample, and has the same length as `Pxx`.

A real-valued input vector `x` produces a full power one-sided (in frequency) PSD (by default), while a complex-valued `x` produces a two-sided PSD.

In general, the length N of the FFT and the values of the input `x` determine the length of `Pxx` and the range of the corresponding normalized frequencies. For this syntax, the (default) length N of the FFT is the larger of 256 and the next power of 2 greater than the length of `x`. The following table indicates the length of `Pxx` and the range of the corresponding normalized frequencies for this syntax.

 Real/Complex Input Data Length of Pxx Range of the Corresponding Normalized Frequencies Real-valued (N/2) +1 [0, ] Complex-valued N [0, 2)

```[Pxx,w] = periodogram(x,window) ``` returns the PSD estimate `Pxx` computed using the modified periodogram method. The vector `window` specifies the coefficients of the window used in computing a modified periodogram of the input signal. Both input arguments must be vectors of the same length. When you don't supply the second argument `window`, or set it to the empty vector `[]`, a rectangular window (`rectwin`) is used by default. In this case the standard periodogram is calculated.

```[Pxx,w] = periodogram(x,window,nfft) ``` uses the modified periodogram to estimate the PSD while specifying the length of the FFT with the integer `nfft`. If you set `nfft` to the empty vector `[]`, it takes the default value for N listed in the previous syntax.

The length of `Pxx` and the frequency range for `w` depend on `nfft` and the values of the input `x`. The following table indicates the length of `Pxx` and the frequency range for `w` for this syntax.

 Real/Complex Input Data nfft Even/Odd Length of Pxx Range of w Real-valued Even `(nfft/2 + 1)` [0, ] Real-valued Odd `(nfft + 1)/2` [0, ) Complex-valued Even or odd `nfft` [0, 2)

 Note    `periodogram` uses an `nfft`-point FFT of the windowed data (`x.*window`) to compute the periodogram. If the value you specify for `nfft` is less than the length of `x`, then `x.*window` is wrapped modulo `nfft`. If the value you specify for `nfft` is greater than the length of `x`, then `x.*window` is zero-padded to compute the FFT.

```[Pxx,f] = periodogram(x,window,nfft,fs) ``` uses the sampling frequency `fs` specified as an integer in hertz (Hz) to compute the PSD vector (`Pxx`) and the corresponding vector of frequencies (f). In this case, the units for the frequency vector are in Hz. The spectral density produced is calculated in units of power per Hz. If you specify `fs` as the empty vector `[]`, the sampling frequency defaults to 1 Hz.

The frequency range for `f` depends on `nfft`, `fs`, and the values of the input `x`. The length of `Pxx` is the same as in the table above. The following table indicates the frequency range for `f` for this syntax.

 Real/Complex Input Data nfft Even/Odd Range of f Real-valued Even `[0,fs/2]` Real-valued Odd `[0,fs/2)` Complex-valued Even or odd `[0,fs)`

```[Pxx,f] = periodogram(x,window,nfft,fs,'range') ``` or

```[Pxx,w] = periodogram(x,window,nfft,'range') ``` specifies the range of frequency values to include in `f` or `w`. This syntax is useful when `x` is real. '`range`' can be either:

• `'twosided'`: Compute the two-sided PSD over the frequency range `[0,fs)`. This is the default for determining the frequency range for complex-valued `x`.
• If you specify `fs` as the empty vector, `[]`, the frequency range is `[0,1)`.
• If you don't specify `fs`, the frequency range is [0, 2).
• `'onesided'`: Compute the one-sided PSD over the frequency ranges specified for real `x`. This is the default for determining the frequency range for real-valued `x`.
 Note    You can put the string argument `'``range``'` anywhere in the input argument list after window.

```periodogram(...) ``` with no outputs plots the power spectral density in dB per unit frequency in the current figure window. The frequency range on the plot is the same as the range of output `w` (or `f`) for the syntax you use.

Examples

Compute the periodogram of a 200 Hz signal embedded in additive noise using the default window:

• ```randn('state',0);
Fs = 1000;
t = 0:1/Fs:.3;
x = cos(2*pi*t*200)+0.1*randn(size(t));
periodogram(x,[],'twosided',512,Fs)

```

Algorithm

The periodogram for a sequence [x1, ... , xn] is given by the following formula:

This expression forms an estimate of the power spectrum of the signal defined by the sequence [x1, ... , xn].

If you weight your signal sequence by a window [w1, ... , wn], then the weighted or modified periodogram is defined as

In either case, `periodogram` uses an `nfft`-point FFT to compute the power spectral density as , where F is

• 2 when you do not supply the sampling frequency
• `fs` when you supply the sampling frequency

`dspdata.msspectrum`, `pburg`, `pcov`, `peig`, `pmcov`, `pmtm`, `pmusic`, `pwelch`, `pyulear`

References

[1] Stoica, P., and R.L. Moses, Introduction to Spectral Analysis, Prentice-Hall, 1997, pp. 24-26.

[2] Welch, P.D, "The Use of Fast Fourier Transform for the Estimation of Power Spectra: A Method Based on Time Averaging Over Short, Modified Periodograms," IEEE Trans. Audio Electroacoustics, Vol. AU-15 (June 1967), pp. 70-73.

[3] Oppenheim, A.V., and R.W. Schafer, Discrete-Time Signal Processing, Prentice-Hall, 1989, pp. 730-742.

 peig phasedelay