繁体   English   中英

在python中绘制图形和fft

[英]Plotting graph and fft in python

我有一列数据,大约 200 行。(1 维数组)。 但是这些数据是在大约 1 分钟的时间内获取的。 所以我需要绘制这个数据与时间图(数据与一分钟的总时间)并且还需要执行 FFT。 任何可能的方法????

让我们假设我们有一个名为 (x,y) 的数据集,我们想要拟合一条像 y=a sin(b x+c) 这样的曲线来拟合,你需要这样的东西

 from scipy.optimize import curve_fit

    def func(a,b,c,x):
"""We define the kind of function we want to fit"""  
        return a*np.sin(b*x+c)  

result = curve_fit(func, x, y) #func uses the function defined before, x and y are data points.
result[0] #array of the values
result[1] #covariance matrix

然后,如果你想用 matplotlib 绘制它

import numpy as np
import matplotlib.pyplot as plt    

plt.plot(x,result[0]*np.sin(result[1]*x+result[2]), 'g--')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM