from DFT relation for cosine function we have DFT( cos(2*pifin) )=.5*( delta(f-fi)+delta(f+fi) ) as we can see the phase of the DFT is zero. However, when I use FFT in matlab, fft coefficients are complex which means the phase of the DFT is not zero. please help me to solve this contradiction.
2 Answers
The phase of an FFT result only corresponds exactly to the phase of the input cosines if the period of the input cosines are exact integer submultiples of the FFT length.
Another source of complex FFT results is rounding error. You can usually ignore values that are comparatively tiny (10e-13, etc.) relative to the average magnitudes, and the phase of two tiny rounding errors is indeterminate (same as the phase of a complex zero). Perhaps just assume zero.

- 70,107
- 14
- 90
- 153
When computing the DTFT of a cosine function, the phase is zero due to its symmetry. However, when using the FFT, the obtained phase is not zero because the FFT treat the sequence from 0 to L-1, that is, there is a shift, which turns to phase shift in the frequency domain. Nevertheless, the non-zero phase is linear.
You can compute the DTFT of two rectangular sequences, the one is symmetric and the other is from 0 to L-1.

- 226
- 3
- 14