赞
踩
我有一个周期信号,我想找出周期。
由于存在边界效应,我首先去掉边界,通过观察第一个和最后一个极小值保持N个周期。在
然后,计算FFT。在
代码:import numpy as np
from matplotlib import pyplot as plt
# The list of a periodic something
L = [2.762, 2.762, 1.508, 2.758, 2.765, 2.765, 2.761, 1.507, 2.757, 2.757, 2.764, 2.764, 1.512, 2.76, 2.766, 2.766, 2.763, 1.51, 2.759, 2.759, 2.765, 2.765, 1.514, 2.761, 2.758, 2.758, 2.764, 1.513, 2.76, 2.76, 2.757, 2.757, 1.508, 2.763, 2.759, 2.759, 2.766, 1.517, 4.012]
# Round because there is a slight variation around actually equals values: 2.762, 2.761 or 1.508, 1.507
L = [round(elt, 1) for elt in L]
minima = min(L)
min_id = L.index(minima)
start = L.index(minima)
stop = L[::-1].index(minima)
L = L[start:len(L)-stop]<
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。