Filter löschen
Filter löschen

Export data from uicontrol objects in figures

4 Ansichten (letzte 30 Tage)
Jasmine Shragai
Jasmine Shragai am 9 Aug. 2015
Beantwortet: Geoff Hayes am 9 Aug. 2015
Hello!
In my script I have a figure with uicontrol objects in it (checkboxes, pop-outs and edit-text boxes). Once the user finishes entering all the data, there's an OK button, once hit, I want to save the data into an array + into an output file.
I have thought of creating a callback function behind the OK button, but then I have to send all this data into the function (and I'm not sure how..)
Another thing is that two of the checkboxes are for "save setting as default", so things have to be saved in few different places...
What would be a good way to do this?
Thank you so much for your help!

Antworten (1)

Geoff Hayes
Geoff Hayes am 9 Aug. 2015
Jasmine - have you used GUIDE to create your GUI? If so, you can use the handles structure to obtain the data from each of the controls. For all controls that you have created, there is a field for each in handles that has the handle for that control. So if you have a checkbox named checkbox1, then you could do
get(handles.checkbox1,'Value')
to get the Value property of this checkbox.
Now, since you have two places where you can save the data (either from the OK button or when you close the GUI), you could create a function within your GUI that both the OK button callback and the CloseFcn call to do all of the saving. Something like
function pushbutton1_Callback(hObject, eventdata, handles)
% call the function to save the data
saveData(handles);
function saveData(handles)
% open a file
% get the data from each property to save to file
cbValue1 = get(handles.checkbox1,'Value');
% etc.
% close the file

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by