renwoxing
2010-04-05, 10:56
data.txt中的数据100.21,95.182,108.86,0.7403,0.13664,0.43116,3.6808,3.5738,3.8024
105.94,105.31,109.64,0.58749,0.064417,0.43587,3.3384,3.3047,3.3724
105.18,104.45,108.92,0.58801,0.068022,0.43331,3.3954,3.3529,3.4202
程序为:
fid = fopen('data.txt');
a = fscanf(fid,'%c',[9 3]) % It has two rows now.
fclose(fid)
运行结果为:char型,数据不对
a =
1.8,0.7419748,..50..32
1.533362169933.
0160.63
0.417331,.049914412,.612964,.3
08,.48815697,.7815635,1.8,,355,4871363
.20130,0.4,,332,08834374,00.561.743.65
2,.318353,00.0418803,..80..53
1626,53,
11761,..10..34
0.021340,.0443149,,3459
,0466389,.043714912,.2916998,1.,00.8
3
9804,.0415638,0.2,,330,296393760..559.
5.3,352,08454354,00.5214684,..,.044,34
我该用怎样将数据正确的读到一个数组中?
谢谢高手指点!
我知道用dlmread可以读出来,但是想弄明白fscanf的用法!
105.94,105.31,109.64,0.58749,0.064417,0.43587,3.3384,3.3047,3.3724
105.18,104.45,108.92,0.58801,0.068022,0.43331,3.3954,3.3529,3.4202
程序为:
fid = fopen('data.txt');
a = fscanf(fid,'%c',[9 3]) % It has two rows now.
fclose(fid)
运行结果为:char型,数据不对
a =
1.8,0.7419748,..50..32
1.533362169933.
0160.63
0.417331,.049914412,.612964,.3
08,.48815697,.7815635,1.8,,355,4871363
.20130,0.4,,332,08834374,00.561.743.65
2,.318353,00.0418803,..80..53
1626,53,
11761,..10..34
0.021340,.0443149,,3459
,0466389,.043714912,.2916998,1.,00.8
3
9804,.0415638,0.2,,330,296393760..559.
5.3,352,08454354,00.5214684,..,.044,34
我该用怎样将数据正确的读到一个数组中?
谢谢高手指点!
我知道用dlmread可以读出来,但是想弄明白fscanf的用法!