MATLAB: Do I see frequencies which do not exist in the original signal in the output of the FFT function

extraneousMATLABnoisenyquistratesampling

I have a simple signal which is the sum of three sinusoids of frequencies 50 Hz, 100 Hz and 100400 Hz. The signal is sampled at 1000 Hz. The output of the FFT function, besides containing the 50 Hz and 100 Hz frequency components, also contains a 400 Hz frequency component which does not exist in the original signal. The code is provided below:
Fs = 1000; % Sampling rate
T = 1/Fs; % Sample time
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
third_frequency=100400;
y = 0.7*sin(2*pi*50*t) + sin(2*pi*100*t) + 2*sin(2*pi*third_frequency*t);
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2);
% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

Best Answer

The behavior observed is due to a phenomenon called aliasing. Aliasing refers to the distortion that occurs when a continuous time signal has frequencies larger than half of the sampling rate. The process of aliasing describes the phenomenon in which components of the signal at high frequencies are mistaken for components at lower frequencies.
To avoid aliasing, ensure that the sampling rate is high enough to avoid any spectral overlap, or use an anti-aliasing filter. In the code, for example, consider "third_frequency" to be 600. Since the sampling frequency, Fs, is 1000, you will notice a component at 1000 – 600 = 400 Hz. If "third_frequency" is 800, you will see a component at 1000 – 800 = 200 Hz.