Why is frequency analysis important in signal processing?
Think about what frequency analysis reveals about a signal.
Frequency analysis breaks down a signal into its frequency parts, showing what frequencies are present and their strengths.
What is the output when applying Fourier Transform to a pure 5 Hz sine wave sampled at 100 Hz?
import numpy as np import matplotlib.pyplot as plt fs = 100 # Sampling frequency f = 5 # Frequency of sine wave t = np.arange(0, 1, 1/fs) signal = np.sin(2 * np.pi * f * t) fft_result = np.fft.fft(signal) frequencies = np.fft.fftfreq(len(signal), 1/fs) magnitude = np.abs(fft_result) peak_freq = frequencies[np.argmax(magnitude)] print(round(peak_freq, 1))
Look for the frequency with the highest magnitude in the FFT output.
The Fourier Transform of a 5 Hz sine wave shows a peak at 5 Hz, which is the frequency of the sine wave.
Given a frequency spectrum plot of a signal, which frequency component has the highest amplitude?
import numpy as np import matplotlib.pyplot as plt fs = 200 f1, f2 = 20, 50 t = np.arange(0, 1, 1/fs) signal = 0.6 * np.sin(2 * np.pi * f1 * t) + 1.2 * np.sin(2 * np.pi * f2 * t) fft_result = np.fft.fft(signal) frequencies = np.fft.fftfreq(len(signal), 1/fs) magnitude = np.abs(fft_result) plt.stem(frequencies[:len(frequencies)//2], magnitude[:len(magnitude)//2], use_line_collection=True) plt.xlabel('Frequency (Hz)') plt.ylabel('Amplitude') plt.title('Frequency Spectrum') plt.show()
Check which frequency has the tallest stem in the plot.
The signal has two sine waves: 20 Hz with amplitude 0.6 and 50 Hz with amplitude 1.2. The 50 Hz component has the highest amplitude.
What error will this code produce when trying to compute the frequency spectrum?
import numpy as np signal = [1, 2, 3, 4, 5] fft_result = np.fft.fft(signal, n=3) print(fft_result)
Check the meaning of the parameter 'n' in np.fft.fft.
The parameter 'n' specifies the length of the FFT. It must be at least the length of the input signal. Here, n=3 is less than signal length 5, causing a ValueError.
You have a noisy signal composed of a 10 Hz sine wave plus random noise. Which approach best removes the noise using frequency analysis?
Think about which frequencies represent noise and which represent the signal.
The 10 Hz sine wave is the desired signal. Noise usually has higher frequencies. A low-pass filter keeping frequencies below 15 Hz removes high-frequency noise while preserving the 10 Hz signal.
