invert this matlab code into a python code x=signal-meansignal;预处理去除直流分量;x=xmaxx;归一化y=fftxN;做FFT变换y1=absy; 取模ayy=y1N2;换算成实际的幅度ayy1=ayy12;
import numpy as np
signal = np.array([1, 2, 3, 4, 5]) # example signal N = len(signal)
x = signal - np.mean(signal) # remove DC component x = x / np.max(x) # normalize
y = np.fft.fft(x, N) # FFT y1 = np.abs(y) # take magnitude ayy = y1 / (N/2) # convert to actual amplitude ayy[0] = ayy[0] / 2 # adjust DC component amplitude
原文地址: https://www.cveoy.top/t/topic/cPe1 著作权归作者所有。请勿转载和采集!