Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Phase versus Time from an FFT

Subject: Phase versus Time from an FFT

From: Robert Ahrens

Date: 30 Sep, 2010 17:31:22

Message: 1 of 12

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

Subject: Phase versus Time from an FFT

From: Greg Heath

Date: 30 Sep, 2010 17:58:00

Message: 2 of 12

On Sep 30, 1:31 pm, "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 = 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.

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

Subject: Phase versus Time from an FFT

From: Jim Rockford

Date: 30 Sep, 2010 18:32:01

Message: 3 of 12

On Sep 30, 1:31 pm, "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.
Use the Hilbert transform. You'll want to read something about it
first, but in Matlab the quick and dirty approach is as follows
(assume the vector s is your signal):

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.

Test this out on a sinusoid s = 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.

Subject: Phase versus Time from an FFT

From: TideMan

Date: 30 Sep, 2010 19:11:14

Message: 4 of 12

On Oct 1, 6:31 am, "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 = 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

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.

Subject: Phase versus Time from an FFT

From: Robert Ahrens

Date: 30 Sep, 2010 19:29:07

Message: 5 of 12

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.

Subject: Phase versus Time from an FFT

From: Jim Rockford

Date: 30 Sep, 2010 22:01:42

Message: 6 of 12

On Sep 30, 3:29 pm, "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

Subject: Phase versus Time from an FFT

From: Greg Heath

Date: 30 Sep, 2010 23:11:09

Message: 7 of 12

On Sep 30, 1:58 pm, Greg Heath <he...@alumni.brown.edu> wrote:
> On Sep 30, 1:31 pm, "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 = 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.
>
> 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.

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

Subject: Phase versus Time from an FFT

From: Robert Ahrens

Date: 30 Sep, 2010 23:12:04

Message: 8 of 12

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

Subject: Phase versus Time from an FFT

From: dbd

Date: 1 Oct, 2010 02:33:51

Message: 9 of 12

On Sep 30, 10:31 am, "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 = 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

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

Subject: Phase versus Time from an FFT

From: Nezaket

Date: 5 Feb, 2013 08:18:08

Message: 10 of 12

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

Subject: Phase versus Time from an FFT

From: Robert Ahrens

Date: 5 Feb, 2013 15:42:11

Message: 11 of 12

"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.

Subject: Phase versus Time from an FFT

From: Andrew

Date: 2 Mar, 2013 23:33:08

Message: 12 of 12

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.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us