Signal Processing Toolbox |

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,...,'

') periodogram(...)*range*

**Description**

`[Pxx,w`

returns the power spectral density (PSD) estimate `] = `

periodogram(x)
`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]`

returns the PSD estimate ` = `

periodogram(x,window)
`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]`

uses the modified periodogram to estimate the PSD while specifying the length of the FFT with the integer ` = `

periodogram(x,window,nfft)
`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.

`[Pxx,f]`

uses the sampling frequency ` = `

periodogram(x,window,nfft,fs)
`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]`

or` = `

periodogram(x,window,nfft,fs,'

')
*range*

`[Pxx,w]`

specifies the range of frequency values to include in ` = `

periodogram(x,window,nfft,'

')
*range*`f`

or `w`

. This syntax is useful when `x`

is real. '

' can be either:*range*

`'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`

.

```
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 [*x*_{1}, ... , *x*_{n}] is given by the following formula:

This expression forms an estimate of the power spectrum of the signal defined by the sequence [*x*_{1}, ... , *x*_{n}].

If you weight your signal sequence by a window [*w*_{1}, ... , *w*_{n}], 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

**See Also**

`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 |

© 1994-2005 The MathWorks, Inc.