我对matlab很新颖。我一直在阅读文档,但可以找出为什么matlab不能正确读取文件中的字符串。我想要做的是从文件中读取混合的数据类型。一些示例数据是:从文件读取混合数据的matlab
t a e incl lasc aper meanan truean rupnode rdnnode name
0.000000 1.2712052487 0.8899021688 22.2458 265.2511471042 322.1539251184 -13.6281352271 -130.986 0.155342 0.889756 phaet_000018
0.000000 1.2712052478 0.8899021575 22.2458 265.2511428392 322.1539270642 -13.6281369694 -130.986 0.155342 0.889756 phaet_000044
0.000000 1.2712052496 0.8899021868 22.2458 265.2511587897 322.1539149438 -13.6281365049 -130.986 0.155342 0.889755 phaet_000006
第一行是标题。所以这是我迄今所做的:
fid = fopen('data.dat');
header = fgetl(fid); # I read the header
Now I read the data:
data = fscanf(fid,'%f %f %f %f %f %f %f %f %f %f %s',[11 inf]);
data1 = data';
fclose(fid);
我现在可以作为访问的第一要素:
data1(1,1)
然而,当我这样做:
data(1,11)
,而不是phaet_000018
我得到一个数字(112)。任何想法我做错了什么?
把矩阵负荷的打印在MATLAB – 16per9
我很抱歉,我没”没有那个。你能否详细说明一下? – user3578925