The following is working fine when reading a data file of "1.2D+02 3.23D+01 ...." in matlab;
tempvs = textscan ( input_unit, '%f', N );
tempvs = cell2mat(tempvs);
tempvs = double(tempvs);
But, the same would not work (does not recognize "D" numbers) in octave (ver. 3.8.2) so i modified a little like the following;
tempvs = textscan ( input_unit, '%s', N );
tempvs = cell2mat(tempvs);
values = zeros(N,1);
for i = 1: N
values(i) = str2num(tempvs{i,1});
end
Is there other efficient way to do the job? Thanks in advance for youe help.
NOTE: changing data file into "1.2E+02 3.23E+01 ...." form is not an option, already tried line-by-line reading using fgetl but its slow.
fopen
the file, read all at oncefread(fid, "char=>char").'
and trytextscan ( regexprep(input_unit,"D","E"), '%f' )
when your file looks likeinput_unit="1.2D+02 3.23D+01"
everywhere. This should be blazing fast as long as your file fits into your RAM. But I dunno whatD
numbers are?