The save
and load
commands allow data to be written to and
read from disk files in various formats. The default format of files
written by the save
command can be controlled using the built-in
variables default_save_format
and save_precision
.
Note that Octave cannot yet save or load structure variables or any user-defined types.
save options file v1 v2 ... | Command |
Save the named variables v1 v2, ... in the file
file. The special filename - can be used to write the
output to your terminal. If no variable names are listed Octave saves
all the variables in the current scope. Valid options for the
save command are listed in the following table. Options that
modify the output format override the format specified by the built-in
variable default_save_format .
The list of variables to save may include wildcard patterns containing the following special characters:
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 The command save -binary data a b* saves the variable |
There are three variables that modify the behavior of save
and
three more that control whether variables are saved when Octave exits
unexpectedly.
crash_dumps_octave_core | Built-in Variable |
If this variable is set to a nonzero value Octave tries to save all current variables the the file "octave-core" if it crashes or receives a hangup terminate or similar signal. The default value is 1. |
sighup_dumps_octave_core | Built-in Variable |
If this variable is set to a nonzero value and
crash_dumps_octave_core is also nonzero Octave tries to save all
current variables the the file "octave-core" if it receives a
hangup signal. The default value is 1.
|
sigterm_dumps_octave_core | Built-in Variable |
If this variable is set to a nonzero value and
crash_dumps_octave_core is also nonzero Octave tries to save all
current variables the the file "octave-core" if it receives a
terminate signal. The default value is 1.
|
default_save_format | Built-in Variable |
This variable specifies the default format for the save command.
It should have one of the following values: "ascii"
"binary" float-binary , or "mat-binary" . The
initial default save format is Octave's text format.
|
save_precision | Built-in Variable |
This variable specifies the number of digits to keep when saving data in text format. The default value is 17. |
save_header_format_string | Built-in Variable |
This variable specifies the the format string for the comment line
that is written at the beginning of text-format data files saved by
Octave. The format string is passed to strftime and should
begin with the character # and contain no newline characters.
If the value of save_header_format_string is the empty string
the header comment is omitted from text-format data files. The
default value is
"# Created by Octave VERSION %a %b %d %H:%M:%S %Y %Z <USER@HOST>" |
load options file v1 v2 ... | Command |
Load the named variables from the file file. As with save
you may specify a list of variables and load will only extract
those variables with names that match. For example to restore the
variables saved in the file data use the command
load data 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. Since it seems that both of these cases are likely to be the result of some sort of error they will generate warnings. 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 The Valid options for
|