COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Phase versus Time from an FFT

• Email
• Follow

```I am trying to obtain phase versus time information from a discrete time sampled signal. As an example: suppose I have a signal F = sin(w*t + phi) where the value of w is constant, but the value of phi is a function of time. So, if I aquire the signal at some sampling rate, I can perform FFT(F) resulting in amplitude and phase information. Since the value of phi is a function of time, the resulting FFT amplitude spectrum will indicate a spread in frequency values located somewhere around w, with a range of phase values also around w.

My question is this: How can I extract the phase versus frequency values such that I can determine the values of phi (in signal F) as a function of time? I don't believe that performing an IFFT(phase) will result in phi(t).

Thanks
Bob
```
 0

See related articles to this posting

```On Sep 30, 1:31=A0pm, "Robert Ahrens" <no.re...@none.com> wrote:
> I am trying to obtain phase versus time information from a discrete time =
sampled signal. As an example: suppose I have a signal F =3D sin(w*t + phi)=
where the value of w is constant, but the value of phi is a function of ti=
me. So, if I aquire the signal at some sampling rate, I can perform FFT(F) =
resulting in amplitude and phase information. Since the value of phi is a f=
unction of time, the resulting FFT amplitude spectrum will indicate a sprea=
d in frequency values located somewhere around w, with a range of phase val=
ues >also around w.

The last phrase makes no sense, w is not a phase.
>
> My question is this: How can I extract the phase versus frequency values =
such that I can determine the values of phi (in signal F) as a function of =
time? I don't believe that >performing an IFFT(phase) will result in phi(t)=
..

If you knew F and w*t how would you obtain phi?

More later.

Greg
```
 0

```On Sep 30, 1:31=A0pm, "Robert Ahrens" <no.re...@none.com> wrote:
> I am trying to obtain phase versus time information from a discrete time =
sampled signal. As an

Bob - don't use the FFT to extract time-dependent phase information.
first, but in Matlab the quick and dirty approach is as follows
(assume the vector  s   is your signal):

sa =3D hilbert(s);    % returns "analytic signal" (complex)
amp =3D abs(sa);   % local amplitude information (envelope)
phase =3D angle(sa);  % phase information (wrapped on unit circle)

If you want frequency vs. time information, you need to numerically
calculate the derivative.  I suggest the Savitzky-Golay method.

Test this out on a sinusoid    s =3D sin(2*t).   The amplitude will be
unity at each time, and the phase should linearly increase in time
(except at jumps) with a line slope equal to 2.
```
 0

```On Oct 1, 6:31=A0am, "Robert Ahrens" <no.re...@none.com> wrote:
> I am trying to obtain phase versus time information from a discrete time =
sampled signal. As an example: suppose I have a signal F =3D sin(w*t + phi)=
where the value of w is constant, but the value of phi is a function of ti=
me. So, if I aquire the signal at some sampling rate, I can perform FFT(F) =
resulting in amplitude and phase information. Since the value of phi is a f=
unction of time, the resulting FFT amplitude spectrum will indicate a sprea=
d in frequency values located somewhere around w, with a range of phase val=
ues also around w.
>
> My question is this: How can I extract the phase versus frequency values =
such that I can determine the values of phi (in signal F) as a function of =
time? I don't believe that performing an IFFT(phase) will result in phi(t).
>
> Thanks
> Bob

You can't.

You're trying to violate the Heisenberg uncertainty principle:
precision in time imposes a certain vagueness about frequency, and
precision in frequency imposes a certain vagueness about time.

FFT wholly transforms from time to frequency meaning there is nothing
left about time in the Fourier transform.
You need to partially transform from time to frequency using wavelets
or similar.
```
 0

```Thanks for the information regarding the Hilbert transform... I am going to look into it.

There seemed to be some confusion regarding my original question, so I have tried to clarify it.... I hope:

Here is the problem: I have an A/D sampled version of F = sin (w*t + phi) (at some Fs sampling rate) that contains a single frequency value that is smeared by the fact that there is a phase error, namely phi. If I take an FFT of F, I see amplitude at a range of frequencies located somewhere around the fundamental frequency f (f = w/2*pi). In the absence of the phase error (phi), I should see power at frequencies of -f and +f; However, the addition of the phase error (phi - which is a function of time) spreads the power out over a range of frequencies, near +/-f.

My question is: In the absence of knowledge of the exact value of w (or f) or knowledge of phi(t), how can I determine the phase error (phi) as a function of time so that the collected data (or FFT) can be corrected to obtain the fundamental value of w (or f = w/2*pi)? If I can determine phi as a function of t, then I can correct the original data and obtain w.
```
 0

