View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

5.0 | 1 rating Rate this file 5 Downloads (last 30 days) File Size: 5.58 KB File ID: #37486 Version: 1.5
image thumbnail




13 Jul 2012 (Updated )

Saves and restores the MATLAB State (e.g. editor files, breakpoints, figures, variables, etc.)

| Watch this File

File Information

This script is designed to to save and restore the working state of MATLAB. This has only been tested on MATLAB version R2007a to R2011a, and it uses some undocumented features of MATLAB and might not work correctly for other versions.

When this script is called with the 'save' flag, it will ask for a location and file name to save the MATLAB state to. It will then proceed to save the current working directory, additional paths that differ from MATLAB root, open editor files, debug break points, open figures, base workspace variables, and command window history (this is not the same as the command history).

When this script is called with the 'restore' flag, it will open and GUI asking for the mState file to restore the MATLAB state from. All editor windows will then be closed, all debug break points will be removed, the command window will be cleared, all open figures will be closed, and all base workspace variables will be deleted before restoring the state. The script will then restore from the mState file the current working directory, addition paths other than MATLAB root, open editor windows, debug break points, open figures, base workspace variables, and commend window text history.

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
23 Oct 2012 Paul Shoemaker

It throws an error in R2011b when I try to save a session and the Editor is closed; apparently it's looking for a getActiveEditor handle that doesn't exist or is empty (line 121).

Comment only
17 Jul 2012 Paul Shoemaker

This is a fantastic capability. It even works for restoring GUIs, something I've been looking for lately.

This opens up a lot of possibilities, including modifying it and building it into my GUIs to allow a user to save and restore their work (not the entire Matlab session, just the GUI stuff).

Job very well done!

26 Jun 2013 1.5

Fixed an error that was caused by saving the MATLAB state when the editor was closed.

Contact us