在 python 中绘制图形和 fft
Plotting graph and fft in python
我有一列数据,大约 200 行。(1 个 D 数组)。但是这些数据是在大约 1 分钟的时间内获取的。
所以我需要绘制这个数据与时间图(数据与一分钟的总时间)并且还需要执行 FFT。
有什么办法吗?????
假设我们有一个名为 (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--')
我有一列数据,大约 200 行。(1 个 D 数组)。但是这些数据是在大约 1 分钟的时间内获取的。 所以我需要绘制这个数据与时间图(数据与一分钟的总时间)并且还需要执行 FFT。 有什么办法吗?????
假设我们有一个名为 (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--')