```On Sep 30, 3:29=A0pm, "Robert Ahrens" <no.re...@none.com> wrote:
> Thanks for the information regarding the Hilbert transform... I am going =
to look into it.

Robert - while I don't have an answer to your main problem (correcting
the phase errors), I would like to point you toward an excellent (the
best in my opinion) and very readable introduction to the Hilbert
transform:  ch. 2 in "Time Frequency Analysis:  Theory and
Applications" by L.Cohen (1994).

A very fundamental, classic problem in signal analysis is how to
define the "instantaneous" phase and frequency of a signal.  The
Hilbert transform is the way to go if your signal is sufficiently
narrow-band.  If it's wide-band, then the Hilbert transform can give
you misleading garbage.  It is for this reason, in fact, that in the
1990s Huang developed the "Hilbert-Huang" transform, which is
something else you might want to look into.  Note that Matlab has a
"hilbert" function to calculate the hilbert transform, but no
implementation of the Hilbert-Huang transform (however, look in Matlab
central).  Incidentally, the Hilbert-Huang transform approach is
immune from the "uncertainty principle" that dogs Fourier and Wavelet
approaches.  However, the Hilbert-Huang transform has plenty of other
murky features to make up for it.

In your case, if the phase errors are not overwhelmingly large, then
you might be well served to calculate the instantaneous phase of the
signal for the entire record, and subtract from this the time
evolution of the phase that you actually expect.  For your apparently
narrow-band data the Hilbert transform is really the way to go to get
instantaneous phase.  I think there is fairly wide consensus that this
tack makes the most sense (see Cohen for good motivational material).
I suggest making a fake signal of the type you're dealing with, with a
known phase function that deviates from the expected, and run this
through the Hilbert transform machinery so you get a feel for things.

Jim
```
 0

```On Sep 30, 1:58=A0pm, Greg Heath <he...@alumni.brown.edu> wrote:
> On Sep 30, 1:31=A0pm, "Robert Ahrens" <no.re...@none.com> wrote:
>
> > I am trying to obtain phase versus time information from a discrete tim=
e sampled signal. As an example: suppose I have a signal F =3D sin(w*t + ph=
i) where the value of w is constant, but the value of phi is a function of =
time. So, if I aquire the signal at some sampling rate, I can perform FFT(F=
) resulting in amplitude and phase information. Since the value of phi is a=
function of time, the resulting FFT amplitude spectrum will indicate a spr=
ead in frequency values located somewhere around w, with a range of phase v=
alues >also around w.
>
> The last phrase makes no sense, w is not a phase.
>
>
>
> > My question is this: How can I extract the phase versus frequency value=
s such that I can determine the values of phi (in signal F) as a function o=
f time? I don't believe that >performing an IFFT(phase) will result in phi(=
t).
>
> If you knew F and w*t how would you obtain phi?
>
> More later.

F has the form of  frequency modulation (FM) and
phase modulation (PM) signals.
..
Rather than using  an FFT/IFFT approach, use one
of the several FM or PM demodulation approaches
typically based on multiplying the modulated signal
by the quaddature of the carrier and filtering.

For a very brief description see

http://en.wikipedia.org/wiki/Demodulation
http://en.wikipedia.org/wiki/Frequency_Modulation
http://en.wikipedia.org/wiki/Phase_Modulation

Hope this helps.

Greg

```
 0
Reply heath (3990) 9/30/2010 11:11:09 PM

```Jim,

Thanks for your informative response. I actually have a copy of Cohen's book on my bookshelf and will definitely read up on the Hilbert transform.

Bob
```
 0

