Digital Signal Processing Reference
In-Depth Information
new location of the window is given by ( N w
1) k (2 N w N o
2) for the second iteration, which is used to compute the periodogram for the
second duration. The process is repeated until the entire signal is parsed and
the average value of the periodogram is selected as the estimate of the power
spectrum. This method, based on averaging the values of the power spectrum
obtained from different periodograms, is referred to as the Welch estimate of the
periodogram.
In the signal processing toolbox of M ATLAB , the built-in function psd
estimates the power spectrum of a signal using the periodogram approach. The
following example illustrates the use of the psd function.
N o
Example 17.3
Estimate the power spectral density of the following signal:
x [ k ] = 3 cos(0 . 2 π k ) + 2 cos(0 . 3 π k ) + r [ k ] ,
(17.14)
where r [ k ] is a white noise with Gaussian distribution with a variance of 4.
Solution
Note that the signal x [ k ] includes a deterministic component consisting of
the two sinusoids and a random component. The following code generates a
realization of x [ k ] and estimates the power spectrum:
>> k = [0:6000];
>> x = 3*cos(0.2*pi*k) + 2*cos(0.4*pi*k) +
2*randn(size(k));
>>Fs=2;nwind = length(x);
>> nfft = length(x); noverlap=0;
>> [PxxNoAvg, F] = psd(x, nfft, Fs, rectwin(nwind),
>> noverlap); Fs = 2; nwind=301;
>> nfft = 512; noverlap = floor(4*nwind/5) ;
>> [PxxWelch, F] = psd(x, nfft, Fs,
hanning(nwind),noverlap);
The random component r [ k ] is generated using the M ATLAB function randn .
As the variance of the random component is 4, we multiply randn by the
standard deviation, which equals 2. Figure 17.3 shows the first 201 samples of
an example of x [ k ]. Over different simulations, the signal x [ k ] may have slight
variations due to the presence of the random component.
The M ATLAB code computes the power spectrum in two ways. The first
estimate PxxNoAvg represents the power spectrum obtained by calculating
the DFT of the entire signal. Note that there is no averaging in this case. The
second estimate, PxxWelch , represents the power spectrum obtained by the
Welch method, where the signal is parsed into shorter sequences with a Hanning
Search WWH ::




Custom Search