How to pull data of UIcontrol objects from the figure handle

4 ビュー (過去 30 日間)
Jasmine Shragai
Jasmine Shragai 2015 年 8 月 18 日
回答済み: liangsai liang 2016 年 10 月 3 日
Hello everyone!
I have created a function which pops up a figure with UIcontrol objects on it (radio buttons, edit-text boxes and check-boxes).
I want to export data from those objects into an excel file after a push-button is pressed. So, I have a callback function for this button, and it is receiving a handle to the figure (which, from my understanding, holds the other objects as "children"?)
How can I get the data of those object from the figure handle? And if not possible, how would you recommend doing such a thing?
Thank you so much! Jasmine

採用された回答

Walter Roberson
Walter Roberson 2015 年 8 月 18 日
Please note that there is no callback for when a pushbutton is released, only for when it is pushed
Normally you would keep track of your objects somehow (such as with a "handles" structure using guidata(), the way that GUIDE does), or you would set the Tag field for each uicontrol to something unique so that you can locate them:
currentfig = ancestor(gcbo,'figure');
eta9_handle = findobj(currentfig, 'tag', 'Eta_9'); %to locate the one you tagged with Eta_9
If you just want them all and will determine an order afterwards then:
currentfig = ancestor(gcbo,'figure');
object_handles = findobj(currentfig, 'type', 'uicontrol');
or you can look for a particular variety:
currentfig = ancestor(gcbo, 'figure');
push_handles = findobj(currentfig, 'type', 'uicontrol', 'style', 'pushbutton');
  2 件のコメント
Jasmine Shragai
Jasmine Shragai 2015 年 8 月 18 日
編集済み: Jasmine Shragai 2015 年 8 月 18 日
Walter, you are THE MAN.
Walter Roberson
Walter Roberson 2015 年 8 月 18 日
We prefer to use the term "humanoid" ;-)

サインインしてコメントする。

その他の回答 (1 件)

liangsai liang
liangsai liang 2016 年 10 月 3 日
厉害!

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by