How to correctly plot the PSD of segments of a signal?

11 views (last 30 days)
I have a signal r of length S samples of baseband bandwidth W Hz. This represents the received signal in a communication system. The sampling rate is fs and carrier frequency is fc. I want to monitor the two-sided power spectral density (PSD) of r in segements each of length U samples, where I prefer to calculate the PSD from fft directly instead of a built in function, but having an additional appraoch using a built-in function may be helpful. The way I do it now for the first segment for example is like so
r1 = r(1:U);
[psd,f]=pwelch(r1);
plot(f, 10*log10(psd));
From the documentaion it seems that I used pwelch incorrectly or not the way I wanted it, because the above syntax returns the normalized frequency as x-axis.
The one I think I need is the following
[pxx,f] = pwelch(x,window,noverlap,f,fs)
But I am not sure what I should use for windows, nooverlap, and f. I also want to calculate a similar result using fft directly on the segments. I do it as so
psd1 = abs(fft(r1)).^2/(fs*S);
where I know I need to normalize the power of the fft of the segment, but not sure how exactly.
How can I use these both methods (or any other built-in method other than pwelch) correctly in MATLAB?

Answers (1)

Chunru
Chunru on 16 Sep 2022
% r1 = r(1:U);
U = 8192;
r1 = randn(U, 1) + 1i*randn(U,1); % complex baseband signal
fs = 10000;
fc = 2000;
nfft = 1024;
[pxx,f] = pwelch(r1,nfft, nfft*3/4, 1024, fs);
% win, overlap, nfft, fs
plot(f, 10*log10(pxx));
xline(fc)

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!