3 views (last 30 days)

Show older comments

I was working on the signal from which I expect to obtain three impulses where the first and the third impulse are situated at Hz which is correct for what the FT of should describe. Furthermore the middle impulse "also known as the DC term" is also apparent as expected however the underlying issue is that this middle impulse supposed to be since the rand function generates numbers from a uniform distribution in the range of which explains why (Note that the "0" additive term comes from the fact that is even symmetric). Now the big question is why is that the FT obtained showed the middle impulse (DC term) having a noise amplitude slightly less than ? Below I present the code I used:

function [X] = FTCos(N)

f=linspace(-51.2,51.2,N);

t=linspace(-5,5,N);

C=cos(2*pi*t)+rand(1,N);

X=fftshift(fft(C))/N;

plot(f,X,'b')

On the command window:

N=1024;

[X]=FTCos(N)

Any theoratical and practical explanation is much welcomed and thank you!

Update: I am theorizing that a reason to obtain the DC term close to and not equal to 0.5 Hz is because the noise generated isn't precisely uniformly distributed.

David Goodmanson
on 2 May 2021

Edited: David Goodmanson
on 2 May 2021

Hi Tarek,

the reason that you don't see 0.5 is that you are taking a finite number of samples, 1024, from the distribution. Due to statistical fluctuations you would not expect to see exactly 0.5 for the mean of the sample. Running your code a bunch of times, sometimes the center peak is a bit greater than 0.5, sometimes a bit less.

The set of random points also produces a small imaginary part to the fft transform, which the plot is warning about but otherwise ignoring.

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!