How can i save GUI data to a workspace
5 views (last 30 days)
Show older comments
Hi guys, i've got a problem over here. I've create a GUI with one edit text and one push button .
My objective is that if i type a number in the edit text box and press the push button, I wanna store the number that I've just type in into a variable name: b in the MATLAB workspace. I want the variable b can be store so that i can call it in the command window.
I've done several research that requires me to use the global variable. Thus i need to type global b first before i can execute my command from the GUI itself. I wanna it to be automatically without me declare the global variable first.Anyone can help me???
0 Comments
Answers (1)
Image Analyst
on 29 Nov 2014
If you don't want to set a global variable, you can just get the value whenever you need it using the known name of the edit field:
editString = get(handles.edit1, 'String');
b = str2double(editString);
That will work in any callback function or any other custom function that you've passed the handles structure to.
1 Comment
Geoff Hayes
on 30 Nov 2014
Edited: Geoff Hayes
on 30 Nov 2014
To get to handles outside of the GUI, from the Command Window for example, you may need to set the HandleVisibility property of the GUI figure to on. Then if you know the Tag of the figure, you would do
hFig = findobj('Tag', 'myFigTag');
if ~isempty(hFig)
handles = guidata(hFig);
% etc
end
where myFigTag is the name/tag of your GUI figure.
See Also
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!