Sinusoid amplitude loss in power spectrum estimation using Pwelch method I am trying to estimate the amplitude or power spectrum of a sinusoidal signal using Pwelch method. The following is the matlab code I use.

rng default 
fs = 1000; 
t = 0:1/fs:5-1/fs; 
x = cos(2*pi*100*t) + 0*randn(size(t)); 
[pxx,f] = pwelch(x,fs,0,fs,fs,'onesided'); plot(f,10*log10(pxx))


And it gives the following result


By default, a Hamming window of length $f_s$ is used in the pwelch function. Since the frequency resolution is 1 Hz, the frequency of the sinusoid lies exactly in one of the discrete frequency bins of the FFT and no scalloping loss is involved.
The question I have is that why the amplitude or power of the peak is -4.357dB instead of -3dB. I tried other windows with the same length. The rectangular window gives a peak of exactly -3 dB and the Hanning window, -4.78 dB. The power loss maybe related to the type of windows, I guess. But I cannot figure out why.

Can anyone explain this? 

Thank you in advance.
I think your difficulty lies in having an overlap size of 0.

I'd recommend having an overlap that gives a Constant Overlap Add result when the windows are laid on top of each other.

For a rectangular window that is 0.
Hann it is 50% blocksize
Hamming seems to have many, but try 75%

Overlap values for different Windows

And don't forget that the PSD 'bin' represents all the content within that delta-f.  For example, if you had a signal at 100 Hz and 100.25 Hz, the 1 Hz delta-f wouldn't resolve them to 2 spikes .

RMS from a bin is sqrt(Area of bin).