0
0
Signal Processingdata~10 mins

Short-Time Fourier Transform (STFT) in Signal Processing - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the function used for STFT from the scipy library.

Signal Processing
from scipy.signal import [1]
Drag options to blanks, or click blank then click option'
Astft
Bspectrogram
Cifft
Dfft
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'fft' instead of 'stft'.
Using 'spectrogram' which is related but different.
2fill in blank
medium

Complete the code to compute the STFT of signal 'x' with a window size of 256 samples.

Signal Processing
f, t, Zxx = stft(x, nperseg=[1])
Drag options to blanks, or click blank then click option'
A256
B512
C128
D1024
Attempts:
3 left
💡 Hint
Common Mistakes
Using too small or too large window size causing poor resolution.
Confusing nperseg with other parameters.
3fill in blank
hard

Fix the error in the code to correctly compute the STFT with a sampling frequency of 1000 Hz.

Signal Processing
f, t, Zxx = stft(x, fs=[1])
Drag options to blanks, or click blank then click option'
A50
B1000
C500
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect sampling frequency causing wrong frequency axis.
Confusing fs with window size.
4fill in blank
hard

Fill both blanks to compute the STFT with a Hann window and 50% overlap.

Signal Processing
f, t, Zxx = stft(x, window=[1], noverlap=[2])
Drag options to blanks, or click blank then click option'
A'hann'
B128
C256
D'hamming'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'hamming' instead of 'hann' window.
Setting overlap equal to window size or zero.
5fill in blank
hard

Fill all three blanks to create a dictionary with frequencies as keys (rounded) and maximum magnitude of STFT for each frequency.

Signal Processing
max_magnitude = [1]([2][i].round().astype(int): abs(Zxx[i]).max() for i, [3] in enumerate(f))
Drag options to blanks, or click blank then click option'
Adict
Bf
Cfreq
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using list instead of dict.
Using wrong variable names causing errors.