Hilbert transform with sine and cosine
34 views (last 30 days)
Show older comments
Lorenzo Bernardini
on 22 Oct 2019
Answered: Lorenzo Bernardini
on 25 Oct 2019
Hello there,
I have a question: from theory I know that the Hilbert transform of a simple sine is a cosine and viceversa. Now, the question is: why if I compute the Hilbert transform (with the function hilbert.m) of a sine, and I take the imaginary part of that transform, that imaginary part, once plotted, is not a cosine?
I think I miss what the matlab function really does. Someone can help me?
Thanks in advance.
0 Comments
Accepted Answer
Daniel M
on 22 Oct 2019
The hilbert transform, as per the documentation, indicates that the imaginary part of the transform is the original (real) sequence with a 90 degree phase shift. Therefore, a cosine becomes a sine (because that is what happens when you shift a cosine wave by pi/2 to the right). A sine wave becomes a negative cosine, because that is what happens when you shift a sine wave by pi/2 to the right.
When it says "Sines are therefore transformed to cosines, and conversely, cosines are transformed to sines." it means that in the sense of odd and even functions (where sines are asymmetric about zero, and cosines are symmetric about zero).
2 Comments
Daniel M
on 22 Oct 2019
In your example, you have 4.75 cycles of the wave. Internally hilbert takes an fft of the signal. Fourier transforms behave circularly, that is, it assumes that the end of the signal wraps back around to the beginning of the signal.
Now because your signal ends at 3pi/2 phase, and begins at 0 phase, it is a large discontinuous jump. That is the source of the distortion of the imag(y1) part.
With real-world signals, typically you can't do much about this, and if your signal is long enough, you can truncate the beginning and ends (if that is applicable to your situation).
Otherwise, I have had some success in the past using paddedhilbert on the file exchange:
"Finally, if I have a random signal, named u, its Hilbert transform is always -imag(hilbert(u))? Thank you again for your time and attention."
No, the hilbert transform is the imaginary part (without the negative).
More Answers (1)
See Also
Categories
Find more on Transforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!