1
$\begingroup$

I am trying to get the phase of a signal with Hilbert transform. However, I found that the unwrapped phase was not correct because the Hilbert transforming using the hilbert function in MATLAB is not correct. The simulation code shown as below:

t=0:0.001:3;
realphase=30*cos(5*t); %signal phase
x=cos(realphase); %signal
H=hilbert(x);

img=imag(H); %Hilbert transform using hilbert function
real=real(H);
ph=unwrap(atan2(img,real)); %unwrapped phase using hilbert function in MATLAB
ht=sin(realphase); %Hilbert transform of cos is sin
pt=unwrap(atan2(ht,real)); %unwrapped phase

subplot(2,1,1)
plot(img)
hold on
plot(ht)
ylabel('Hilbert transform')
legend('imag(H)','sin(realphase)')

subplot(2,1,2)
plot(realphase)
hold on
plot(ph)
plot(pt)
ylabel('phase')
legend('realphase','ph','pt')

The Hilbert transform of $\cos$ should be $\sin$, but with the hilbert function in MATLAB, it is not a $\sin$, why? Could anyone please help me?

$\endgroup$
  • 1
    $\begingroup$ Note that your signal x is a cosine of a cosine. $\endgroup$ – MBaz Aug 11 '16 at 13:42
  • $\begingroup$ @MBaz I believe this is intentional - the analysis is of a non-stationary sinusoid. $\endgroup$ – Speedy Aug 11 '16 at 14:47
  • $\begingroup$ @Speedy I thought so, but the OP is expecting the Hilbert transform to be a sine, which only makes sense if the signal x is a (regular) cosine, right? $\endgroup$ – MBaz Aug 11 '16 at 18:20
  • 1
    $\begingroup$ side note: don't call your variable real. You will confuse yourself when trying to call built-in real. $\endgroup$ – Memming Oct 10 '16 at 17:46
1
$\begingroup$

I don't think the Hilbert function in Matlab is incorrect - you can establish this by carrying out the same process for a stationary sinusoid (observe the discontinuities at the start/end). Further, the unwrapped phase of the Hilbert transform you've performed does have a sinusoidal characteristic, although with a significant offset.

I think it's more likely you're looking at an interaction of your rapidly changing phase with the windowing implicit to a filter implementation of the Hilbert Transform. Perhaps you could try slowing down the rate in change of phase to see whether you can isolate changes in phase from the window length? You could do this by expanding your time vector (using an increment smaller than 0.001).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.