I guess this is a pretty basic question, but I am kinda stuck... So if I am remembering the DSP theory correctly, spectral leakage can occur when we take "inappropriate" combinations of the following:
1) FFT length
2) sampling frequency
3) fundamental frequency of input signal
Here is a MATLAB script for demonstrating this, in a case of a sinusoid input:
F0=10; %Frequency of the sinusoid Fs=100; %Sampling Frequency observationTime = 1; %observation time in seconds t=0:1/Fs:observationTime-1/Fs; %time base x=sin(2*pi*F0*t);%sampled sine wave N1=100; %DFT length same as signal length X1 = 1/N1*fftshift(fft(x,N1));%N-point complex DFT of x f1=(-N1/2:1:N1/2-1)*Fs/N1; %frequencies on x-axis stem(f1,abs(X1));
MY thought was that if the fundamental frequency is a multiple of the frequency resolution, then there will be no spectral leakage, since there is a bin that corresponds to the exact value of the fundamental frequency F0. However, it seems like I am wrong here...
Can someone please explain to me what's the flaw in my rationale? Why is there leakage in the 3rd plot? Thanks in advance