I'm trying to decompose some signal to even and odd components, here's the Python
code of it:
import numpy as np
t = np.linspace(0,1,64)
f = 2e6
test_signal = []
for i in range(len(t)):
test_signal.append(np.sin(2*np.pi*f*t)[i]+i*0.05)
plt.plot(t, test_signal)
which outputs the original signal:
but if I try to decompose it to even and odd components:
xe = []
xo = []
N = len(t)-1
for i in range(len(t)):
if i==0:
xe.append(test_signal[0])
xo.append(0)
else:
xe.append(0.5*(test_signal[i]+test_signal[N-i]))
xo.append(0.5*(test_signal[i]-test_signal[N-i]))
plt.plot(xe, label='even part')
plt.plot(xo, label='odd part')
plt.legend();
I get the following:
which is not equivalent to the original signal:
plt.plot(xe+xo)
what's wrong in my signal decomposition?