Desktop Tools and Development Environment |
The workspace is not maintained across MATLAB sessions. When you quit MATLAB, the workspace is cleared. You can save any or all of the variables in the current workspace to a MAT-file, which is a MATLAB specific binary file. You can then load the MAT-file at a later time during the current or another session to reuse the workspace variables. MAT-files use a .mat
extension.
Saving All Variables
To save all of the workspace variables using the Workspace browser,
You can also save the workspace variables from the desktop by selecting Save Workspace As from the File menu.
Saving Selected Variables
To save some but not all of the current workspace variables,
To specify preferences for saving MAT-files, see MAT-Files.
Function Alternative
To save workspace variables, use the save
function followed by the filename you want to save to. For example,
save('june10')
saves all current workspace variables to the file june10.mat
.
If you don't specify a filename, the workspace is saved to matlab.mat
in the current working directory. You can specify which variables to save, as well as control the format in which the data is stored, such as ASCII. For these and other forms of the function, see the reference page for save
. For a related function, see genvarname
. MATLAB provides additional functions for saving information--see Data Import and Export in the MATLAB Programming documentation.
Opening the Workspace Browser | Loading a Saved Workspace and Importing Data |
© 1994-2005 The MathWorks, Inc.