With the cosine signal fc=3Hz and the fs=13Hz as below,
fc=3; fs=13; Ts=1/fs; N=101*13; % 101 times of fs n=0:N-1; x=cos(2*pi*fc*n*Ts);
and then fft with the number nfft=N
nfft=N; Xk=fft(x,nfft); Pxx=(abs(Xk)/nfft).^2; f=(0:nfft-1)*fs/nfft; plot(f,10*log10(Pxx))
and I got the result as below figure
and then I tried with different number N=1200 I got different shape of fft result as shown below figure
After several fft trials with different numbers, I found that only when N is an integer number of multiples of fs, I get the same result as the first picture. I wonder why this phenomenon is happening.