MATLAB Answers

GUI creating multiple objects with the same Tag

8 views (last 30 days)
Blake Rogers
Blake Rogers on 5 Feb 2018
Answered: Walter Roberson on 5 Feb 2018
I have a GUI created with GUIDE named WGE_GUI and with the tag WGE_GUIh. When I run the GUI, if I insert the code
h = findobj('Tag','WGE_GUIh')
right after the GUI is made visible, then h is a 1x1 with Class of matlab.ui.Figure.
However, I have a pushbutton that when clicked runs the same findobj function as above and it returns the following:
h =
3x1 Figure array:
Figure (WGE_GUIh)
Figure (WGE_GUIh)
Figure (WGE_GUIh)
All the Figures in h seem to have the same properties, but I can't determine why there are multiple figures with the same tag. All of their FileNames (e.g. h(1).FileName) are identical and point to the GUI .fig file on my hard drive.
I'm not really sure what I'm looking for when I'm debugging. I have other buttons that use the findobj function, as well as setappdata and getappdata to pass variables between GUIs, but I get this behavior even if those aren't used. Any help would be appreciated!

  0 Comments

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 5 Feb 2018
Some of the objects might have HandleVisibility set to 'callback'; see https://www.mathworks.com/help/matlab/creating_plots/preventing-access-to-figures-and-axes.html
At the command line, try findall() instead of findobj()

  0 Comments

Sign in to comment.


Translated by