MATLAB Answers

# Questions on FFT and spectrogram

53 views (last 30 days)
crixus on 26 Sep 2016
Commented: Star Strider on 27 Sep 2016
I know that fft transform the time domain into frequency domain and my colleague told me that from the FFT output you can see whats the amplitude for of the signal happening once every certain frequency (not exactly sure what that means ... ). From the example I have seen, the results of fft is a straight vectical line but mine is a slanted vertical line, is it wrong ???
I have attached my signal data in matlab.mat and my example code in fft.txt, example code is from one of my tutorial
So few questions I would like to ask
• firstly, how to interpret the results of FFT and the spectrogram
• second, why must signal be multiplied by hanning window
• third, what is the purpose of excluding Nyquist point
• lastly, the purpose of the spectrogram
Sorry for appearing to be noobish/stupid/lazy but the truth is the more I read on FFT the more confused I got, so any kind soul who can help me out ?

#### 0 Comments

Sign in to comment.

### Accepted Answer

Star Strider on 26 Sep 2016
The Fourier transform (see the documentation in the R2015a version of fft (link) for a more understandable explanation) takes a time-domain signal as its input and converts it to a frequency-domain representation. If you have a frequency in your time-domain signal of 1 kHz for example, the Fourier transform of it will show that as a triangle with a narrow base centred at a frequency of 1 kHz. In a real-world sampled signal, the process of sampling introduces some nonlinearities, so the signal will never be a single vertical line, although in a pure signal it will be close. (The length of your original signal determines the minimum frequency resolution of the Fourier-transformed signal, and you can increase the frequency resolution by zero-padding your signal.)
To address your specific questions:
• firstly, how to interpret the results of FFT and the spectrogram
The frequencies of your original time-domain signal will appear as magnitudes at those frequencies in the Fourier-transformed signal. The spectrogram calculates short Fourier transforms on successive sections of your signal (not the entire signal), and presents them as the frequency content of your signal over that time interval. (That is the short explanation. There are many ways to overlap, add, and window the Fourier transform of the individual segments. I refer you to the documentation for a full description, and any comprehensive book on signal processing for a full discussion.)
• second, why must signal be multiplied by hanning window
It does not have to be, and I do not window the fft in my calculations, since I want to see the entire frequency content, although it is useful in the spectrogram function. The windows act as selective filters that minimise the effect of the sampling process (truncation of an infinite series), giving a smoother result. There is an advantage to using them, but it is not necessary to use them.
• third, what is the purpose of excluding Nyquist point
The Nyquist frequency is the highest uniquely-resolvable frequency in any sampled signal. There is no reason to represent any frequencies above it. (The reason is actually much more involved. Data acquisition hardware include hardware filters eliminating all frequencies above the Nyquist frequency from the analog-to-digital converter to avoid ‘aliasing’ that would result in frequencies above the Nyquist frequency from erroneously appearing in the sampled signal. I refer you to analogue and discrete signal processing textbooks for a full discussion.)
• lastly, the purpose of the spectrogram
It calculates the frequency content of the signal over a short time span and displays it as the frequency spectrum as a function of time. For signals with time-varying frequency content, it presents important information.
NOTE This is a very short discussion of a very detailed topic. Please take the time to read a good signal processing textbook — and preferably take courses in analog and discrete signal processing — to understand them in necessary detail.

#### 2 Comments

crixus on 27 Sep 2016
Hi Star Strider thanks for your time is explaining the details in a short discussion. If you were to recommend a textbook on signal processing, which one would be a good read ?
Star Strider on 27 Sep 2016
As always, my pleasure.
I recommend two:
• Proakis JG and Manolakis DG. Digital Signal Processing: Principles, Algorithms, and Applications 4th Edition (2007) ISBN 0-13-187374-1 (There might be a later edition)
• Weeks M. Digital Signal Processing Using MATLAB® and Wavelets (2011) ISBN 978-0-7637-8422-5
Depending on what you want to do, others may also be appropriate. These are the books I usually refer to. Proakis is pretty much the universal reference for discrete signal processing.

Sign in to comment.