Fast Fourier Transform of sinusoidal signal | FFT Lecture - 3
ฝัง
- เผยแพร่เมื่อ 10 ก.ย. 2024
- In this video, we demonstrate how to perform a Fast Fourier Transform (FFT) on a normalized sine wave that has been mixed with noise. This process is essential in signal processing to analyze the frequency components of a signal.
Code Breakdown:
Setup:
We define the sample rate (SR) and duration (T) of the signal.
We calculate the number of samples (N) in the signal.
FFT Calculation:
We use the rfft function from the scipy.fft module to compute the FFT of the normalized mixed signal (normalized_tone).
We calculate the corresponding frequencies using rfftfreq.
Plotting the FFT:
We plot the amplitude of the FFT result against the frequency to visualize the frequency components of the signal.
Code:
in addition to the last video code add the below code
from scipy.fft import rfft, rfftfreq
#no of samples in the normalized frequency
N= SR* T # SR = sample rate and T = length of the pulse
yf= rfft(normalized_tone)
xf= rfftfreq(N, 1/ SR)
plt.xlabel('Frequency (Hz)')
plt.ylabel('Amplitude')
plt.title('FFT of the Sine Wave')
plt.plot(xf,np.abs(yf))
plt.show()