Time Series Data, FFT, and Spectrograms: A Comprehensive Guide
This guide delves into the fundamentals of signal analysis, starting with raw time series data and
moving through the powerful transformations of FFT and spectrograms. We will explore how
these tools work together to reveal hidden patterns in signals, illustrating each concept with the
outputs generated by the provided MATLAB code.
1. Time Series Data: The Raw Signal View
At its core, time series data is simply a sequence of data points recorded at successive, equally
spaced points in time. Imagine recording the air pressure changes as a sound wave passes you –
that's a time series!
In the context of our MATLAB code, we're generating a chirp signal. A chirp is a special kind of
sound where its frequency (how high or low the pitch is) continuously changes over time. In our
code, the frequency increases linearly from 10 Hz to 200 Hz over 2 seconds.
The first plot generated by your MATLAB code is the Time Series Data of a Chirp Signal.
Figure 1: Time Series Plot of a Chirp Signal. This graph displays the amplitude of the chirp signal over time,
showing increasing oscillation frequency.
• X-axis (Time): Shows how the signal evolves chronologically. You can see the total
duration (2 seconds) and individual moments.
• Y-axis (Amplitude): Represents the intensity or strength of the signal at each given time.
For sound, this relates to how "loud" it is.
Looking at the plot, you would observe that the signal's oscillations (waves) start relatively slow
and wide apart, then gradually become much faster and closer together, visually representing the
increasing frequency.
2. Fast Fourier Transform (FFT): Unveiling Frequencies
While a time series shows us when a signal's amplitude changes, it doesn't directly tell us what
specific frequencies (pitches) are present within that signal. That's where the Fast Fourier
Transform (FFT) comes in.
The FFT is an incredibly efficient algorithm that takes a signal from the time domain (amplitude
versus time) and transforms it into the frequency domain (amplitude versus frequency). It
deconstructs the signal into its fundamental sine and cosine waves, telling us the strength of each
frequency component that makes up the entire signal.
The second plot from your MATLAB code is the Single-Sided Amplitude Spectrum of a Chirp
Signal (FFT).
Figure 2: Single-Sided Amplitude Spectrum (FFT) of a Chirp Signal. This plot shows the distribution of frequencies
present in the entire signal.
• X-axis (Frequency): Shows the different frequencies (in Hertz) present in the signal.
• Y-axis (Amplitude): Indicates how strong or prominent each frequency component is.
For our chirp signal, which sweeps through a range of frequencies (from 10 Hz to 200 Hz), the
FFT plot shows activity across that entire frequency range. Instead of a single sharp peak (which
you'd see for a pure tone), you'll observe a broad band of energy, indicating that many frequencies
between 10 Hz and 200 Hz are present throughout the signal's duration. This plot gives us an
overall "recipe" of frequencies for the entire 2-second signal.
3. Spectrograms: The Dynamic View of Frequencies Over Time
Both the time series and FFT plots provide valuable information, but they each offer only one
piece of the puzzle. The time series tells you about temporal changes, and the FFT tells you about
overall frequency content. But what if you want to know how the frequencies change over time? That's
precisely what a spectrogram reveals.
A spectrogram is a visual representation of how the frequency content of a signal evolves through
its duration. It's often called a time-frequency plot because it combines both dimensions into a
single, rich visualization.
How a Spectrogram is Derived (Short-Time Fourier Transform - STFT)
The magic behind a spectrogram is the Short-Time Fourier Transform (STFT). Instead of
taking one FFT of the entire signal, the STFT works by:
1. Segmenting (Windowing): The original time series signal is divided into many small,
overlapping segments or "frames." Each segment is multiplied by a "window function"
(like the Hamming window used in the code) to smoothly taper its ends, which helps to
reduce unwanted spectral artifacts.
2. FFT on Each Segment: An FFT is performed on each of these short segments. Each
FFT provides the frequency content for that specific short period of time.
3. Stacking and Visualization: The results of all these individual FFTs are then arranged
side-by-side. This forms a 2D map, where:
o The horizontal (X) axis represents time.
o The vertical (Y) axis represents frequency.
o The color intensity at any point (x,y) indicates the amplitude (or power) of that
particular frequency at that particular time. Typically, brighter or "hotter" colors
(e.g., yellow/red) signify higher amplitudes, while cooler colors (e.g., blue/dark
green) indicate lower amplitudes. A color bar usually accompanies the spectrogram
to show the mapping from color to amplitude (often in decibels, dB).
The Time-Frequency Resolution Trade-off
One of the most critical concepts in spectrogram analysis is the time-frequency resolution trade-
off. When you choose the parameters for your spectrogram (specifically the window_size and
overlap), you're deciding how much detail you want to see in time versus how much detail you want
to see in frequency:
• Larger Window Size:
o Better Frequency Resolution: A longer segment provides more data points for
each FFT, resulting in more precise frequency bins. This means you can distinguish
between very closely spaced frequencies more accurately.
o Worse Time Resolution: A longer window averages the frequency content over
a longer period. This "smears" events in time, making it harder to pinpoint the
exact moment a frequency change occurs.
• Smaller Window Size:
o Better Time Resolution: A shorter segment focuses on a very brief moment,
allowing you to see rapid changes in frequency content and pinpoint when events
happen more precisely.
o Worse Frequency Resolution: Fewer data points in the window lead to wider,
less precise frequency bins. It becomes harder to differentiate between closely
spaced frequencies.
• Overlap:
o Overlap ensures that information isn't lost at the boundaries between segments
and helps to create a smoother, more continuous visual representation of the
spectrogram. A 50% overlap (half the window size) is a common and effective
choice.
4. Analyzing Spectrograms with Varying Parameters
Your MATLAB code generates four different spectrograms, allowing us to directly observe this
time-frequency resolution trade-off and the effect of overlap. For our chirp signal, which linearly
increases in frequency, you'd expect to see a diagonal line on the spectrogram.
Spectrogram 1: Window Size 256, No Overlap
Figure 3: Spectrogram with Window Size 256, No Overlap. This shows good frequency resolution but can appear
blocky in the time domain due to lack of overlap.
• Parameters: window_size = 256, overlap = 0
• Characteristics: With a window size of 256, you get a decent frequency resolution,
meaning the diagonal line of the chirp will be reasonably thin in the frequency direction.
However, because there is no overlap, you might notice some "blockiness" or discontinuity
in the time direction. The spectrogram might appear as a series of distinct vertical strips
rather than a smooth diagonal line, as each segment is processed in isolation.
Spectrogram 2: Window Size 256, 128 Overlap (50%)
Figure 4: Spectrogram with Window Size 256, 128 Overlap. Shows improved temporal smoothness compared to
Figure 3 while maintaining frequency resolution.
• Parameters: window_size = 256, overlap = 128
• Characteristics: This configuration uses the same window size as Spectrogram 1,
maintaining the same frequency resolution (the line's vertical thickness). The crucial
difference is the 50% overlap. This overlap significantly improves the temporal
smoothness of the spectrogram. The diagonal line representing the chirp will appear
much more continuous and visually pleasing, as the analysis windows are seamlessly
blending. This is often a preferred setting for general-purpose spectrograms.
Spectrogram 3: Window Size 128, No Overlap
Figure 5: Spectrogram with Window Size 128, No Overlap. Displays better time resolution but reduced
frequency resolution (thicker line) and still exhibits blockiness.
• Parameters: window_size = 128, overlap = 0
• Characteristics: With a smaller window size of 128, you're prioritizing time resolution.
This means if there were very short, sudden frequency changes, you'd see them more
clearly. However, this comes at the cost of frequency resolution – the diagonal line of
the chirp will appear thicker or more "smeared" vertically, as the frequency bins are wider.
Again, the no overlap setting will contribute to a blocky appearance in time.
Spectrogram 4: Window Size 128, 64 Overlap (50%)
Figure 6: Spectrogram with Window Size 128, 64 Overlap. Offers a smooth temporal view with enhanced time
resolution, albeit with reduced frequency precision.
• Parameters: window_size = 128, overlap = 64
• Characteristics: Similar to Spectrogram 3, this uses the smaller window size (128) but
includes a 50% overlap. Compared to Spectrogram 3, this will show a smoother
representation in the time domain, making the diagonal line of the chirp look much more
continuous and less blocky, even with the reduced frequency precision. This is a good
setting if you need to precisely locate events in time.
5. Uses of Spectrograms
Spectrograms are invaluable tools across many fields because they provide such a clear, intuitive
view of a signal's dynamic frequency content:
• Audio Analysis: Analyzing speech (identifying phonemes, speaker recognition), music
(instrument identification, melody extraction), and animal vocalizations (bird calls, whale
songs).
• Bioacoustics: Studying animal communication and environmental soundscapes.
• Seismology: Analyzing earthquake signals.
• Medical Imaging: Interpreting ultrasound and Doppler signals.
• Radar and Sonar: Detecting objects and analyzing their movement.
• Machine Diagnostics: Identifying anomalies in machinery by analyzing vibrational
patterns.
• Telecommunications: Analyzing modulated signals.
Conclusion
Time series data, Fast Fourier Transform, and spectrograms form the bedrock of digital signal
processing. While time series provides a raw, temporal view, and FFT offers a static frequency
breakdown, the spectrogram stands out as a dynamic visualizer, showing how frequencies evolve.
By understanding the underlying STFT process and the critical time-frequency resolution trade-
off, you can effectively use spectrograms to gain deep insights into the behavior of complex signals.
The different plots generated by the MATLAB code demonstrate that choosing appropriate
windowing parameters is crucial for revealing the specific details needed for your analysis.