| Contents | Index |
Hmatch = findobj(Hobj,<conditions>)
Hmatch = findboj(Hobj,'-property','PropertyName')
Hmatch = findobj(Hobj,<conditions>) finds handle class objects that meet the specified conditions. Specify conditions as property name/property value pairs, indicating that the objects you are trying to find have specific property values.
The Hobj argument must be an array of handle objects. The returned value, Hmatch contains an array of object handles that match the conditions.
Hmatch = findboj(Hobj,'-property','PropertyName') finds all object in Hobj having the specified property.
findobj has access only to public members of the objects in Hobj. findobj can find dynamic properties. See Find Handle Objects for more information on using findobj.
You cannot use regular expression with handle class objects.
Find the object with a specific property value. Given the handle class, BasicHandle:
classdef BasicHandle < handle properties Prop1 end methods function obj = BasicHandle(val) if nargin > 0 obj.Prop1 = val; end end end end
Create an array of BasicHandle objects:
h(1) = BasicHandle(7); h(2) = BasicHandle(11); h(3) = BasicHandle(27);
Find the handle of the object whose Prop1 property has a value of 7:
h7 = findobj(h,'Prop1',7);
h7.Prop1
ans =
7Find the object with a specific dynamic property. Given the button class:
classdef button < dynamicprops properties UiHandle end methods function obj = button(pos) if nargin > 0 if length(pos) == 4 obj.UiHandle = uicontrol('Position',pos,... 'Style','pushbutton'); else error('Improper position') end end end end end
Create an array of button objects, only one element of which defines a dynamic property. Use findobj to get the handle of the object with the dynamic property named ButtonCoord:
b(1) = button([20 40 80 20]); b(1).addprop('ButtonCoord'); b(1).ButtonCoord = [2,3]; b(2) = button([120 40 80 20]); b(3) = button([220 40 80 20]); h = findobj(b,'-property','ButtonCoord'); h.ButtonCoord ans = 2 3
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |