欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

txt记录位置 c++,python显示位置

发布时间:2024/8/23 31 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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显示位置的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。