필터 지우기
필터 지우기

Export data from uicontrol objects in figures

조회 수: 4 (최근 30일)
Jasmine Shragai
Jasmine Shragai 2015년 8월 9일
답변: Geoff Hayes 2015년 8월 9일
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!

답변 (1개)

Geoff Hayes
Geoff Hayes 2015년 8월 9일
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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by