Implementation Steps
1. FFT Computes the Frequency Content of a Signal
FFT converts a time-domain signal to the frequency domain. If:
- The signal is sampled at rate $f_s$
- You compute an $N_{\text{FFT}}$-point FFT
Then each FFT bin corresponds to a frequency resolution of:
$$\Delta f = \frac{f_s}{N_{\text{FFT}}}$$
So the FFT gives you accurate frequency content, assuming the signal is stationary and adequately sampled (Nyquist criterion met).
2. Magnitude Squared Gives Power (Not Amplitude)
$$P[k] = |X[k]|^2$$
This gives power at each frequency bin, not just amplitude. It represents how much energy is present at each frequency. It's a key step for PSD.
3. Normalization Makes the PSD Physically Meaningful
The equation:
$$\text{PSD}[k] = \frac{|X[k]|^2}{N_{\text{FFT}} \cdot f_s \cdot U}$$
is derived from first principles and ensures that the units of PSD are power per Hz. The components are:
- $N_{\text{FFT}}$: ensures proper scaling from discrete to continuous frequency
- $f_s$: converts to Hz
- $U$: accounts for power loss/gain due to the window
This formula ensures the area under the PSD equals the signal power (Parseval's theorem consistency).
4. One-Sided Correction for Real Signals
Because the FFT of a real-valued signal is symmetric, we can discard half the spectrum and double the power in positive frequency bins (except DC and Nyquist), which is standard and preserves total power.
MATLAB Code
Output