I have a question about the following codes for measuring analytic signal (Hilbert transform). Here,the time domain signal (x) is a real value signal. After making fft it becomes complex (X). Then it is multiplied by h (a real vector with the same size as X, and having real number in upper half and 0 in the bottom half). X*.h is complex obviously. Then we made ifft on X*.h , but surprisingly the output is again a complex signal (while we expected it to be real). How did that happen? Can anybody please explain it to me? Is h doing something special?
In other words, we multiply the real signal with exp-j(2*pi/k) during fft, and multiply it one more time with exp
j(2*pi/k) during ifft. These two should kill each other and give us a real output, isn't it?
def main(): t = np.arange(start=0,stop=0.5,step=0.001) x = np.sin(2*np.pi*10*t) z = analytic_signal(x) def analytic_signal(x): from scipy.fftpack import fft,ifft N = len(x) X = fft(x,N) h = np.zeros(N) h = 1 h[1:N//2] = 2*np.ones(N//2-1) h[N//2] = 1 Z = X*h z = ifft(Z,N) return z if __name__ == '__main__': main()