I suspect that your frequency of interest is simply not falling on a DFT bin directly. Why do you think you need to use a power of two for the DFT?
For example, if I have data sampled at 1 kHz and I have 1000 points, then frequency increment in DFT bins is 1 Hz (the bins are 1 Hz apart) so a frequency of 100 Hz for example will fall directly on a bin.
Fs = 1000;
t = 0:1/Fs:1-1/Fs;
x = 1.5*cos(2*pi*100*t);
xdft = fft(x);
freq = 0:Fs/length(x):Fs/2;
xdft = xdft(1:length(x)/2+1)./length(x);
xdft(2:end) = 2*xdft(2:end);
plot(freq,abs(xdft))
See that the magnitude is estimated exactly. Now watch what happens when I pad to 1024:
xdft = fft(x,1024);
freq = 0:Fs/length(xdft):Fs/2;
xdft = xdft(1:length(xdft)/2+1)./length(x);
xdft(2:end) = 2*xdft(2:end);
plot(freq,abs(xdft))
by padding to 1024, I have now made the frequency of interest fall between DFT bins and that makes my amplitude estimate inaccurate.
in the Signal Processing Toolbox documentation
Best Answer