Professional Documents
Culture Documents
Short-Time Fourier Transform
Short-Time Fourier Transform
An Introduction to
Short-Time Fourier Transform (STFT)
M Ahmadizadeh, PhD, PE
Contents
1
4/7/2014
Fourier Transform
Inverse DFT
DFT
2
4/7/2014
Fourier Transform
• Example: 5 Hz Signal
5 Hz
1
0.5
Signal
-0.5
-1
0 0.2 0.4 0.6 0.8 1
Time (s) Output
Amplitude 20
10
0
0 20 40 60 80 100
5
Phase
-5
0 20 40 60 80 100
Frequency (Hz) 5
Fourier Transform
• Example: 15 Hz Signal
15 Hz
1
0.5
Signal
-0.5
-1
0 0.2 0.4 0.6 0.8 1
Time (s) Output
20
Amplitude
10
0
0 20 40 60 80 100
10
Phase
0
0 20 40 60 80 100
Frequency (Hz) 6
3
4/7/2014
Fourier Transform
• Example: 30 Hz Signal
30 Hz
1
0.5
Signal
-0.5
-1
0 0.2 0.4 0.6 0.8 1
Time (s) Output
Amplitude 20
10
0
0 20 40 60 80 100
10
Phase
0
0 20 40 60 80 100
Frequency (Hz) 7
Fourier Transform
1
Signal
-1
-2
-3
0 0.2 0.4 0.6 0.8 1 Output
Time (s) 15
Amplitude
10
0
0 20 40 60 80 100
10
Phase
0
0 20 40 60 80 100
Frequency (Hz)
8
4
4/7/2014
times -1
-2
-3
0 0.2 0.4 0.6 0.8 1
Time (s)
0.5
Combination of 3 signals
Signal
-1
0 0.2 0.4 0.6 0.8 1
Time (s)
10
5
4/7/2014
0.5
Signal
-0.5
-1
0 0.2 0.4 0.6 0.8 1
Output
Time (s)
4
Amplitude
2
Excellent frequency 0
0 20 40 60 80 100
localization (shows all 50
existing frequencies), but 0
no time localization
Phase
-50
-100
0 20 40 60 80 100
Frequency (Hz)
11
12
6
4/7/2014
1
Acceleration
-1
Output
-2 3
Amplitude
-3 2
-4 1
0 5 10 15 20 25 30 35
Time 0
0 5 10 15 20 25 30
500
Phase
-500
0 5 10 15 20 25 30
Frequency (Hz) 13
1
Acceleration
-1 -3 El Centro - Components: 1
x 10
1
-2
-3
0.5
-4
0 5 10 15 20 25 30 35
Acceleration
Time
0
-1
0 5 10 15 20 25 30 35
Time
14
7
4/7/2014
1
Acceleration
-1 El Centro - Components: 10
0.15
-2
0.1
-3
0.05
-4
0 5 10 15 20 25 30 35
Acceleration
Time 0
-0.05
-0.15
-0.2
0 5 10 15 20 25 30 35
Time
15
1
Acceleration
-1 El Centro - Components: 50
1.5
-2
-3 1
-4 0.5
0 5 10 15 20 25 30 35
Acceleration
Time
0
-0.5
Included Signals: 50
-1
-1.5
0 5 10 15 20 25 30 35
Time
16
8
4/7/2014
1
Acceleration
-3 2
-4 1
0 5 10 15 20 25 30 35
Acceleration
Time
0
-1
Included Signals: 200
-2
-3
0 5 10 15 20 25 30 35
Time
17
1
Acceleration
Time 0
-1
-3
-4
0 5 10 15 20 25 30 35
Time
18
9
4/7/2014
• Basic Concept:
19
1
Acceleration
-1
-2
Output
4
-3
Amplitude
-4 2
0 0.5 1 1.5 2 2.5 3 3.5
Time
0
0 5 10 15 20 25 30
100
50
Phase
-50
0 5 10 15 20 25 30
Frequency (Hz)
20
10
4/7/2014
1
Acceleration
-1
-2 El Centro - Components: 10
3
-3
2
-4
0 0.5 1 1.5 2 2.5 3 3.5
Time 1
Acceleration
0
Included Signals: 10
-1
-2
-3
0 0.5 1 1.5 2 2.5 3 3.5
Time
21
1
Acceleration
-1
-2 El Centro - Components: 30
3
-3
2
-4
0 0.5 1 1.5 2 2.5 3 3.5
Time 1
Acceleration
0
Included Signals: 30
-1
-2
-3
0 0.5 1 1.5 2 2.5 3 3.5
Time
22
11
4/7/2014
1
Acceleration
-1
-2 El Centro - Components: 80
3
-3
2
-4
0 0.5 1 1.5 2 2.5 3 3.5 1
Time
Acceleration
0
Included Signals: 80 -1
-2
-3
-4
0 0.5 1 1.5 2 2.5 3 3.5
Time
23
Knowing the
location of the
0.5
considered chunk
in time and its
frequency
Signal
0 content, we can
get an idea of the
time each
-0.5 frequency exists.
-1
0 0.2 0.4 0.6 0.8 1
Time (s)
24
12
4/7/2014
0.5
Signal
-0.5
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time (s)
25
• Steps:
– Choose a window function of finite length
• A window function is a function that is multiplied by the signal to
keep a certain portion of it
13
4/7/2014
• Steps (continued)
– Compute the FT of the truncated signal, save results.
• For each time location where the window is centered, we
obtain a different FT
– Each FT provides the spectral information of a separate time-
slice of the signal, providing simultaneous time and frequency
information
27
0.6
0.2
Signal
Signal
Signal
0 0 0
-0.2
-0.6
-0.8 -1 -1
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Time (s) Time (s) Time (s)
0.6
0.4 0.5
0.2
Signal
Signal
0 0
-0.2
-0.4 -0.5
-0.6
-0.8 -1
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Time (s) Time (s)
0.3s 0.7 s
28
14
4/7/2014
Amplitude
Amplitude
1 1 1
0 0 0
0 20 40 60 80 100
0 20 40 60 80 100
0 20 40 60 80 100
0 2
Phase
Phase
Phase
10
-5 0
Output Output
-10 1 -2 1 0
0 20 40 60 80 0
100 20 40 60 80 100
0 20 40 60 80 100
Frequency (Hz) Frequency (Hz) Frequency (Hz)
Amplitude
Amplitude
0.5 0.5
0 0
0 20 40 60 80 100 0 20 40 60 80 100
0.3s 0.7 s
0 300
-100 200
Phase
Phase
-200 100 29
-300 0
0 20 40 60 80 100 0 20 40 60 80 100
Frequency (Hz) Frequency (Hz)
Frequency
30
15
4/7/2014
• Formulation:
– Continuous STFT
STFT x(t ) , X , x(t ) w t e
it
dt
• Formulation:
Time discretized, frequency continuous; but if
– Discrete STFT FFT is used, they both will be discrete.
STFT xn m, X m, xw
n
n nm e itn
32
16
4/7/2014
• Inverse STFT
– The original signal can be recovered from the transform
by the Inverse STFT. The most widely accepted way of
inverting the STFT is by using the overlap-add (OLA)
method, which also allows for modifications to the STFT
complex spectrum.
33
– Hence:
34
17
4/7/2014
35
– Or:
36
18
4/7/2014
38
19
4/7/2014
39
40
20
4/7/2014
X , x(t )e
it
dt X
1
t f
4
42
21
4/7/2014
43
• Example:
– Chirp Signal (linear frequency variation 10-200 Hz)
0.5
x(t)
-0.5
-1
44
22
4/7/2014
• Example (Continued):
– Chirp Signal – Ordinary Fourier Transform
Output
0.8
Amplitude 0.6
0.4
0.2
0
0 50 100 150 200 250
-100
-200
Phase
-300
-400
-500
0 50 100 150 200 250
Frequency (Hz)
45
• Example (Continued):
– Chirp Signal – Window Size: 128 points
Window size = 128 Window type = Hann Window size = 128 Window type = Hann
250
20 200
Frequency (Hz)
15
150
10
5 100
0
250
50
200 1
150 0.8
100 0.6
0.4
50 0.2 0
0 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Frequency (Hz) Time (sec) Time (sec)
46
23
4/7/2014
• Example (Continued):
– Chirp Signal – Window Size: 64 points
Window size = 64 Window type = Hann Window size = 64 Window type = Hann
250
20 200
Frequency (Hz)
15
150
10
5 100
0
250 50
200 1
150 0.8
100 0.6
0.4
50 0.2 0
0 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Frequency (Hz) Time (sec) Time (sec)
47
• Example (Continued):
– Chirp Signal – Window Size: 32 points
Window size = 32 Window type = Hann Window size = 32 Window type = Hann
250
20
200
15
Frequency (Hz)
150
10
5 100
0
250
50
200 1
150 0.8
100 0.6
0.4
50 0.2 0
0 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Frequency (Hz) Time (sec) Time (sec)
48
24
4/7/2014
• Use of MATLAB:
– The MATLAB command to perform STFT is spectrogram:
– Spectrogram inputs:
• x: input signal (signal to be transformed)
• window function (discrete window at the same input rate)
• window overlap (in terms of number of points)
• sampling points for FFT (number of points used in FFT)
• sampling frequency (rate of sampling for the input signal
and the window function)
• Applications:
50
25
4/7/2014
• Applications:
– Damage Detection Example:
• 2-Story structure, natural frequencies 2.2 and 5.8 Hz
• Response simulated to El Centro record
• Linear Response
5
x 10
0.04 2
Displacement, m
0.02 1
Force, N
0 0
-0.02 -1
-0.04 -2
0 10 20 30 40 -0.02 -0.01 0 0.01 0.02
Time, s Displacement, m
4
x 10
2.5 1
51
Number of Iterations
2 0.8
Energy, N-m
1.5 0.6
Internal
1 Input 0.4
0.5 0.2
0 0
0 10 20 30 40 0 10 20 30 40
Time, s Time, s
• Applications:
– Damage Detection Example:
• 2-Story structure, natural frequencies 2.2 and 5.8 Hz
• Response simulated to El Centro record
• Nonlinear Response (by defining a yield displacement)
5
x 10
0.04 2
Displacement, m
0.02 1
Force, N
0 0
-0.02 -1
-0.04 -2
0 10 20 30 40 -0.02 -0.01 0 0.01 0.02
Time, s Displacement, m
4
x 10
2.5 30
52
Number of Iterations
2
Energy, N-m
20
1.5
Internal
1 Input
10
0.5
0 0
0 10 20 30 40 0 10 20 30 40
Time, s Time, s
26
4/7/2014
• Applications:
– Damage Detection Example: Linear Response
0.02
0.01
x(t)
-0.01
-0.02
0 5 10 15 20 25 30 35
Time (sec)
0
0 5 10 15 20 25 30
Time (sec)
53
• Applications:
– Damage Detection Example: Nonlinear Response
0.02
0.01
x(t)
-0.01
-0.02
0 5 10 15 20 25 30 35
Time (sec)
0
0 5 10 15 20 25 30
Time (sec)
54
27