How to reference a property name with a variable in findobj?
Afficher commentaires plus anciens
In my code, I am looping through several property names in order to produce different handles. In my case, I have an array called list, which stores different group names.
list = ['G1', 'G2', 'G3']
I have 8 different objects which all have one of these group names. I am using the following code to find a handle for objects with specific group names. I am using a loop to produce these handles.
for x = 1:numel(list)
grp = findobj(obj, 'GrpName', list(x))
% other code that is not important for this problem
end
Theoretically, since list(1) = 'G1', during the first loop grp should yield a handle with the objects that have the GrpName 'G1' (when I hardcode the value 'G1' into the findobj function it correctly produces a handle). However, grp is empty presumably because of the variable name. Am I formatting this incorrectly? Thanks in advance.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!