identifying phase shift between signals

前端 未结 6 2076
暗喜
暗喜 2020-12-23 14:50

I have generated three identical waves with a phase shift in each. For example:

t = 1:10800; % generate time vector
fs = 1; % sampling frequency (seconds)
A          


        
6条回答
  •  半阙折子戏
    2020-12-23 15:37

    For two sinusoidal signal the phase of the complex correlation coefficient gives you what you want. I can only give you an python example (using scipy) as I don't have a matlab to test it.

    x1 = sin( 0.1*arange(1024) )
    x2 = sin( 0.1*arange(1024) + 0.456)
    x1h = hilbert(x1)
    x2h = hilbert(x2)
    c = inner( x1h, conj(x2h) ) / sqrt( inner(x1h,conj(x1h)) * inner(x2h,conj(x2h)) )
    phase_diff = angle(c)
    

    There is a function corrcoeff in matlab, that should work, too (The python one discard the imaginary part). I.e. c = corrcoeff(x1h,x2h) should work in matlab.

提交回复
热议问题