Find handle objects - MATLAB - MathWorks Deutschland (2024)

Class: handle

Find handle objects

expand all in page

Syntax

Hmatch = findobj(H)
Hmatch = findobj(H,property,value,...,property,value)
Hmatch = findobj(H,'-not',property,value)
Hmatch = findobj(H,'-regexp',property,expression)
Hmatch = findobj(H,property,value,logicaloperator,property,value)
Hmatch = findobj(H,'-function',fh)
Hmatch = findobj(H,'-function',property,fh)
Hmatch = findobj(H,'-class',class)
Hmatch = findobj(H,'-isa',class)
Hmatch = findobj(H,'-property',property)
Hmatch = findobj(H,'-method',methodname)
Hmatch = findobj(H,'-event',eventname)
Hmatch = findobj(H,'-depth',d,___)

Description

Hmatch = findobj(H) returns the objects listed in H and all of their descendants.

Hmatch = findobj(H,property,value,...,property,value) finds handle objects that have the specified property set to the specified value (compared using isequal).

Hmatch = findobj(H,'-not',property,value) inverts the expression in the following property value pair. That is, find objects whose specified property is not equal to value.

Hmatch = findobj(H,'-regexp',property,expression) uses the regular expression defined in expression to find properties with specific values. Not all classes supported the use of regular expression to find property values.

Hmatch = findobj(H,property,value,logicaloperator,property,value) applies the logical operator to the name/value pairs. Supported logical operators include:

  • '-or'

  • '-and' (default if you do not specify an operator)

  • '-xor'

Hmatch = findobj(H,'-function',fh) calls the function handle fh on the objects in H and returns the objects for which the function returns true.

Hmatch = findobj(H,'-function',property,fh) calls the function handle fh on the specified property’s value for the objects in H and returns the objects for which the function returns true. The function must return a scalar logical value.

Hmatch = findobj(H,'-class',class) finds all objects belonging to the specified class.

Hmatch = findobj(H,'-isa',class) finds all objects belonging to the specified class.

Hmatch = findobj(H,'-property',property) finds all object in H having the named property.

Hmatch = findobj(H,'-method',methodname) finds objects that have the specified method name.

Hmatch = findobj(H,'-event',eventname) finds objects that have the specified event name.

Hmatch = findobj(H,'-depth',d,___) specifies how many levels in the instance hierarchies under the objects in H to search.

Specify all -options as character vectors or string scalars.

Input Arguments

expand all

Objects to search from, specified as an array of object handles. Unless the you specify the '-depth' option, findobj searches the objects in the input array H and child objects in the instance hierarchy.

Class of object to find, specified as case-sensitive, quoted text.

Data Types: char | string

Property value, specified as a value or MATLAB® expression.

Method name, specified as case-sensitive quoted text.

Data Types: char | string

Event name, specified as case-sensitive quoted text.

Data Types: char | string

Depth of search, specified as an integer indicating the number of levels below any given object in the input array H.

  • d = n — Search n levels of the hierarchy below each object in H

  • d = 0 — Search only the same level as the objects in H.

  • d = inf — Search all levels below objects in H. This is the default.

Function handle, specifying the function that is evaluated for each object in the input array H. This function must return a scalar, logical value indicating whether there is a match (true) or not (false).

Output Arguments

expand all

Objects found by search, returned as a handle array.

Attributes

Accesspublic

To learn about attributes of methods, see Method Attributes.

Examples

Object with Specific Property Value

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 endend

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 = 7

Object with Specific Property Name

