Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Hilbert Transform/filter (Read 5813 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Hilbert Transform/filter

Greetings,

I would like to change the phase of a signal but not much of a DSP person. Changing the phase by 180 degrees is a matter of multiplying the signal by -1. But how do you change the phase of a signal by say 90 degrees?

From what I have understood so far, the Hilbert Transform does just that. I have found the following link which provides coefficients for achieving this.
Digital Hilbert Transformer Designer

Question 1: That site has the option to set the windowing type. I thought windowing was only needed when working in the frequency domain.

Question2: I got 35 coefficients with rectangular window mode and convolved them with a 440Hz sine wave. When comparing the waveforms of the original sine wave and the one that went through the hilbert filter, there is a change in shift but it seems to be greater than 90 degrees, in fact it seems to be closer to 180 thatn 90. Is this not how I am supposed to use the hilbert?

Question 3: (Basic question).. 90 degrees phase change should move the signal 90 degrees forward in time, and -90 degrees pahse change should result in the signal begind shift 90 degrees back in time? Other way arround? Which ever way the above link coeeficient calculator shifts it, how does one change it to shift the signal the other way (Perhaps one would want to shift a signal by +90 and antother signal by -90?

Question 3: How can I calculate the coeeficients myself so that I am not limited to 35 coeeficients?

Thanks!   

Aristotel

Hilbert Transform/filter

Reply #1
Answer 1:
The impulse response of a perfect hilbert transformer is of infinite length. If you want to approximate the transform via a FIR filter you have to limit the impulse response's length. By just chopping some samples off you'll get pass band ripples which is a not so good thing. By applying a smooth weightening of the finite impulse response sample set you can smooth the filter's frequency response curve.

The perfect Hilbert transformer's transfer function is given by:
Code: [Select]
H(z) = 2/(1*pi) * (z^1 - z^{-1}) +
       2/(3*pi) * (z^3 - z^{-3}) +
       2/(5*pi) * (z^5 - z^{-5}) + ...


Note: There are positive powers of z.


Answer 2:

If you approximated a Hilbert transformer with a 35 coefficient FIR filter you have to compensate for the filter's delay of 17 samples. This is because of the positive powers of z in H(z) which actually means you need samples of the original signal in advance to compute the current sample.


Answer 3:

phase shift != time shift (this only works for infinite sines). BTW: shifting -90 is equivalent to shifting +90 and multiplying the result by -1. Moreover, if you have calculated the 90 degree shifted version you can simply create other phase shifts by a smart weighted addidion of those two. Let x be your original signal and y be the 90 degree shifted signal. Then z = cos(alpha) * x + sin(alpha) * y will be a phase shifted version (alpha degree) of your original signal x.


Answer of 2nd question you numbered with 3:

Just take a look at the optimal filter's transfer function I gave in form of a polynomial. Generating the coefficients is now a very simple task. First, you have to decide about the length of the filter's response. The only lengths that make sense are of the form 3+4k where k is any non-negative integer. In your case k was 8. For my example I choose k=2. The unweighted ir coefficients are
ir = [ -2/(5*pi)  0  -2/(3*pi)  0  -2/(1*pi)  0  2/(1*pi)  0  2/(3*pi)  0  2/(5*pi) ]
Now you should smooth the filter's frequency response curve by applying a window. I usually prefer the Blackman window for such tasks.
weighted_ir = ir .* blackman(length(ir))'  // Matlab style code, ".*" denotes to component-wise multiplication
After the filter creation you should check the filter's properties by applying an FFT on a zero-padded version of your impulse response and observation of the FFT bin's magnitudes.

edit: since the Blackman function implementation of Matlab (i just checked) returns a vector starting and ending with a zero component  the first and last coeff will be zeroed and this practically lowers the filter's order. You may want to compute the window for size n+2 and use just the middle n (non-zero) samples as weights.

edit2: This approach is fairly simple. There are more advanced methods like (REMEZ = equi-ripple optimization) which actually lets you optimize the filter so that certain constraints are met but these are usually not that trivial. (btw: Matlab comes with a REMEZ implementation which lets you design all sorts of FIR filters)


SebastianG

Hilbert Transform/filter

Reply #2
Sebastian...Danke danke danke!!!

that information is all very useful and I am going to give the suggestions a try in a few hours.

Thanks a lot! Will let you know on the outcome..

Aristotel 

Hilbert Transform/filter

Reply #3
I am trying to create a signal with a prespecified sequence of instantaneous phases. Does anyone know how to do this?
The amplitudes don't matter. If I get a new signal X(t) from taking a random Y(t) and dividing it by the tangent of the prespecified phases, this does not work, as if I try to find the instantaneous phases of the new X(t) by finding its HT, I get different phases. Any help would be much appreciated!

Hilbert Transform/filter

Reply #4
Quote
I am trying to create a signal with a prespecified sequence of instantaneous phases. Does anyone know how to do this?
The amplitudes don't matter. If I get a new signal X(t) from taking a random Y(t) and dividing it by the tangent of the prespecified phases, this does not work, as if I try to find the instantaneous phases of the new X(t) by finding its HT, I get different phases. Any help would be much appreciated!
[a href="index.php?act=findpost&pid=290795"][{POST_SNAPBACK}][/a]


I'm not following you.
"signal with a prespecified sequence of instantaneous phases" ???
"tangent" ???

Sorry, I can't make any sense of what you said.


SebastianG

Hilbert Transform/filter

Reply #5
Quote
Quote
I am trying to create a signal with a prespecified sequence of instantaneous phases. Does anyone know how to do this?
The amplitudes don't matter. If I get a new signal X(t) from taking a random Y(t) and dividing it by the tangent of the prespecified phases, this does not work, as if I try to find the instantaneous phases of the new X(t) by finding its HT, I get different phases. Any help would be much appreciated!
[a href="index.php?act=findpost&pid=290795"][{POST_SNAPBACK}][/a]


I'm not following you.
"signal with a prespecified sequence of instantaneous phases" ???
"tangent" ???

Sorry, I can't make any sense of what you said.


SebastianG
[a href="index.php?act=findpost&pid=291067"][{POST_SNAPBACK}][/a]


Thanks very much for your reply! I want to create a time domain signal having any random series of amplitudes. If I make this signal into an analytic signal, using the Hilbert Transform, I can obtain the series of instantaneous phases, theta(t), for that signal by finding the arctangent of the imaginary part, Y(t), divided by the real part, X(t). What I want to do is to reverse that process, to make a time domain signal that would give a particular sequence of phases (by the process jsut described) that I have pre-specified. I am basically seeking a real sequence and an imaginary sequence which have two relationships. Y(t)/X(t) must equal the tangent of theta(t), and Y(t) must be the Hilbert Transform of X(t). The actual values of X(t) and Y(t) do not matter, only that they have these two relationships. The only 'given' is theta(t). Does this make sense? Thanks! Catherine