用textread函数
这是例子的一部分:
Examples:
Suppose the text file mydata.dat contains data in the following form:
Sally Type1 12.34 45 Yes
Joe Type2 23.54 60 No
Bill Type1 34.90 12 No
Read each column into a variable
[names,types,x,y,answer] = textread('mydata.dat','%s%s%f%d%s');
后面格式那部分,跟C语言的printf的格式字符串用法一样。
温馨提示:答案为网友推荐,仅供参考