Take the 2-minute tour ×
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It's 100% free, no registration required.

Long story short, I have a sinusoidal wave with DC offset going in with a given frequency of say 100 Hz and $\phi = 0$ (which I'm guessing is really $\pi/2$ since it is a sine wave not cosine). I get an output of the same frequency and, using FFT, I would like to find the phase between these two. What I did is I found the peak frequencies (-100 and 100 Hz), found their bin and from the same bin I extracted the amplitude and the phase.

Is that correct?

share|improve this question
add comment

migrated from stackoverflow.com Apr 15 '13 at 17:17

This question came from our site for professional and enthusiast programmers.

3 Answers

The phase is relative to the start of the sample window, and unless the frequency component corresponds exactly with the center frequency of the relevant FFT bin then you also need to apply a correction.

share|improve this answer
That's a very good point. Any chance that you could add an explanation and/or example? –  Jim Clay Apr 15 '13 at 17:29
Sure - I'll try and find some time to add more detail later today. –  Paul R Apr 15 '13 at 18:03
The phase is relative to BOTH the start and end of the FFT window. Thus the problem for non-periodic signals unless one applies an fftshift. –  hotpaw2 Apr 15 '13 at 22:48
@jimclay : See my answer for a method to get a more correct phase (to a different reference point). –  hotpaw2 Apr 15 '13 at 22:49
Yes, the more I think about it the more it seems that using an FFT to extract phase information is the wrong approach - it can only really work if you know the exact frequency of the component of interest, which makes it useless for most practical applications. –  Paul R Apr 16 '13 at 6:46
show 2 more comments

If you're interested in the time delay between the two signals, it's probably most useful to compute the cross-correlation function of the two signals and find its maximum. The location of the maximum will give you the time lag.

share|improve this answer
add comment

You method will work for frequencies that are exactly periodic in the FFT width. For frequencies that are in between bins, I would first do an fftshift (of both FFTs) to position the 0 phase reference at the window center before interpolating phase and doing the phase subtraction. Otherwise the FFT will flip the phase between alternating FFT result bins making phase interpolation far more non-intuitive. However the evenness/oddness ratio of a sinusoid about the window center does not flip even for FFT result bins of non-periodic-in-aperture sinusoids, allowing a more intuitive phase comparison (after the fftshifts).

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.