Find 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]);addprop(b(1),'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

Find Objects Using Regular Expressions

Find objects based on the value of object properties using regular expressions. While findobj has a -regexp options, not all classes support this option. This example uses the -function option to use a regular expression from a function as an alternative to the -regexp option.

This class defines a static method that builds an object array. Each object has a Name property that contains character representing the array element number.

classdef FindRegExpr < handle properties Name end methods (Static) function b = regXArray b = FindRegExpr.empty(0,50); for i = 1:50 b(i).Name = sprintf('%d',i); end end endendA = FindRegExpr.regXArray;
a = 1×50 FindRegExpr array with properties: Name

Find the objects whose Name property contains a character vector beginning with the character '1'.

subArray = findobj(a, '-function', 'Name', @(x) ~isempty(regexp(x, '^1\d*')));
subArray = 11×1 testRegExpr array with properties: Name

Tips

  • findobj has access only to public members.

  • If there are no matches, findobj returns an empty array of the same class as the input array H.

  • Logical operator precedence follows MATLAB precedence rules. For more information, see Operator Precedence.

  • Control precedence by grouping within cell arrays

Extended Capabilities

Thread-Based Environment
Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

Version History

Introduced in R2008a

See Also

findprop

MATLAB-Befehl

Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:

 

Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.

Find handle objects - MATLAB- MathWorks Deutschland (1)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

Find handle objects - MATLAB
- MathWorks Deutschland (2024)
Top Articles
Opinion: 30 years after ‘My So-Called Life,’ its creator reflects on choice | CNN
Zittende Helvetia (1911) - Switzerland - LastDodo
Kostner Wingback Bed
Is Paige Vanzant Related To Ronnie Van Zant
Www.1Tamilmv.cafe
122242843 Routing Number BANK OF THE WEST CA - Wise
What Are Romance Scams and How to Avoid Them
Frederick County Craigslist
Amc Near My Location
Enrique Espinosa Melendez Obituary
Nco Leadership Center Of Excellence
Guardians Of The Galaxy Showtimes Near Athol Cinemas 8
라이키 유출
Tx Rrc Drilling Permit Query
Heska Ulite
Dark Souls 2 Soft Cap
Nier Automata Chapter Select Unlock
Babyrainbow Private
10 Free Employee Handbook Templates in Word & ClickUp
Local Collector Buying Old Motorcycles Z1 KZ900 KZ 900 KZ1000 Kawasaki - wanted - by dealer - sale - craigslist
Rhinotimes
Lancasterfire Live Incidents
Destiny 2 Salvage Activity (How to Complete, Rewards & Mission)
CANNABIS ONLINE DISPENSARY Promo Code — $100 Off 2024
R Personalfinance
Axe Throwing Milford Nh
Huntersville Town Billboards
We Discovered the Best Snow Cone Makers for Carnival-Worthy Desserts
Ahn Waterworks Urgent Care
Military life insurance and survivor benefits | USAGov
Baja Boats For Sale On Craigslist
Jcp Meevo Com
Pain Out Maxx Kratom
Hdmovie2 Sbs
One Credit Songs On Touchtunes 2022
Suspect may have staked out Trump's golf course for 12 hours before the apparent assassination attempt
Exploring The Whimsical World Of JellybeansBrains Only
Google Jobs Denver
Craigslist Pets Huntsville Alabama
Boone County Sheriff 700 Report
Tiny Pains When Giving Blood Nyt Crossword
Join MileSplit to get access to the latest news, films, and events!
Wunderground Orlando
Wal-Mart 140 Supercenter Products
Gw2 Support Specter
Yosemite Sam Hood Ornament
Dineren en overnachten in Boutique Hotel The Church in Arnhem - Priya Loves Food & Travel
Understanding & Applying Carroll's Pyramid of Corporate Social Responsibility
Public Broadcasting Service Clg Wiki
Law Students
32 Easy Recipes That Start with Frozen Berries
Latest Posts
Article information

Author: Wyatt Volkman LLD

Last Updated:

Views: 6051

Rating: 4.6 / 5 (46 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Wyatt Volkman LLD

Birthday: 1992-02-16

Address: Suite 851 78549 Lubowitz Well, Wardside, TX 98080-8615

Phone: +67618977178100

Job: Manufacturing Director

Hobby: Running, Mountaineering, Inline skating, Writing, Baton twirling, Computer programming, Stone skipping

Introduction: My name is Wyatt Volkman LLD, I am a handsome, rich, comfortable, lively, zealous, graceful, gifted person who loves writing and wants to share my knowledge and understanding with you.