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?
x
is a cosine of a cosine. $\endgroup$x
is a (regular) cosine, right? $\endgroup$real
. You will confuse yourself when trying to call built-inreal
. $\endgroup$