MATLAB: Do results differ between pwelch and dsp.SpectrumEstimator

DSP System Toolboxpwelchspectrumestimatorwelch

Why does the results differ when I obtain the welch spectrum using function pwelch and dsp.SpectrumEstimator object using a window?
 

Best Answer

The 'window' property in 'pwelch' function specifies the length of segments which the signal gets divided into. Power spectrum is then calculated by taking the spectral averages of these segments. 
The 'dsp.SpectrumEstimator' object has a property 'Spectral Averages' which determines the number of spectral averages to be taken for the segmented signal. However, the object itself does not divide the signal into segments. Although, the underlying implementation of this object is through Welch Spectrum Estimate algorithm which requires the signal to be segmented, we have to manually implement the segmentation part of the signal and step these segments through the object.  
Please refer to the attached script which shows an example of correct usage of 'dsp.SpectrumEstimator' for computing the Welch Spectrum of a sinusoid signal. Please note, the parameters such as sampling frequency, length of fft, etc. are defined in the script.