Export data from uicontrol objects in figures
2 ビュー (過去 30 日間)
古いコメントを表示
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!
0 件のコメント
回答 (1 件)
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!