How to properly scale frequency axis in Fast Fourier Transform?
问题 I am trying some sample code taking the FFT of a simple sinusoidal function. Below is the code import numpy as np from matplotlib import pyplot as plt N = 1024 limit = 10 x = np.linspace(-limit, limit, N) dx = x[1] - x[0] y = np.sin(2 * np.pi * 5 * x) + np.sin(2 * np.pi * x) Y = np.abs(np.fft.fft(y) ** 2) z = fft.fftshift(np.fft.fftfreq(N, dx)) plt.plot(z[int(N/2):], Y[int(N/2):]) plt.show() From the function that is given, , it is clear there should be two spikes at frequencies 1 and 5.