2010年4月16日星期五

Scilab: Read file

When the data file is too large, one cannot read all of them into stack. Instead one has to read line by line and only put those usefull data into stack. To read a data file line by line, one can do it in the following way.

fid = mopen('D:\WORK\pe1.TXT', "r");
while (done_yet == 0);
[num_read, val(1), val(2)] = mfscanf(fid, "%f %f");

... ...

if (num_read <= 0);
done_yet = 1;
end
end;

Firstly, open the file.
Then read data in format from one line.
Deal with the data.
If the file is not end, continue reading.

没有评论:

发表评论