MATLAB Answers

FFT of sine wave shows unexpected spectral widening

2 views (last 30 days)
Trying this code:
res = 1024;
t = 1:res*90;
t = t/res;
FreqList = [ 0.1, 0.25, 0.5, 0.55, 1];
templeS = (10*sinpi(2*FreqList(1)*t));
for i = 2:numel(FreqList)
ff = fft(templeS);
frq = 0:numel(t)-1;
frq = frq*res/numel(t);
plot(frq, abs(ff));
I expected to get sharp peaks at FreqList. However....
Can anyone explain this stange behavior of 0.25 and 0.55 frequencies?
BTW, i tryed also 0.24 and 0.56 without other frequencies, as well as different resolutions, with the same effect os spectral widening...


Sign in to comment.

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 29 Jan 2020
Try this:
axis tight
ax = axis;
axis([[-30 0]+ax(2) ax(3:4)])
axis tight
axis tight
ax = axis;
axis([[0 6000]+ax(1) ax(3:4)])
Then you'll see that the function might be continuous around at the boundary, but its first derivative is not. Therefore the spectral widening. If you try the to select a period where your signal is nicely periodic you get much nicer peaks:
ff2 = fft(templeS(1:(89600)));

  1 Comment

Eli Ratner
Eli Ratner on 29 Jan 2020
Thanks, but i get widening at other frequenciesi in this case. Of course, i can find the number of samples for complete period of all used frequencies, but it seems me incorrect way to work with real signals...
Indeed, i expected that the error of not whole cycle will be much smaller, because the number of cycles is large enough...

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Translated by