Reputation: 1651
I have a simple gui where the user enters some data and executes a script file afterwards. I want to extract the data entered in the text boxes and tables from the gui. How can I perform that ?
Note: the gui is just used to enter data. That is the user has to call the script file from the workspace after entering the data in the gui.
Upvotes: 0
Views: 59
Reputation: 5175
To extract data from a uicontrol
you can use wwhat is called "dot notation":
h=uicontrol('styile','edit');
text=h.string;
(more uicontrol parameters should be defined)
As alternative, you can use the "old style" function get
h=uicontrol('styile','edit');
text=get(h,'string')
About the user required to manually run the script, you can also "automate" it by assigning the script to the callback
property of a uicontrol (e. g. to a pushbutton)
h=uicontrol('style','pushbutton','callback','my_script')
the my_script
m-file will be execute when the user presses the pushbutton.
Hope this helps.
Upvotes: 1
Reputation: 151
Right-click the uicontrol in the gui and select View Callbacks->Callback.
If your uicontrol is an editbox these lines would set the variable myData in the base workspace to the data entered in the editbox if you add these lines to the callback function:
assignin('base','myData',get(hObject,'String'));
If your uicontrol is something else than an editbox the 'String' might be 'Value'. Right click the uicontrol and select the Property Inspector to find the attribute of interest.
Upvotes: 0