Challenge - 5 Problems
Spectrogram Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of Basic Spectrogram Command
What will be the output of the following MATLAB code snippet that computes and plots a spectrogram of a sine wave?
MATLAB
fs = 1000; % Sampling frequency t = 0:1/fs:1-1/fs; x = sin(2*pi*100*t); spectrogram(x,128,120,128,fs,'yaxis');
Attempts:
2 left
💡 Hint
Think about the frequency content of a pure sine wave and how it appears in a spectrogram.
✗ Incorrect
The sine wave has a single frequency at 100 Hz, so the spectrogram shows a bright horizontal line at that frequency. The window and overlap parameters are valid, so no error occurs.
🧠 Conceptual
intermediateUnderstanding Window and Overlap Parameters
In MATLAB's spectrogram function, what is the effect of increasing the overlap parameter between windows?
Attempts:
2 left
💡 Hint
Consider how overlapping windows affect the smoothness of the time axis in the spectrogram.
✗ Incorrect
Increasing overlap means more windows are computed closer in time, improving time resolution (more detail in time) without changing the frequency resolution, which depends on window length.
🔧 Debug
advancedIdentify the Error in Spectrogram Computation
What error will the following MATLAB code produce when executed?
MATLAB
fs = 500; t = 0:1/fs:2-1/fs; x = chirp(t,0,2,fs/2); spectrogram(x,64,70,64,fs);
Attempts:
2 left
💡 Hint
Check the relationship between window length and overlap parameters.
✗ Incorrect
The overlap parameter (70) cannot be larger than the window length (64). MATLAB throws an error for this invalid input.
❓ Predict Output
advancedSpectrogram Output for Multi-Tone Signal
What will the spectrogram display when running this MATLAB code?
MATLAB
fs = 1000; t = 0:1/fs:1-1/fs; x = sin(2*pi*50*t) + sin(2*pi*150*t); spectrogram(x,256,200,256,fs,'yaxis');
Attempts:
2 left
💡 Hint
The signal is a sum of two sine waves at fixed frequencies.
✗ Incorrect
The spectrogram shows two distinct horizontal lines at the frequencies of the two sine waves: 50 Hz and 150 Hz.
🧠 Conceptual
expertEffect of Window Length on Frequency Resolution
Which statement correctly describes the effect of increasing the window length in MATLAB's spectrogram function?
Attempts:
2 left
💡 Hint
Think about how longer windows capture more cycles of a frequency but blur time details.
✗ Incorrect
Longer windows capture more signal cycles, improving frequency resolution, but they average over longer time intervals, reducing time resolution.
