I have 2 sin waves:
Fs = 1500; N = 100; t = (0:N-1)'/Fs; sinwave = sin(2*pi*15*t); sinwaveshifted = sin(2*pi*15*t + 1.3);
If I get the magnitude at 15Hz using an fft (need to use an FFT that is a power of 2 for reasons beyond my control):
fftsin = fft(sinwave,128); fftsinshift = fft(sinwaveshifted,128); % 2 corresponds to 15Hz abs(fftsin(2)) = 51.819; abs(fftsinshift(2)) = 41.6151;
Why the difference? I'm assuming because my bins do not line up perfectly there is some leakage occurring. Also, I haven't done any windowing.
If I do window my signals (I used a flat top because I read that was best in terms of magnitude accuracy), these are my results:
w = window(@flattopwin, 100); sinwin = sinwave .* w; sinshiftwin = sinwaveshift .* w; fftsin = fft(sinwin ,128); fftsinshift = fft(sinshiftwin ,128); % 2 corresponds to 15Hz abs(fftsin(2)) = 2.7283; abs(fftsinshift(2)) = 17.822;
Why the huge difference?