Share

## Computing analytical signal using FFT in C++

ReportQuestion

I’m currently lost trying to figure out how to implement an equivalent version of MATLAB’s `hilbert()`

function in C++. I’m very new to signal processing, but, ultimately, I would like to figure out a way to phase shift any given signal by 90 degrees. I was attempting to follow the method suggested in this question on MATLAB central, which appears to work based on tests using GNU Octave.

I have what I believe to be a working implementation of both FFT and the inverse FFT, and I have tried implementing the method described in the answer to this post in order to compute the analytical signal. I have tried doing this by applying the FFT, setting the upper half of the array to zero, and then applying the inverse FFT, but, based on graphs I made of output from a test, there must be a problem with the way I have implemented finding the analytical signal.

What would be a suitable way to implement the `hilbert()`

function from MATLAB in C++ given a working implementation of FFT and inverse FFT? Is there a better way of achieving the 90 degree phase shift?

solved
0

7 days
1 Answer
6 views
0
## Answer ( 1 )

## Please briefly explain why you feel this answer should be reported .

Report CancelChecking the MATLAB implementation the following should return the same result as the

`hilbert`

function. You’ll obviously have to modify it to match your specific implementation. I’m assuming a`signal`

class of some sort exists.Edit: Forgot to set the second half to zeros.

Edit2: Fixed a logical error. I coded the following up in MATLAB which matches hilbert.