fft-response
fft-response
% Create a sample signal (sum of two sine waves) f1 = 50; % Frequency of the first sine wave (Hz) f2 = 120; %
Frequency of the second sine wave (Hz) signal = sin(2 * pi * f1 * time) + 0.5 * sin(2 * pi * f2 * time + pi/4);
% Create the frequency vector for the single-sided spectrum frequency_vector = sampling_frequency * (0:(N/2)) / N;
% Theory: The Fast Fourier Transform (FFT) is a fundamental algorithm in % signal processing that efficiently
computes the Discrete Fourier Transform (DFT). % The DFT decomposes a time-domain signal into its constituent
frequency % components. This code generates a sample signal composed of two sine waves % and then uses the fft
function in MATLAB to compute its frequency spectrum. % The magnitude spectrum shows the amplitude of each
frequency component present % in the signal. For real-valued signals, the frequency spectrum is symmetric, % so we
typically analyze the single-sided spectrum (from DC to the Nyquist % frequency, which is half the sampling frequency).
The peaks in the magnitude % spectrum correspond to the frequencies present in the original signal.