Red de conocimiento informático - Material del sitio web - Cómo implementar la transformada rápida de Fourier en Python

Cómo implementar la transformada rápida de Fourier en Python

Referencias:

matplotlib inline

importar numpy como np

importar matplotlib.pyplot como plt

importar scipy.fftpack

# Número de puntos de muestreo

N = 600

# Intervalo de muestreo

T = 1,0 / 800,0

x = np.linspace(0.0, N*T, N)

y = np.sin(50.0 * 2.0*np.pi*x) 0.5*np.sin(80.0 * 2.0 * np.pi*x)

yf = scipy.fftpack.fft(y)

xf = np.linspace(0.0, 1.0/(2.0*T), N/2 )

fig, ax = plt.subplots()

ax.plot(xf, 2.0/N * np.abs(yf[:N//2]))

plt.show()