import numpy as np
import matplotlib.pyplot as pp
curve = np.genfromtxt('C:\Users\latel\Desktop\kool\Neuro\prax2\data\curve.csv',dtype = 'float', delimiter = ',')
curve_abs2 = np.empty_like(curve)
z = 1j
N = len(curve)
for i in range(0,N-1):
curve_abs2[i] =0
for k in range(0,N-1):
curve_abs2[i] += (curve[i]*np.exp((-1)*z*(np.pi)*i*((k-1)/N)))
for i in range(0,N):
curve_abs2[i] = abs(curve_abs2[i])/(2*len(curve_abs2))
#curve_abs = (np.abs(np.fft.fft(curve)))
#pp.plot(curve_abs)
pp.plot(curve_abs2)
pp.show()
#後面的代碼給了我3個值。但是,這只是......不同手冊FFT不給我相同的結果,FFT
錯誤^^驗證碼:http://www.upload.ee/image/3922681/Ex5problem.png
正確使用numpy.fft.fft():http://www.upload.ee/image/3922682/Ex5numpyformulas.png
工作很好,謝謝! :) – user3027316