Save the named variables v1, v2, ..., in the file file. The special filename ‘-’ may be used to write the output to your terminal. If no variable names are listed, Octave saves all the variables in the current scope. If the
-struct
modifier is used, fields f1 f2 ... of the scalar structure STR are saved as if they were variables with corresponding names. Valid options for thesave
command are listed in the following table. Options that modify the output format override the format specified bydefault_save_options
.If save is invoked using the functional form
save ("-option1", ..., "file", "v1", ...)then the options, file, and variable name arguments (v1, ...) must be specified as character strings.
-ascii
- Save a single matrix in a text file.
-binary
- Save the data in Octave's binary data format.
-float-binary
- Save the data in Octave's binary data format but only using single precision. You should use this format only if you know that all the values to be saved can be represented in single precision.
-V7
-v7
-7
-mat7-binary
- Save the data in Matlab's v7 binary data format.
-V6
-v6
-6
-mat
-mat-binary
- Save the data in Matlab's v6 binary data format.
-V4
-v4
-4
-mat4-binary
- Save the data in the binary format written by Matlab version 4.
-hdf5
- Save the data in HDF5 format. (HDF5 is a free, portable binary format developed by the National Center for Supercomputing Applications at the University of Illinois.)
HDF5 load and save are not available, as this Octave executable was not linked with the HDF5 library.
-float-hdf5
- Save the data in HDF5 format but only using single precision. You should use this format only if you know that all the values to be saved can be represented in single precision.
-zip
-z
- Use the gzip algorithm to compress the file. This works equally on files that are compressed with gzip outside of octave, and gzip can equally be used to convert the files for backward compatibility.
The list of variables to save may include wildcard patterns containing the following special characters:
?
- Match any single character.
*
- Match zero or more characters.
[
list]
- Match the list of characters specified by list. If the first character is
!
or^
, match all characters except those specified by list. For example, the pattern ‘[a-zA-Z]’ will match all lower and upper case alphabetic characters.Wildcards may also be used in the field names specifications when using the
-struct
modifier (but not in the struct name itself).-text
- Save the data in Octave's text data format.
Except when using the Matlab binary data file format, saving global variables also saves the global status of the variable, so that if it is restored at a later time using ‘load’, it will be restored as a global variable.
The command
save -binary data a b*saves the variable ‘a’ and all variables beginning with ‘b’ to the file data in Octave's binary format.