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