Hi Louise,
As per my understanding, you are facing an issue while implementing the single-sided PSD.
The “pwelch” function takes in the following arguments:
pxx = pwelch(x,window,noverlap,nfft)
Assume the default Fs to be 1Hz unless specified specifically by:
[pxx,f] = pwelch(___,fs)
You will be able to replicate the results you have obtained through the second method that you have used by modifying the 14th line of your code as follows:
pxx=pwelch(xbit,N,[],N,Fs);
For more information on “pwelch” function please refer to the documentation provided below.
https://in.mathworks.com/help/signal/ref/pwelch.html