【问题标题】:Plotting graph and fft in python在python中绘制图形和fft
【发布时间】:2017-03-30 23:33:41
【问题描述】:

我有一列的数据,大约 200 行。(1 个 D 数组)。但这些数据的采集时间约为 1 分钟。 所以我需要绘制这个数据与时间图(数据与一分钟的总时间)并且还需要执行 FFT。 有什么可能的方法??????

【问题讨论】:

  • 您已经尝试过哪些方法?在这里提供代码是非常必要的。
  • 你可以在docs.scipy.org/doc/numpy/reference/routines.fft.html找到几种计算fft的方法
  • 我真的没有任何想法来做这个任何想法!!!!!!!!!!!!
  • 我还需要知道如何根据 1 分钟的总时间绘制数据。

标签: python matplotlib scipy signal-processing fft


【解决方案1】:

假设我们有一个名为 (x,y) 的数据集,我们想要拟合一条曲线,例如 y=asin(bx+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--')

【讨论】:

  • func() 中的第一个参数是 x 值
猜你喜欢
  • 2017-03-21
  • 1970-01-01
  • 2015-10-03
  • 2011-01-04
  • 2021-06-05
  • 1970-01-01
  • 2016-11-14
  • 2016-07-06
  • 2018-05-20
相关资源
最近更新 更多