Why the Hilbert transform is not correct using the hilbert function in Matlab?

35 次查看(过去 30 天)
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')
Why the Hilbert transform using hilbert function is not same as the real Hilbert transform?

回答(2 个)

Fatpigdog
Fatpigdog 2024-1-24
编辑:Fatpigdog 2024-1-24
As carefully buried deep in Matlab's help for the hilbert function ...
"hilbert returns a complex helical sequence, sometimes called the analytic signal, from a real data sequence.
The analytic signal x = xr + jxi has a real part, xr, which is the original data, and an imaginary part, xi, which contains the Hilbert transform."
So the "Hilbert transform", xi, is the imaginary part of the returned value from hibert function, or
Hilbert transform = imag(hilbert(xr));

Paul
Paul 2024-1-24
I think the issue is that the assertion that the "Hilbert transform of cos is sin" is not correct for this problem. According to the Table of Selected Hilbert Transforms that relationship is true when the frequency and phase of the cos is constant. But further down the page at Angle Modulation it states that the Hilbert transform of
u(t) = cos(w*t + phi(t))
is
H(u) = sin(w*t + phi(t))
only when w is sufficiently large compared to dphi/dt.
In the problem at hand, we have w = 0 and phi(t) = 30*cos(5*t), so the condition doesn't hold.
The maximum of dphi/dt is 30*5 = 150, so I'll use w = 500 as being "sufficiently large." Note: I'm not sure what sufficiently large means for w > 0 and where dphi/dt can be negative; I'm assuming the absolute value of dphi/dt is what counts.
With w = 500, the expected relationships appear to hold using hilbert.
t = 0:0.001:3;
realphase = 30*cos(5*t); %signal phase, or phi(t)
w = 500;
x = cos(w*t + realphase); %signal
H =hilbert(x);
img =imag(H); %Hilbert transform using hilbert function
ht = sin(w*t + realphase); %Hilbert transform of cos is sin
figure
plot(img)
hold on
plot(ht)
ylabel('Hilbert transform')
legend('imag(H)','sin(w*t + realphase)')
xlim([0 500])
real=real(H);
ph = unwrap(atan2(img,real)); %unwrapped phase using hilbert function in MATLAB
pt = unwrap(atan2(ht,real)); %unwrapped phase
figure
plot(realphase)
hold on
plot(ph)
plot(pt)
ylabel('phase')
legend('realphase','ph','pt')

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by