5
$\begingroup$

I have a small question that I am confused.

N=16;
x=[-pi:2*pi/N:pi-2*pi/N];
y=1.5*cos(x)
z=fft(y)/N

we will get negtive Fourier coefficients, however when we do it in this way:

N=16;
x=[0:2*pi/N:2*pi-2*pi/N];
y=1.5*cos(x);
z=fft(y)/N

we get positive ones. How to explain this? Thank you very much!

$\endgroup$
  • $\begingroup$ This is a question about MATLAB programming, not signal processing. I vote to close. $\endgroup$ – Dilip Sarwate Jul 19 '12 at 14:42
  • 2
    $\begingroup$ I think the fundamental question regards the meaning of the phase of DFT coefficients. The Matlab code is just a manifestation. $\endgroup$ – Mark Borgerding Jul 20 '12 at 11:24
6
$\begingroup$

In both cases, you are creating a sinusoid (y) that goes through exactly one cycle during the observation window of the FFT. The only difference is the phase at which the sinusoids begin. The latter starts at zero, while the former starts exactly one half cycle offset (-pi/2). The phase of an FFT coefficient reflects the cyclical timing offset of the sinusoid that coefficient represents.

$\endgroup$
3
$\begingroup$

A standard FFT (not using fftshift) references the phase of any sinusoid to the start of the window. Your two examples start the FFT window at two different points, where a cosine has a different value or phase.

Your input data is a cosine referenced to time 0. And a phase of 0 will show up as a positive real result in common FFT implementations.

Shift the window 180 degrees, and an out of phase with respect to the window start will show up as a negative real result.

Shifts by 90 degrees will show up in the imaginary component of the complex result.

The above examples are for strictly periodic in FFT aperture sinusoids only.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.