问题
I have a piece of code that gets the FFT of a part of the signal and I'm 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))))))
From my understanding, in order to get the PSD I just need to raise sf
to the power of 2, or is there anything more I need to perform?
回答1:
Technically yes, you can obtain the power-spectral density (PSD) of a periodic signal by taking the squared-magnitude of its FFT. Note that if you are going to plot it on a logarithmic decibel scale, there is really no difference between 20*log10(abs(sf))
or 10*log10(abs(sf).^2)
.
There is however generally more to it in the sense that the PSD estimate computed in this way tends to have a fairly large variance. There are a number of techniques which can be used to improve the estimate. A simple one consists of applying a window to sections of data, perform the FFT, then averaging the resulting PSDs (i.e. averaging the squared-magnitudes).
回答2:
You are perfectly right. You just have to built the square of the absolute values.
来源:https://stackoverflow.com/questions/24984008/power-spectral-density-of-fft