To use the Welch method with FFT in MATLAB, you can use the 'pwelch' function. Here is an example code:
main.m618 chars19 lines
The 'pwelch' function returns the power spectral density estimate, Pxx, as a function of frequency, f. The inputs to the function are the signal, x, the window function, window, the number of samples to use for each FFT, nfft, the amount of overlap between consecutive window segments, noverlap, and the sampling frequency, fs. The above example uses a Hann window with 50% overlap and the FFT size of the next power of 2 from the length of the input signal.
Once you have computed the power spectral density estimate, you can plot it using the 'plot' function. In the above example, the plot shows the estimated PSD of a sine wave with added noise. The x-axis shows the frequency in Hz and the y-axis shows the power/frequency in dB/Hz.
gistlibby LogSnag