Check out example codes for "power spectral density - matlab". It will help you in understanding the concepts better.

Code Example 1

N = length(x);
xdft = fft(x);
psdx = (1/(2*pi*N)) * abs(xdft).^2;
freq = 0:(2*pi)/N:2*pi-(2*pi)/N;

plot(freq/pi,10*log10(psdx))
grid on
title('Periodogram Using FFT')
xlabel('Normalized Frequency (\times\pi rad/sample)') 
ylabel('Power/Frequency (dB/rad/sample)')

Code Example 2

periodogram(x)

Learn ReactJs, React Native from akashmittal.com