Permanently updating the value of an Edit Text box to input values with a push button
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
My GUI uses several Edit Text boxes for setting numeric variables that are used within my main code. Because certain parameters may change and shall be specified by the user, I need a way of saving new values into these Edit Text boxes and keeping them permanently i.e. keep the values that the user enters even if I close MATLAB and open it again etc.
So far I have managed to set the String property of my Mass_tb Edit Text handle using the “set” function to set its string to the variable “var”. This happens when a push button with the tag “SetDynDef_pb” is pressed:
function SetDynDef_pb_Callback(hObject, eventdata, handles) get(handles.AvT_cb,'value'); var = get(handles.Mass_tb,'string'); set(handles.Mass_tb,'String',var);
This does update the value of the string to the correct value when I run the code once, but when I close the GUI and run the program again, the value changes back to what I initially set in the Property Inspector from GUIDE (when I built the GUI). I need it to keep the value specified with var from previous runs when the user presses the push button.
Is this doable? I’m sure there’s a way but I only just started with matlab GUIs a few days ago so I’m a bit stuck.
I would very much appreciate any help you could give me!
Thanks
0 comentarios
Respuestas (2)
Walter Roberson
el 28 de Jun. de 2011
You would have to re-save the .fig file /OR/ you would have to write a routine that saved the values in to a file and and another routine to load saved parameters and set() the handles appropriately.
2 comentarios
Walter Roberson
el 29 de Jun. de 2011
I find that I do not like the idea of re-saving the .fig file. Possibly that is partly because _I_ would not use a .fig file in the first place: I prefer to place all of the elements programmatically, which allows me to adapt to user font size preferences and to the user's screen size.
I have not looked at Doug's video to see what he recommends.
I save the key state variables as a structure in a .mat file. User preferences, though, I use uigetpref() and uisetpref() for, which MATLAB saves to a file by itself.
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!