I'm starting with Matlab and our professor told us to do some exercises to get it going.
One of them it's to plot the Fourier Transform of a cosine (cos(2*pi*t)), but sampled with sample frequency of fs=12Hz.
So I did the following:
>> fs=12;
>> n=0:1/fs:11/fs;
>> x=cos(2*pi*n);
>> stem(n,x)
Which gives me the following:
Then I calculated the fft of x:
>> y=abs(fft(x));
>> k=0:fs:11*fs;
>> stem(k,y)
Which should give me the real part of the Fourier Transform of a cosine, but If I recall correctly, the FT of a cosine is two spikes, one at (wave frequency)/2*pi and another at -(wave frequency)/2*pi, but I got this:
Why I'm getting both spikes at positive side of the axis? One could argue the DFT is periodic, which is, but it should be periodic with 2*pi, no?
I think I'm really messing up DTFT and DFT of cosine, but I can't figure out what can I do to correct my plot.
Thanks in advance.
Best Answer