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.

Scilab: Increase stacksize

stacksize()

This command will return two numbers. The first one is the current stacksize, and the second one is how much in use. One can give these values to a variable by

v = stacksize()

To increase the stacksize, use

stacksize(n)

where n is a number that is the stacksize that one wants to set.