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)

FAQs

How do you get the handle of an object in MATLAB? ›

h = gco returns the handle of the current object. h = gco(figure_handle) returns the handle of the current object in the figure specified by figure_handle .

How do you find all handles in MATLAB? ›

h = findall( objhandles , prop 1, value 1,..., prop N, value N) returns the handles of all objects in the hierarchy that have the specified properties set to the specified values. For example, h = findall(gcf,'Type','text','Color','r') returns all text objects in the current figure that have a red color.

How do you find the current handle in MATLAB? ›

Use the gcf command to get the current figure handle. surf(peaks) fig = gcf; % current figure handle fig.

How do you check handle equality in MATLAB? ›

Use isequal when you want to determine if different handle objects have the same data in all object properties. Use == when you want to determine if handle variables refer to the same object. When comparing objects that contain dynamic properties, isequal always returns false .

What is a handle object? ›

Handle objects enable more than one variable to refer to the same object. Handle-object behavior affects what happens when you copy handle objects and when you pass them to functions.

What is a handle in MATLAB? ›

A function handle is a MATLAB® data type that represents a function. A typical use of function handles is to pass a function to another function. For example, you can use function handles as input arguments to functions that evaluate mathematical expressions over a range of values.

How do you find the objects of a class in MATLAB? ›

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.

How to get figure handle in MATLAB? ›

MATLAB allows you to get any property of a figure handle (or actually any type of graphics handle, including axes, line objects, text objects, and so on) by using the 'get' function in the following manner: >> h = figure; >> propvar = get(h, 'Propertyname');

What is findobj in MATLAB? ›

The findobj function can scan the object hierarchy to obtain the handles of objects that have specific property values. For identification, all graphics objects have a Tag property that you can set to any character vector. You can then search for the specific property/value pair.

What are function handle operations in MATLAB? ›

Function handles are variables that you can pass to other functions. For example, calculate the integral of x2 on the range [0,1]. q = integral(f,0,1); Function handles store their absolute path, so when you have a valid handle, you can invoke the function from any location.

How do you convert a function to a handle in MATLAB? ›

Description. ht = matlabFunction( f ) converts the symbolic expression or function f to a MATLAB® function with handle ht . If there is an equivalent MATLAB function operating on the double data type for the symbolic expression or function, then the converted function can be used without Symbolic Math Toolbox™.

What is handle graphics in MATLAB? ›

Each part of a matlab plot has some set of properties that can be changed to change its appearance. You can create a "handle" for each part of the plot which basically lets you "grab" that part of the plot and change some of its properties.

How do you check if an object is a handle in MATLAB? ›

B = isvalid( H ) returns a logical array in which each element is true if the corresponding element in H is a valid handle. A handle variable becomes invalid if the object has been deleted. Within a class delete method, isvalid always returns false . You cannot override the isvalid method in handle subclasses.

How do you compare handles in MATLAB? ›

MATLAB® considers function handles that you construct from the same named function to be equal. The isequal function returns a value of true when comparing these types of handles. If you save these handles to a MAT-file, and then load them back into the workspace, they are still equal.

What does == do in MATLAB? ›

Description: Use the equal sign to assign values to a variable. The syntax B = A stores the elements of A in variable B . The = character is for assignment, whereas the == character is for comparing the elements in two arrays.

How to get the object handle? - MATLAB AnswersMathWorkshttps://www.mathworks.com ›

The value of 'Children' properties are always object handles (usually in handle graphic numeric form), and are never strings. Is 'axes_of_data' ...
More than one variable can refer to the same handle object. Therefore, users interact with instances of handle classes differently than instances of value class...
Find objects using regular expressions or obtain the matlab.metadata.Property object for specific properties.

How do you create a figure handle in MATLAB? ›

Figure handles. To create a figure, use the figure function like so: >> fhandle = figure; This creates a new figure window and stores all the figure data in the variable fhandle.

How do you find the property of an object in MATLAB? ›

The findprop method returns the matlab. metadata. Property object for the specified object and property. The property can also be a dynamic property created by the addprop method of the dynamicprops class.

What is the MATLAB handle class? ›

The handle class implements methods to support events and listeners, destructors, relational operations, and other operations. Handle Class Destructor. Define a delete method to customize what happens when MATLAB destroys handle objects.

Top Articles
Soterra Hunting Leases
How To Download Locked Videos From Any Website | Robots.net
This website is unavailable in your location. – WSB-TV Channel 2 - Atlanta
Aberration Surface Entrances
Immobiliare di Felice| Appartamento | Appartamento in vendita Porto San
Top Financial Advisors in the U.S.
Localfedex.com
J Prince Steps Over Takeoff
Jasmine
Mlifeinsider Okta
Bubbles Hair Salon Woodbridge Va
Boat Jumping Female Otezla Commercial Actress
Athens Bucket List: 20 Best Things to Do in Athens, Greece
Think Up Elar Level 5 Answer Key Pdf
Gma Deals And Steals Today 2022
Mbta Commuter Rail Lowell Line Schedule
Samantha Lyne Wikipedia
Craigslist Free Stuff Santa Cruz
Find Such That The Following Matrix Is Singular.
Rams vs. Lions highlights: Detroit defeats Los Angeles 26-20 in overtime thriller
Pizza Hut In Dinuba
St Maries Idaho Craigslist
Diakimeko Leaks
Anotherdeadfairy
Valley Craigslist
2021 Tesla Model 3 Standard Range Pl electric for sale - Portland, OR - craigslist
Solo Player Level 2K23
Winterset Rants And Raves
LG UN90 65" 4K Smart UHD TV - 65UN9000AUJ | LG CA
Pay Stub Portal
Blush Bootcamp Olathe
Craigslist Texas Killeen
35 Boba Tea & Rolled Ice Cream Of Wesley Chapel
Pokemmo Level Caps
Tyler Sis 360 Boonville Mo
Junee Warehouse | Imamother
Zero Sievert Coop
Edict Of Force Poe
ATM Near Me | Find The Nearest ATM Location | ATM Locator NL
Soulstone Survivors Igg
Frommer's Philadelphia &amp; the Amish Country (2007) (Frommer's Complete) - PDF Free Download
Yogu Cheshire
“To be able to” and “to be allowed to” – Ersatzformen von “can” | sofatutor.com
2007 Jaguar XK Low Miles for sale - Palm Desert, CA - craigslist
Anthem Bcbs Otc Catalog 2022
Shell Gas Stations Prices
Conan Exiles Tiger Cub Best Food
Random Animal Hybrid Generator Wheel
Craigslist Free Cats Near Me
Game Akin To Bingo Nyt
Kobe Express Bayside Lakes Photos
Gameplay Clarkston
Latest Posts
Article information

Author: Rob Wisoky

Last Updated:

Views: 6328

Rating: 4.8 / 5 (68 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Rob Wisoky

Birthday: 1994-09-30

Address: 5789 Michel Vista, West Domenic, OR 80464-9452

Phone: +97313824072371

Job: Education Orchestrator

Hobby: Lockpicking, Crocheting, Baton twirling, Video gaming, Jogging, Whittling, Model building

Introduction: My name is Rob Wisoky, I am a smiling, helpful, encouraging, zealous, energetic, faithful, fantastic person who loves writing and wants to share my knowledge and understanding with you.