0
0
Signal Processingdata~10 mins

Spectral leakage concept 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 create a simple sine wave signal.

Signal Processing
import numpy as np
fs = 1000  # Sampling frequency
f = 5     # Frequency of the sine wave
t = np.arange(0, 1, 1/fs)
signal = np.sin(2 * np.pi * [1] * t)
Drag options to blanks, or click blank then click option'
Afs
Bf
Ct
Dnp.pi
Attempts:
3 left
💡 Hint
Common Mistakes
Using sampling frequency fs instead of signal frequency f.
2fill in blank
medium

Complete the code to compute the FFT of the signal.

Signal Processing
from numpy.fft import fft
N = len(signal)
fft_values = fft([1])
Drag options to blanks, or click blank then click option'
At
BN
Csignal
Dfs
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the time vector t instead of the signal.
3fill in blank
hard

Fix the error in the code to correctly compute the frequency bins for the FFT.

Signal Processing
freqs = np.fft.fftfreq([1], d=1/fs)
Drag options to blanks, or click blank then click option'
AN
Bfs
Csignal
Dt
Attempts:
3 left
💡 Hint
Common Mistakes
Passing sampling frequency fs instead of number of samples N.
4fill in blank
hard

Fill both blanks to create a windowed signal and compute its FFT.

Signal Processing
window = np.[1](N)
windowed_signal = signal * window
fft_windowed = np.fft.[2](windowed_signal)
Drag options to blanks, or click blank then click option'
Ahanning
Bhamming
Cfft
Difft
Attempts:
3 left
💡 Hint
Common Mistakes
Using ifft instead of fft.
Using hanning when the question expects hamming.
5fill in blank
hard

Fill both blanks to create a dictionary of frequency magnitudes above a threshold.

Signal Processing
threshold = 10
freq_magnitudes = {freq: abs(fft_windowed[i]) [1] threshold for i, freq in enumerate(freqs) if freq >= 0 and abs(fft_windowed[i]) [2] threshold}
Drag options to blanks, or click blank then click option'
A:
B>
C>=
D,
Attempts:
3 left
💡 Hint
Common Mistakes
Using comma , instead of colon : in dictionary comprehension.
Using >= instead of > inconsistently.