Navigation

Operators and Keywords

Function List:

C++ API

: load file
: load options file
: load options file v1 v2 …
: S = load ("options", "file", "v1", "v2", …)
: load file options
: load file options v1 v2 …
: S = load ("file", "options", "v1", "v2", …)

Load the named variables v1, v2, …, from the file file.

If no variables are specified then all variables found in the file will be loaded. As with save, the list of variables to extract can be full names or use a pattern syntax. The format of the file is automatically detected but may be overridden by supplying the appropriate option.

If load is invoked using the functional form

load ("-option1", …, "file", "v1", …)

then the options, file, and variable name arguments (v1, …) must be specified as character strings.

If a variable that is not marked as global is loaded from a file when a global symbol with the same name already exists, it is loaded in the global symbol table. Also, if a variable is marked as global in a file and a local symbol exists, the local symbol is moved to the global symbol table and given the value from the file.

If invoked with a single output argument, Octave returns data instead of inserting variables in the symbol table. If the data file contains only numbers (TAB- or space-delimited columns), a matrix of values is returned. Otherwise, load returns a structure with members corresponding to the names of the variables in the file.

The load command can read data stored in Octave’s text and binary formats, and MATLAB’s binary format. If compiled with zlib support, it can also load gzip-compressed files. It will automatically detect the type of file and do conversion from different floating point formats (currently only IEEE big and little endian, though other formats may be added in the future).

Valid options for load are listed in the following table.

-force

This option is accepted for backward compatibility but is ignored. Octave now overwrites variables currently in memory with those of the same name found in the file.

-ascii

Force Octave to assume the file contains columns of numbers in text format without any header or other information. Data in the file will be loaded as a single numeric matrix with the name of the variable derived from the name of the file.

-binary

Force Octave to assume the file is in Octave’s binary format.

-hdf5

Force Octave to assume the file is in HDF5 format. (HDF5 is a free, portable binary format developed by the National Center for Supercomputing Applications at the University of Illinois.) Note that Octave can read HDF5 files not created by itself, but may skip some datasets in formats that it cannot support. This format is only available if Octave was built with a link to the HDF5 libraries.

-import

This option is accepted for backward compatibility but is ignored. Octave can now support multi-dimensional HDF data and automatically modifies variable names if they are invalid Octave identifiers.

-mat
-mat-binary
-6
-v6
-7
-v7

Force Octave to assume the file is in MATLAB’s version 6 or 7 binary format.

-mat4-binary
-4
-v4
-V4

Force Octave to assume the file is in the binary format written by MATLAB version 4.

-text

Force Octave to assume the file is in Octave’s text format.

See also: save, dlmwrite, csvwrite, fwrite.

Package: octave