Saving the State of a GUI
(Originally posted on Doug's MATLAB Video Tutorials blog.)
A question that comes across my inbox from time to time is how to save the state of a GUI between session. There are few methods for doing this, one is using the HGSAVE command to save the .FIG file for the GUI. This can be done in a way that modifies the original .FIG file, or you can save a different one. Another way is to explicitly query each of the UICONTROLS for their value and then save those values in a structure. You can later reload and set the values. Personally, I am very willing to do more typing to get explicit control over activities like this. The saved state .MAT file is very readable, and would allow you to save state that might not be reflected in the UICONTROLS. Also, this helps to keep the saved data separate from the files that create GUI components. The modular architecture is appealing. Finally, for people that are building their entire GUI programmatically (that is, using UICONTROL to position widgets instead of GUIDE) this method is really useful because you do not ever really load a .FIG file.
Also, be sure to take some time to explore the new look of the File Exchange. Lots of new features.
Recorded: 31 Oct 2008
Featured Product
MATLAB
Up Next:
Related Videos:
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)