Contents Previous Next Subchapters

Writing a Matrix to the Screen or a File
Syntax write(filematrix)
See Also print , read , gsave , bread , bwrite , and write(file, matrix, max)

Writes matrix to the specified file or the screen, where file is a character row vector.

Each element is written using the same format as described in the floating point and integer format sections.

The brackets, braces, and commas that the print statement displays are not included. A single space is included between each value in a row unless matrix is a character matrix. Each row of the matrix corresponds to a line in file.

If there is no file named TEMP.OMS in the current directory, and you enter
     z = {[0r0, 1i0], [1r0, 1r0 + 1i0]}
     write("TEMP.OMS", z)
the file TEMP.OMS will be created and will contain the complex valued matrix
     / 0   i  \
     \ 1  1+i /

If there is a file named TEMP.OMS in the current directory, the example above will append the matrix to TEMP.OMS.

Continuing the previous example, you can view TEMP.OMS by selecting "File | Open Program" and choosing TEMP.OMS from the file browser, which will then display the following:
     (0,0) (0,1)
     (1,0) (1,1)

If file is "screen", O-Matrix writes the matrix to the command output window.
     x = {[1, 2], [3, 4]}
     write("screen", x)
results in
     1 2
     3 4