可以考虑用textread,帮助里面有例子
Example 2 — Read as Fixed Format File, Ignoring the Floating Point Value
The first line of mydata.dat is
Sally Level1 12.34 45 Yes
Read the first line of the file as a fixed format file, ignoring the floatin
g-point value.
[names, types, y, answer] = textread('mydata.dat', ...
'%9c %6s %*f %2d %3s', 1)
returns
names =
Sally
types =
'Level1'
y =
45
answer =
'Yes'
%*f in the format string causes textread to ignore the floating point value,
in this case, 12.34.
【 在 toohardtogo (easy) 的大作中提到: 】
: 有一个文本文件,里面的格式如下所示:
: rrw, file order = 1,
: 379.81 379.81 100.41 100.41 257.15 379.81 379.81
: ...................