12.07.2015 Views

GNU Octave - Local Sector 7 web page

GNU Octave - Local Sector 7 web page

GNU Octave - Local Sector 7 web page

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

118 <strong>GNU</strong> <strong>Octave</strong>There are three files that are always available. Although these files can be accessed usingtheir corresponding numeric file ids, you should always use the symbolic names given in thetable below, since it will make your programs easier to understand.stdinBuilt-in VariableThe standard input stream (file id 0). When <strong>Octave</strong> is used interactively, this isfiltered through the command line editing functions.stdoutThe standard output stream (file id 1).normally filtered through the <strong>page</strong>r.Built-in VariableData written to the standard output isstderrBuilt-in VariableThe standard error stream (file id 2). Even if paging is turned on, the standard erroris not sent to the <strong>page</strong>r. It is useful for error messages and prompts.16.2.1 Opening and Closing Files[fid, msg] = fopen (name, mode, arch)Built-in Functionfid list = fopen ("all")Built-in Functionfile = fopen (fid)Built-in FunctionThe first form of the fopen function opens the named file with the specified mode(read-write, read-only, etc.) and architecture interpretation (IEEE big endian, IEEElittle endian, etc.), and returns an integer value that may be used to refer to the filelater. If an error occurs, fid is set to −1 and msg contains the corresponding systemerror message. The mode is a one or two character string that specifies whether thefile is to be opened for reading, writing, or both.The second form of the fopen function returns a vector of file ids corresponding toall the currently open files, excluding the stdin, stdout, and stderr streams.The third form of the fopen function returns the name of a currently open file givenits file id.For example,myfile = fopen ("splat.dat", "r", "ieee-le");opens the file ‘splat.dat’ for reading. If necessary, binary numeric values will beread assuming they are stored in IEEE format with the least significant bit first, andthen converted to the native representation.Opening a file that is already open simply opens it again and returns a separate fileid. It is not an error to open a file several times, though writing to the same filethrough several different file ids may produce unexpected results.The possible values ‘mode’ may have are‘r’‘w’Open a file for reading.Open a file for writing. The previous contents are discared.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!