How to get the inputs given in gui by user into main code

2 次查看(过去 30 天)
Hi,
I am looking for a code that helps me in passing tag names of all the buttons which are on in gui into the another matlab code.
Thanks in Advance.

采纳的回答

Walter Roberson
Walter Roberson 2019-1-21
编辑:Walter Roberson 2019-1-21
t = unique(get(findobj(0, 'type', 'uicontrol', 'style','radio', '-or', 'style', 'push'),'tag'));
t( cellfun(@isempty, t) ) = []; %remove empty tags
Now t is a cell array of the tags of only the radio and push buttons.
You might prefer to replace the 0 with the handle of the figure of the GUI.
Note also: if you used GUIDE, then some of the handles might be set to callback visibility. If so and you need to find them anyhow, then change findobj() to findall()
  1 个评论
Walter Roberson
Walter Roberson 2019-1-21
t = unique(get(findobj(0, 'type', 'uicontrol', 'style','radio', 'value', 1),'tag'));
if ischar(t); t = {t}; end %can happen if only a single radio button
if isempty(t)
t = {}; %no active radio buttons found
else
t( cellfun(@isempty, t) ) = []; %remove empty tags
end

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by