Challenge - 5 Problems
FFT Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of FFT Magnitude Calculation
What is the output of the following MATLAB code snippet that computes the magnitude of the FFT of a simple signal?
MATLAB
Fs = 8; % Sampling frequency T = 1/Fs; % Sampling period L = 8; % Length of signal t = (0:L-1)*T; % Time vector x = cos(2*pi*1*t) + 0.5*cos(2*pi*3*t); Y = fft(x); P2 = abs(Y/L); P1 = P2(1:L/2+1); P1(2:end-1) = 2*P1(2:end-1); disp(P1);
Attempts:
2 left
💡 Hint
Remember the FFT output is symmetric and the magnitude is scaled by the length of the signal.
✗ Incorrect
The signal is a sum of two cosines at 1 Hz and 3 Hz. The FFT magnitude shows peaks at these frequencies. The scaling and doubling of the single-sided spectrum values except the first and last elements produce the output [0 1 0 0.5 0].
🧠 Conceptual
intermediateFrequency Resolution in FFT
If you have a signal sampled at 1000 Hz and you take an FFT of length 500, what is the frequency resolution of the FFT?
Attempts:
2 left
💡 Hint
Frequency resolution is sampling frequency divided by FFT length.
✗ Incorrect
Frequency resolution = Fs / N = 1000 / 500 = 2 Hz. This means each FFT bin represents a 2 Hz frequency band.
🔧 Debug
advancedIdentify the Error in FFT Frequency Vector Calculation
What error does the following MATLAB code produce when trying to create a frequency vector for an FFT of length N sampled at Fs?
MATLAB
N = 16; Fs = 100; f = (0:N-1)*(Fs/N); disp(f);
Attempts:
2 left
💡 Hint
Consider the meaning of Nyquist frequency and how frequency vectors are usually constructed for FFT plots.
✗ Incorrect
The frequency vector goes from 0 to Fs*(N-1)/N, which exceeds the Nyquist frequency (Fs/2). For plotting single-sided FFT, frequencies should be limited to 0 to Fs/2.
📝 Syntax
advancedSyntax Error in FFT Magnitude Plotting
Which option contains the correct syntax to plot the single-sided amplitude spectrum of a signal x sampled at Fs using FFT in MATLAB?
MATLAB
x = sin(2*pi*50*t) + sin(2*pi*120*t); Fs = 1000; L = length(x); Y = fft(x); P2 = abs(Y/L); P1 = P2(1:L/2+1); P1(2:end-1) = 2*P1(2:end-1); f = Fs*(0:(L/2))/L;
Attempts:
2 left
💡 Hint
Check that the plotted vector matches the frequency vector and labels are clear.
✗ Incorrect
Option C correctly plots the single-sided amplitude spectrum P1 against frequency vector f with proper axis labels including units.
🚀 Application
expertDetermine the Number of Frequency Components
Given a real-valued signal sampled at 2000 Hz with length 1024, after computing the FFT and taking the single-sided spectrum, how many unique frequency components are present in the single-sided amplitude spectrum?
Attempts:
2 left
💡 Hint
For real signals, the single-sided spectrum length is N/2 + 1.
✗ Incorrect
The single-sided spectrum includes the DC component and Nyquist frequency, so it has N/2 + 1 = 1024/2 + 1 = 513 components.
