How do we interpret frequency from fft command in matlab? When I apply fft to a sampled function(@ Fs) and I get peaks at some values in the fft array. How do I know what frequency in Hertz does it correspond to?
The output of the fft function will go from 0 Hz to fs/2, then -fs/2 to almost 0. If you ignore the 2nd half (for purely real signals), the following works well:
For n samples at a sampling rate of fs, you can create a frequency axis, f with the following formula:
f = (0:n-1)/n*fs
This gives you freqs from fs/2 to almost fs, but if you overlook that...
The other option is to use the fftshift command on the fft output and revise the formula
f = (0:n-1)/n*fs-fs/2