如下的写法是错误的!!!(修订版后续给出)
def fft_(signal, fs):
if not fs:
raise ValueError("The sampling frequency must be given !")
L = len(signal)
PL = abs(np.fft.fft(signal / L))[: int(L / 2)]
PL[0] = 0
f = np.fft.fftfreq(L, 1 / fs)[: int(L / 2)]
return f, PL