mywelch

advertisement

Welch modified periodogram

MATLAB’s psd function estimates the power spectral density of a signal using the modified

Welch periodogram technique. Please read its help file:

» help psd

PSD Power Spectral Density estimate

Pxx = PSD(X,NFFT,Fs,WINDOW) estimates the Power Spectral Density of signal vector X using Welch's averaged periodogram method. X is divided into overlapping sections, each of which is detrended, then windowed by the WINDOW parameter, then zero-padded to length NFFT.

The magnitude squared of the length NFFT DFTs of the sections are averaged to form Pxx. Pxx is length NFFT/2+1 for NFFT even, (NFFT+1)/2 for NFFT odd, or NFFT if the signal X is complex. If you specify a scalar for WINDOW, a Hanning window of that length is used. Fs is the sampling frequency which doesn't effect the spectrum estimate but is used for scaling of plots.

[Pxx,F] = PSD(X,NFFT,Fs,WINDOW,NOVERLAP) returns a vector of frequen- cies the same size as Pxx at which the PSD is estimated, and overlaps the sections of X by NOVERLAP samples.

[Pxx, Pxxc, F] = PSD(X,NFFT,Fs,WINDOW,NOVERLAP,P) where P is a scalar between 0 and 1, returns the P*100% confidence interval for Pxx.

PSD(X,...,DFLAG), where DFLAG can be 'linear', 'mean' or 'none', specifies a detrending mode for the prewindowed sections of X.

DFLAG can take the place of any parameter in the parameter list

(besides X) as long as it is last, e.g. PSD(X,'none');

PSD with no output arguments plots the PSD in the current figure window, with confidence intervals if you provide the P parameter.

The default values for the parameters are NFFT = 256 (or LENGTH(X), whichever is smaller), NOVERLAP = 0, WINDOW = HANNING(NFFT), Fs = 2,

P = .95, and DFLAG = 'linear'. You can obtain a default parameter by leaving it off or inserting an empty matrix [], e.g. PSD(X,[],10000).

»

The modified Welch periodogram of the two tone sequence was obtained as below clear; clf; n=[0:1:1000]; n2=[0:1:1000]; x=cos(0.48*pi*n)+cos(0.52*pi*n); psd(x,1024,2,kaiser(128,pi),0,0.95); title(‘using function psd’); xlabel(‘frequency in pi units’);

using function psd

20

10

0

-10

-20

-30

-40

-50

-60

0 0.1

0.2

0.3

0.4

0.5

frequency in pi units

0.6

0.7

0.8

0.9

1 psd does the following:

It applies the specified anti-leakage window to successive detrended sections of x,

It transforms each section with an FFT using the size of the window for the FFT

It forms the periodogram of each section by obtaining the magnitude squared of each transform (by the way, the instruction used is Xx = abs(fft(xw,nfft)).^2;)

It averages the periodograms of the overlapping sections to form Pxx, the power spectral density estimation of x.

Experiment with different windows and window sizes and notice what happens with the frequency resolution and the variance (width of the confidence interval).

Download