0
0
Signal Processingdata~10 mins

Rectangular window limitations 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 rectangular window of length 50 using NumPy.

Signal Processing
import numpy as np
window = np.[1](50)
Drag options to blanks, or click blank then click option'
Ablackman
Bhanning
Cones
Dhamming
Attempts:
3 left
💡 Hint
Common Mistakes
Using other window functions like hamming or hanning instead of ones.
Confusing the window length with the window type.
2fill in blank
medium

Complete the code to compute the Fourier Transform of the rectangular window using NumPy's FFT.

Signal Processing
import numpy as np
window = np.ones(50)
fft_window = np.fft.[1](window)
Drag options to blanks, or click blank then click option'
Afft
Bfftshift
Crfft
Difft
Attempts:
3 left
💡 Hint
Common Mistakes
Using inverse FFT instead of FFT.
Using FFT shift which only rearranges the FFT output.
3fill in blank
hard

Fix the error in the code to plot the magnitude of the FFT of the rectangular window using matplotlib.

Signal Processing
import numpy as np
import matplotlib.pyplot as plt
window = np.ones(50)
fft_window = np.fft.fft(window)
plt.plot(np.abs(fft_window[1]))
plt.title('Magnitude of FFT of Rectangular Window')
plt.show()
Drag options to blanks, or click blank then click option'
A[:25]
B[0:25]
C[0:50]
D[:50]
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect slice notation like [0:25] which is valid but less common.
Trying to slice with [0:50] which is the full length and unnecessary.
4fill in blank
hard

Fill in the blank to create a dictionary of window lengths and their main lobe widths, assuming main lobe width is 2 divided by window length.

Signal Processing
window_lengths = [20, 40, 80]
main_lobe_widths = {length: 2 [1] length for length in window_lengths}
Drag options to blanks, or click blank then click option'
A+
B/
C*
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication instead of division for main lobe width.
Not iterating over the list correctly.
5fill in blank
hard

Fill all three blanks to create a plot comparing the rectangular window and its FFT magnitude normalized by the maximum value.

Signal Processing
import numpy as np
import matplotlib.pyplot as plt
N = 50
window = np.ones(N)
fft_window = np.fft.fft(window)
fft_magnitude = np.abs(fft_window) / np.[1](np.abs(fft_window))
plt.plot(window, label='Rectangular Window')
plt.plot(fft_magnitude[:N//2], label='Normalized FFT Magnitude')
plt.[2]('Window Samples')
plt.[3]('Amplitude')
plt.legend()
plt.show()
Drag options to blanks, or click blank then click option'
Amin
Bxlabel
Cylabel
Dmax
Attempts:
3 left
💡 Hint
Common Mistakes
Using min instead of max for normalization.
Mixing up xlabel and ylabel functions.