```On Sep 30, 10:31=A0am, "Robert Ahrens" <no.re...@none.com> wrote:
> I am trying to obtain phase versus time information from a discrete time =
sampled signal. As an example: suppose I have a signal F =3D sin(w*t + phi)=
where the value of w is constant, but the value of phi is a function of ti=
me. So, if I aquire the signal at some sampling rate, I can perform FFT(F) =
resulting in amplitude and phase information. Since the value of phi is a f=
unction of time, the resulting FFT amplitude spectrum will indicate a sprea=
d in frequency values located somewhere around w, with a range of phase val=
ues also around w.
>
> My question is this: How can I extract the phase versus frequency values =
such that I can determine the values of phi (in signal F) as a function of =
time? I don't believe that performing an IFFT(phase) will result in phi(t).
>
> Thanks
> Bob

Your problem does not have a unique solution unless your data meet
anti-aliasing and circular ambiguity requirements. Also, it is not
possible to distinguish between contributions to data values from w
and from a component of phi that is proportional to time.

Within these limitations, You can estimate w from the zero crossings
in your data duration. This can be performed to best accuracy by
applying your best interpolation algorithm to accurately estimate the
times of the first and last crossings. Calculate w from the time
interval between those crossings and the number of half-cycles.

You do not need to calculate phi(t) to determine w. You could
calculate phi once you know w.

If you had specified a finite signal to noise ratio, further steps
could be applied to reduce the variance of the estimate of w.

Dale B. Dalrymple
```
 0

```Dear Bob,
I have a similar problem. Have you solved your problem and if yes could you please tell me how?

"Robert Ahrens" wrote in message <i835g4\$2q2\$1@fred.mathworks.com>...
> Jim,
>
> Thanks for your informative response. I actually have a copy of Cohen's book on my bookshelf and will definitely read up on the Hilbert transform.
>
> Bob
```
 0
Reply neezaket (1) 2/5/2013 8:18:08 AM

```"Nezaket" wrote in message <keqf80\$sj0\$1@newscl01ah.mathworks.com>...
> Dear Bob,
> I have a similar problem. Have you solved your problem and if yes could you please tell me how?
>
> "Robert Ahrens" wrote in message <i835g4\$2q2\$1@fred.mathworks.com>...
> > Jim,
> >
> > Thanks for your informative response. I actually have a copy of Cohen's book on my bookshelf and will definitely read up on the Hilbert transform.
> >
> > Bob

I did. If you tell me what your problem is, maybe I can help.
```
 0

```Very, nice and exactly what I needed to find the instantaneous phase difference between two noisy oscillating signals (not sinusoids, but the outputs of a dynamical system). Some notes that might be helpful to others:

1. This technique is apparently due to Nobel prize winner and inventor of holography Dennis Gabor (of filter and wavelet fame) in case you want to cite the appropriate paper: Gabor D. (1946) Theory of communication. J. IEE London 93, 429-457.

2. If your trying to find phase differences between signals, you'll want to make sure that your "signals" are centered about zero or have zero mean or you may get undesirable discontinuities (even when you apply unwrap()). This might be the case if your signal is rectified, in which case you can just shift the signal down by half the rectified magnitude. You may want to do this anyways as the numeric phase value returned will be off by the shift amount. However, the resultant phase curve will possibly have a different shape.

3. If you have an analytical expression for your oscillatory input signal (e.g., sin(t)), you may be able to derive (or find) an analytical expression for the Hilbert Transform of it. MathWorld offers several: http://mathworld.wolfram.com/HilbertTransform.html  and this book has many more (see pp. 301-303): http://amazon.com/dp/1420066528

4. Just like with FFTs/DFTs you should try to make sure to apply the hilbert() function to an integer number of periods of your oscillatory signal. In fact, Matlab's hilbert() function is based on fft() and ifft() (type "edit hilbert" in the Matlab console to see the code). If this is not an option, try to use as many periods as possible and be sure to discount or crop the left- and right-most parts.

5. I heartily recommend Savitzky-Golay (sgolay() in Matlab) for calculating derivatives of real data signals.

-- Andy

> sa = hilbert(s);    % returns "analytic signal" (complex)
> amp = abs(sa);   % local amplitude information (envelope)
> phase = angle(sa);  % phase information (wrapped on unit circle)
>
>
> If you want frequency vs. time information, you need to numerically
> calculate the derivative.  I suggest the Savitzky-Golay method.
```
 0