Data storage and retrieval
It is possible to store ScalaLab arrays as text files. It is also possible to read these files. The file format is very simple. This also lets you create text containing data using any tool you want and load it into ScalaLab as data, as long as you follow the file format that is used, of course. There are two functions for doing this. They are called readAscii
and saveAscii
. The signatures of those functions are given here:
saveAscii(d: Array[Double], fileName: String): Unit saveAscii(dd: Array[Array[Double]], fileName: String, sepChar: Char= ' '): Unit readD1Ascii( fileName: String): Array[Double] readD2Ascii(fileName: String): Array[Array[Double]]
The save
function takes an array of doubles and a filename. The data will be stored into the file specified. The other version of the save
function takes a 2-dimensional array and saves it to a specified file. You can also supply a separator symbol to be used. The default separator is the space. Let's see how this works...