读取.csv文件

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%读取.csv文件中的groudTruth,保存时间戳和pose
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 close all;clc;clear;
 file_name1 = '/data.csv';
 savepath =  '/out.txt';
 data1 = csvread(file_name1, 1, 0);%读取第1行以下,第0列以右区域的数据;  csvread仅能读取纯数字
 [m1,n1] = size(data1);
 
 fid = fopen(savepath,'wt');
 for i = 1:m1
    fprintf(fid,'%f %f %f %f %f %f %f %f\n',data1(i,1)/1e9,data1(i,2),data1(i,3),data1(i,4),data1(i,6),data1(i,7),data1(i,8),data1(i,5));
 end
 fclose(fid); 

 

输入文件data.csv格式:

#timestamp, p_RS_R_x [m], p_RS_R_y [m], p_RS_R_z [m], q_RS_w [], q_RS_x [], q_RS_y [], q_RS_z [], v_RS_R_x [m s^-1], v_RS_R_y [m s^-1], v_RS_R_z [m s^-1], b_w_RS_S_x [rad s^-1], b_w_RS_S_y [rad s^-1], b_w_RS_S_z [rad s^-1], b_a_RS_S_x [m s^-2], b_a_RS_S_y [m s^-2], b_a_RS_S_z [m s^-2]
1403636580838555648,4.688319,-1.786938,0.783338,0.534108,-0.153029,-0.827383,-0.082152,-0.027876,0.033207,0.800006,-0.003172,0.021267,0.078502,-0.025266,0.136696,0.075593
1403636580843555328,4.688177,-1.786770,0.787350,0.534640,-0.152990,-0.826976,-0.082863,-0.029272,0.033992,0.804771,-0.003172,0.021267,0.078502,-0.025266,0.136696,0.075593
1403636580848555520,4.688028,-1.786598,0.791382,0.535178,-0.152945,-0.826562,-0.083605,-0.030043,0.034999,0.808240,-0.003172,0.021267,0.078502,-0.025266,0.136696,0.075593
1403636580853555456,4.687878,-1.786421,0.795429,0.535715,-0.152884,-0.826146,-0.084391,-0.030230,0.035853,0.810462,-0.003172,0.021267,0.078502,-0.025266,0.136696,0.075593
1403636580858555648,4.687727,-1.786240,0.799484,0.536244,-0.152821,-0.825731,-0.085213,-0.029905,0.036316,0.811406,-0.003172,0.021267,0.078502,-0.025266,0.136696,0.075593
1403636580863555328,4.687579,-1.786059,0.803540,0.536768,-0.152768,-0.825314,-0.086049,-0.029255,0.036089,0.811225,-0.003172,0.021267,0.078502,-0.025266,0.136696,0.075593
1403636580868555520,4.687435,-1.785881,0.807594,0.537289,-0.152725,-0.824896,-0.086890,-0.028469,0.035167,0.810357,-0.003172,0.021267,0.078502,-0.025266,0.136696,0.075593
1403636580873555456,4.687295,-1.785709,0.811642,0.537804,-0.152680,-0.824481,-0.087725,-0.027620,0.033777,0.808910,-0.003172,0.021267,0.078502,-0.025266,0.136696,0.075593

 

输出文件out.txt文件格式:

# ground truth trajectory
# timestamp tx ty tz qx qy qz qw
1403636580.838556 4.688319 -1.786938 0.783338 -0.153029 -0.827383 -0.082152 0.534108
1403636580.843555 4.688177 -1.786770 0.787350 -0.152990 -0.826976 -0.082863 0.534640
1403636580.848556 4.688028 -1.786598 0.791382 -0.152945 -0.826562 -0.083605 0.535178
1403636580.853555 4.687878 -1.786421 0.795429 -0.152884 -0.826146 -0.084391 0.535715
1403636580.858556 4.687727 -1.786240 0.799484 -0.152821 -0.825731 -0.085213 0.536244
1403636580.863555 4.687579 -1.786059 0.803540 -0.152768 -0.825314 -0.086049 0.536768
1403636580.868556 4.687435 -1.785881 0.807594 -0.152725 -0.824896 -0.086890 0.537289
1403636580.873555 4.687295 -1.785709 0.811642 -0.152680 -0.824481 -0.087725 0.537804

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值