I m having trouble reading some fixed width (6E12) data from a text file. Notice that there are leading spaces in the file.
The first line isnt that important. However, starting on the 2nd line I want to read 59 values.
file.txt
PleaseAnswer 3 , ThisQuestion 40
0.00000E+00 4.78181E+01-4.76356E+01 3.76280E-01 0.00000E+00 1.59238E+00
1.88171E+00 1.73928E-06 0.00000E+00 3.57826E+01 0.00000E+00 0.00000E+00
0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00
0.00000E+00 3.75261E-07 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00
0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00
0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00
0.00000E+00 0.00000E+00 0.00000E+00 3.28103E+01 0.00000E+00 0.00000E+00
0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00
0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00
0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00
...
end file.txt
如下文所示,由于负面迹象,我遇到第2和第3数值的问题。 我完全理解为什么要有一个主要空间。 我的几乎所有数字都应有一个主要空间,但消极的空间除外。
me trying to read this file
fid = fopen(filename);
dontcare = textscan(fid, %s %d %s %s %n , 1);
fixme = textscan(fid, %12s , 59, Delimiter , , Whitespace , );
fixme{1}
ans =
0.00000E+00
4.78181E+01-
4.76356E+01
3.76280E-01
0.00000E+00
1.59238E+00
1.88171E+00
1.73928E-06
0.00000E+00
3.57826E+01
0.00000E+00
0.00000E+00
0.00000E+00
0.00000E+00
0.00000E+00
0.00000E+00
0.00000E+00
0.00000E+00
0.00000E+00
...