I have been working with FFTs for some time now and I just noticed this while I was trying to reproduce some results from simulations. The amplitude of the peak recovered with FFT changes with the the freqeuncy itself. Also, I noticed that different sampling frequencies on the same signal frequency produce a similar effect (with sampling freqeucny always higher than Nyquist). Lastly, I noticed that with sampling points around powers of two the effect is exxagerrated, with the delta function receovered by FFT being significantly broadened. WHy is this happenining?
Here is the code that I am using. Any help is appreciated!
sampling_points=2000;f_s=3000; % Hz sampling frequency
time=(1:sampling_points)/f_s;A=2; for ii=1:100 %loop to produce spectra with different frequencies
freq(ii)=ii*1+10;spectrum=A*cos(2*pi*freq(ii)*time); %make the spectrum
FFT_of_spectrum=fft(spectrum,[],2);FFT_abs=2*abs(FFT_of_spectrum)/sampling_points; % rescale the fft
FFT_abs=FFT_abs(1:sampling_points/2);FFT_abs(2:end-1)=FFT_abs(2:end-1);peak(ii)=max(FFT_abs); % find the height of the peak
endfigure('name','FFT of time domain spectrum')plot(FFT_abs);xlabel('Frequency (Hz)');ylabel('Amplitude');figure('name','FFT of spectrum in depth domain')plot(freq,peak)xlabel('Frequency (Hz)');ylabel('Amplitude of peak');
Best Answer