直接上代码
import pyqtgraph.examples
import sys
from scipy.fftpack import fft,ifft
import matplotlib.pyplot as plt
from scipy import signal
import scipy as scipy
import pyqtgraph.opengl as gl
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
import sys
rootPath = "E:/MATLAB/0920/"#数据所在的根目录
#查询一分钟数据中的几秒数据
def getOneMinutesSecondData(arr,startSecond,endSecond):
if endSecond == 0:
endSecond = 60
beginIndex = startSecond*10240
print('begin: '+str(beginIndex))
endIndex = beginIndex+(endSecond-startSecond)*10240
print('end: '+str(endIndex))
return arr[beginIndex:endIndex]
def get_mse(records_real, records_predict):
"""
均方误差 估计值与真值 偏差
"""
if len(records_real) == len(records_predict):
return sum([(x - y) ** 2 for x, y in zip(records_real, records_predict)]) / len(records_real)
else:
return None
以上代码是导入的包以及常用方法的加载
carData= np.loadtxt(rootPath + 'carData.txt')
car = carData[10240*17:10240*17+51200]
dataF= np.loadtxt(rootPath + 'data.txt')
dataF = getOneMinutesSecondData(dataF,3,8)
以上代码是加载需要画图的数据
arr = np.zeros(1)
arrSplitData = carData
lenthData = len(arrSplitDa