txt记录位置 c++,python显示位置
///c++ 寫/
std::ofstream lane_postion_log(ROOT_DIR"/build/lane_position_log.txt");//創建文件
lane_postion_log <<p.x<<","<<p.y<<","<<p.z<<endl;//寫位置
lane_postion_log.close();
?
//python顯示///
#!/usr/bin/python
# -*- coding: UTF-8 -*-
?
from numpy import *
import operator
from os import listdir
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.pyplot import MultipleLocator
import numpy as np
?
def file2matrix(filename):
fr = open(filename)
numberOfLines = len(fr.readlines()) #get the number of lines in the file
x = [] #prepare labels return
y = []
z = []
fr = open(filename)
index = 0
lineNum = 0
for line in fr.readlines():
line = line.strip()
listFromLine = line.split(',')
#print(listFromLine)
#returnMat[index,:] = listFromLine[0:1]
x.append(float(listFromLine[0])*-1)
y.append(float(listFromLine[1]))
z.append(float(listFromLine[2]))
#classLabelVector
index += 1
return x,y,z
?
x,y,z = file2matrix("../build/position.txt")
?
print( np.mean(x))
ax=plt.gca()
y_major_locator=MultipleLocator(10)
ax.yaxis.set_major_locator(y_major_locator)
?
plt.ylim(1250,1330)
plt.plot(x,'-')
plt.ylabel('x')
plt.show()
?
總結
以上是生活随笔為你收集整理的txt记录位置 c++,python显示位置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Delta3d动态角色层
- 下一篇: Springboot 集成 Swagge