Is it possible to save data in my MATLAB GUI and retrieve that data the next time I open the GUI?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
When I close my GUI, I would like to save the information that is contained in some of my UICONTROLS and then have that data available when I run the GUI again. I would like to know if there is an option in GUIDE that will allow me to do this.
Akzeptierte Antwort
MathWorks Support Team
am 20 Jan. 2010
This ability is not directly available in MATLAB.
As a workaround, you can save the data to a MAT file which can be loaded when the GUI is opened.
The attached files contain a basic example with a slider and an edit text box in the GUI. When the CloseRequestFcn is called on the GUI to end a session, values of the the editbox 'String' property and the slider 'Value' property will be saved to a MAT file. When the next GUI session is opened, the values will be loaded and used to set the GUI properties.
Please run the attached GUI by downloading the files to your MATLAB path and typing 'preference_saving_gui' at the MATLAB command prompt. After the GUI appears, make changes to the text box and slider control. Then close the GUI and notice that a MAT file has been created containing the saved property values. Rerun the file, and note that the old setting should be loaded. The command window will show messages indicating what has happened when opening and closing the GUI.
Please see the following functions in the attached GUI program file to understand how this GUI was implemented:
1) edit1_Callback
2) slider1_Callback
3) figure1_CloseRequestFcn
4) preference_saving_gui_OpeningFcn
Attached Files:
1) preference_saving_gui.m
2) preference_saving_gui.fig
Another example that also implements the similar behavior but in a slightly different manner:
1) reloading_param.fig
2) reloading_param.m
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!