3 External file-I/O functions.

Contents of this section

This section describes functions from file files.ct.

3.1 export_matlab

[] = export_matlab(fn...)
 export_matlab("file") saves all variables in Tela
   workspace in "file". Any previous contents of "file"
   is overwritten. The data are written in MATLAB
   binary format.
   save("file","var1","var2"...) saves only the specified variables.
   Notice that you have to give the variable names as strings.

   The resulting MAT-file can be read using the
   MATLAB 'load' command.
   
   Limitations (bugs): It is not possible to export
   local variables. If you try, the global ones will
   be written, if they have numeric values.
   
   See also: save, load, import.
   Error codes:
   1: Too few arguments
   2: Argument not a string or char
   3: Write error on file
   

3.2 import

[] = import(filename)
 import("file") tries to load the contents of "file"
   into Tela workspace. All files accepted by load are
   also accepted by import. In addition import accepts
   more general HDF files and MATLAB binary files.
   Create these files using the MATLAB 'save' command.

   Restrictions:
   1) Only MATLAB files created on a similar
   architecture can be correctly imported. If this rule
   is not followed, the imported data will be garbage!
   2) MATLAB4.0 and higher saves arrays with more than
   10000 elements as various integer formats, if all
   elements are whole numbers. Tela cannot read these
   files. A workaround is to perturb one element in
   MATLAB before saving so that it is not exactly
   integer.

   For filename conventions, see load.
   See also: load, save, import1, export_matlab.

   (The difference between import and import1 is that
    import1 reads only one object and returns it, whereas
    import reads several objects and assigns them directly
    to workspace variables.)
   Error codes:
   1: Argument not string or char
   2: Argument is not an HDF file
   3: File not found
   4: Cannot import file
   5: Unused error message
   6: Cannot import this Matlab file (O(letter'Oh) != 0, (can even Matlab?))
   7: Cannot import this Matlab file (P != 0). Is your array size >10000 and all integer? Try perturbing it
   8: Cannot import this Matlab file (T != 0, 1). Is it a sparse matrix? Make it full
   10: Bad Matlab binary file, premature end of file
   

3.3 import1

[x] = import1(filename)
 import1("file") reads one object from "file".
   The imported object is returned.
   The "file" can be an HDF file, in which
   case the first Scientific Data Set (SDS) is
   loaded. The "file" can also be an ASCII file
   of the following format:
   
   (line 1)   D=Nt dim1 dim2 ... dimN
   (line 2)   data1 data2 ....

   where N is the rank of the dataset and t is an
   optionial type specification letter: t may be either
   'r', 'i', or 'c' for real, integer and complex data,
   respectively. If t is missing, real data are asssumed.

   See also: import, load, save. See 'help import' for
   a difference between import and import1.
   For filename conventions, see load.
   Error codes:
   -1: Input arg not a char or string
   -2: File not found
   -3: Unknown format in ASCII file
   -4: Unknown format in ASCII file
   -5: Too high rank ASCII data
   -6: Syntax error in ASCII file dimension specification
   -7: Syntax error when reading ASCII data
   -8: Internal error
   -9: Cannot import file
   

3.4 load

[] = load(filename)
 load("file") loads the contents of "file"
   in Tela workspace.
   "file" must have been previously created using
   the 'save' command; it must be in a certain
   HDF format.

   Filename conventions:
   If the filename starts with "/", "./" or "..",
   it is considered absolute. Otherwise it is searched
   along TELAPATH. This applies to other file
   operations as well.
   
   The counterpart of load is save.
   To read more general HDF files and ASCII files,
   see import1.
   To load more general HDF files and MATLAB binary
   files, see import.

   See also: save, import, import1, export_matlab.
   Error codes:
   1: Argument not string or char
   2: Argument is not an HDF file
   3: File not found
   

3.5 save

[] = save(fn...)
 save("file") saves all variables in Tela workspace
   in "file". Any previous contents of "file" is
   overwritten. The data are written as Scientific
   Data Sets in HDF format.
   save("file","var1","var2"...) saves only the
   specified variables. Notice that you have to give
   the variable names as strings.

   Limitations (bugs): It is not possible to save
   local variables, since they are not bound to
   symbols. If you try, the global one, if any,
   will be saved.
   
   See also: load, export_matlab.
   Error codes:
   1: Too few arguments
   2: Argument not a string or char
   3: Unexpected HDF error
   

Next Chapter, Previous Chapter

Table of contents of this chapter, General table of contents

Top of the document, Beginning of this Chapter