How do I determine phase shift of two sine curves (discrete time sampled sine curves) in Matlab. Currently, I have the FFT of these two sine curves, the phase shift is just the delay in time, which coresponds to the change of the phase angle. My question is, is it better to compare the phase shift in time domain, or do the comparison in the frequency domain?
[Math] Phase shift of two sine curves
fourier analysisgraphing-functionsMATLAB
Best Answer
A general method is to calculate the instantaneous phase for each of your discrete samples. The Hilbert transform, which can be represented in terms of the Fourier transform and it's inverse, can be used for this.
In Matlab, using the
hilbert
,angle
, andunwrap
functions:The result is a figure something like this:
Note, that, like the Fourier transform, this won't be accurate at the edges of your signals. Trimming your input signals to a whole number of periods will reduce aliasing effects. Type
edit hilbert
in your command window too see the code.