Contents Previous Next Subchapters

Reading A Specified Number Of Rows From A File
Syntax read(filemtypenr)
See Also read(file, mtype) , bread(file) , and read(file, mtype, nr, nc)

Reads values from the specified file and returns a matrix of the specified type with the specified number of rows. The arguments file and mtype have the same meaning as in read(file, mtype) . The integer scalar nr specifies the number of rows to read and return. The number of columns in the returned matrix equals the number of columns in the first row read. All rows read from file must contain the same number of columns. The first row of the resulting matrix corresponds to the first values read, the next row to the next values read, and so on.

You can create a file called complexvals.dat that contains the text representation of the following complex values
     (1,2) (3,4) (5,6)
     (7,8) (9,10) (11,12)
by entering the following commands
     file = "complexvals.dat"
     write(file, "(1,2) (3,4) (5,6)")
     write(file, "(7,8) (9,10) (11,12)")
If you then enter
     read("complexvals.dat", "complex", 2)
O-Matrix will respond
     [ (1,2) , (3,4) , (5,6) ]
     [ (7,8) , (9,10) , (11,12) ]