我在磁盘上有一个数据集,我正在逐行读取,我想将其中一列数据转换为浮点向量(范围为 0-23.99999)(那天)。
数据如下所示:
2010/01/01,00:00:00.979131, 27.4485, 51.9362, 14.8, 6
2010/01/01,00:00:01.021977, 27.5149, 51.9375, 16.0, 6
2010/01/01,00:00:01.074032, 27.4797, 51.9446, 14.5, 10
2010/01/01,00:00:01.663689, 25.8441,-152.8141, 14.6, 6
2010/01/01,00:00:01.639541, 25.8744,-152.6122, 1.5, 5
2010/01/01,00:00:02.232099, -2.2447, 11.5023, 18.8, 6
2010/01/01,00:00:02.256351, -0.8135, 27.3139, 17.7, 5
2010/01/01,00:00:02.306734, -2.7797, 28.5109, 26.0, 5
2010/01/01,00:00:02.620765, 25.6656,-154.2029, 26.2, 9
2010/01/01,00:00:02.658495, 25.6698,-154.2157, 23.0, 6
2010/01/01,00:00:02.731266, -5.7106, 126.4517, 3.6, 5
2010/01/01,00:00:02.787495, -5.7138, 126.5210, 24.4, 8
2010/01/01,00:00:02.811636, -3.2453, 124.6919, 21.1, 8
第 2 列(例如,00:00:00.979131)很有趣,我想做类似的事情
setenv GNUTERM 'x11';
fid = fopen('myfile.txt', 'r');
m = textscan(fid, '%d%d%d%d/%d%d/%d%d, %d%d:%d%d:%d%f, %f, %f, %f, %d');
mx = m(:, 5); %here, I would expect to grab 14.8, 16.0, etc
my = m(:, 2) / 24.0; %here, all data from timestamp column (00:00:00.979131, for ex)
plot(mx, my);
问题是我传递给textscan
我的数据的字符串格式错误。该数字的格式为“时:分:秒”,以军用时间表示。如何访问/转换 vars 的值mx
,或者my
?
谢谢,jml