0
0
Signal Processingdata~10 mins

Spectrogram visualization 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 library needed for plotting the spectrogram.

Signal Processing
import matplotlib.pyplot as [1]
Drag options to blanks, or click blank then click option'
Amatplot
Bmp
Cplt
Dplotlib
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect or uncommon aliases like 'mp' or 'matplot'.
Forgetting to import matplotlib.pyplot before plotting.
2fill in blank
medium

Complete the code to generate a spectrogram from the signal array using matplotlib.

Signal Processing
frequencies, times, Sxx = plt.specgram(signal, NFFT=[1], Fs=fs)
Drag options to blanks, or click blank then click option'
A128
B256
C1024
D512
Attempts:
3 left
💡 Hint
Common Mistakes
Using too small NFFT values like 128 which reduce frequency resolution.
Using values not a power of two which may cause errors.
3fill in blank
hard

Fix the error in the code to correctly label the x-axis as 'Time [sec]'.

Signal Processing
plt.xlabel([1])
Drag options to blanks, or click blank then click option'
A'Time [sec]'
BTime [sec]
C'Time (seconds)'
DTime_sec
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the label string.
Using parentheses instead of square brackets for units.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each frequency to its power value if power is above 0.1.

Signal Processing
freq_power = {freq: power[1] for freq, power in zip(frequencies, map(max, Sxx)) if power [2] 0.1}
Drag options to blanks, or click blank then click option'
A**2
B>
C>=
D*2
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication instead of exponentiation for squaring.
Using >= instead of > which changes the filter condition.
5fill in blank
hard

Fill all three blanks to create a filtered dictionary of frequencies and powers where power is above 0.05, and keys are rounded frequencies.

Signal Processing
filtered = { [1]: [2] for freq, power in freq_power.items() if power [3] 0.05}
Drag options to blanks, or click blank then click option'
Around(freq)
Bpower
C>
Dfreq
Attempts:
3 left
💡 Hint
Common Mistakes
Not rounding the frequency keys.
Using <= or < instead of > for filtering.