So I have a simulation to get Fourier Transform of an given array.
This is my Python code to get Fourier Transform
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal as signal
w1=np.arange(-2*np.pi,2*np.pi,0.01)
x = np.array([1,2,3,4,3,2,1])
#fourier transform
s=0
for n in range(len(x)-1):
s=s+(x[n+1]*np.exp(-1j*w1*n))
n=np.arange(len(x))
plt.figure(1)
plt.stem(n,x)
plt.title("Signal")
plt.figure(2)
plt.subplot(1,2,1)
plt.plot(w1,np.abs(s))
plt.title("Phase response")
plt.subplot(1,2,2)
plt.plot(w1,np.angle(s))
plt.title("Frequency Response")
plt.figure(3)
w,h=signal.freqz(x)
plt.subplot(2,1,1)
plt.plot(w, 20 * np.log10(abs(h)), 'b')
plt.subplot(2,1,2)
plt.plot(w, np.angle(h), 'g')
plt.suptitle("Frequency response")
I think I have got my fourier transform, but when I thy to do inverse Fourier Transform
#inverse fourier transform
s1=0
n1=np.arange(0,len(x))
for n in np.arange(0,len(s)-1):
s1=s1+(s[n]*(np.exp(1j*w1[n]*n1)))
s1=s1/(2*np.pi*200)
plt.figure(4)
n=range(len(s1))
plt.stem(n,s1)
I can't get the 1st element back
Anyway to get 1st element back.
(I know there is an command to get IFT but I have to do it without the command)