MATLAB: Power spectral density of fft

audiofftsignal processing

hello guys, i have a piece of code that gets the fft of a part of the signal and i am now trying to get the PSD.
Fs = 44100; cj = sqrt(-1); %T=.6; dt = 1/Fs; left=test(:,1); right=test(:,2); time = 45; interval =.636; w_range = time*Fs: (time+interval)*Fs-1; I = left(w_range); Q = right(w_range); n = interval * Fs; f = -Fs/2:Fs/n:Fs/2-Fs/n;
s = I+cj.*Q;
% Smooth the signal ss = smooth(s,201);
sf = (fftshift(fft(ss(1:n)))); %FFT of signal
figure(1) plot(f,((20*log10((abs(sf))./max(abs(sf))))))
so now i was wondering from my understanding in order to get the PSD i just need to raise sf to the power of two or is there more things i need to perform?
Thanks in advance

Best Answer

well, in some sense, you can never really "get" the PSD of anything. you can only estimate it. And yes, the fft magnitude squared is an estimator of the PSD. This is referred to as the periodogram. However, it is not a very good estimator. A better estimator would be to use the pwelch() function. I some tutorial on PSD here http://www.mechanicalvibration.com/Introduction_power_spectral.html that may help you.