MATLAB Function Reference | Search  Help Desk |
save | See Also |
Save workspace variables on disk
save savefilename
savefilename
variables
savefilename
options
savefilename
variables
options
save,
by itself, stores all workspace variables in a binary format in the file named matlab.mat
. The data can be retrieved with load
.
save filename
stores all workspace variables in filename.mat
instead of the default matlab.mat
. If filename
is the special string stdio
, the save
command sends the data as standard output.
save filename
variables
saves only the workspace variables
you list after the filename
.
The forms of the save
command that use options
are:
save
filename
options
save
filename
variables
options
,
Each specifies a particular ASCII data format, as opposed to the binary MAT-file format, in which to save data. Valid option combinations are:filename
shown above results in a single workspace variable named filename
. Use the colon operator to access individual variables.
Saving complex data with the -ascii
keyword causes the imaginary part of the data to be lost, as MATLAB cannot load nonnumeric data ('i'
).
The save
and load
commands retrieve and store MATLAB variables on disk. They can also import and export numeric matrices as ASCII data files.
MAT-files are double-precision binary MATLAB format files created by the save
command and readable by the load
command. They can be created on one machine and later read by MATLAB on another machine with a different floating-point format, retaining as much accuracy and range as the disparate formats allow. They can also be manipulated by other programs, external to MATLAB.
Alternative syntax: The function form of the syntax, save('filename')
, is also permitted.
The binary formats used by save
depend on the size and type of each array. Arrays with any noninteger entries and arrays with 10,000 or fewer elements are saved in floating-point formats requiring eight bytes per real element. Arrays with all integer entries and more than 10,000 elements are saved in the formats shown, requiring fewer bytes per element.Element Range |
Bytes per Element |
0 to 255 |
1 |
0 to 65535 |
2 |
-32767 to 32767 |
2 |
-231+1 to 231-1 |
4 |
other |
8 |
fprintf
Write formatted data to file
fwrite
Write binary data to a file
load
Retrieve variables from disk