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.

Property name, specified as case-sensitive, quoted text.

Data Types: char | string

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.

What is the difference between handle and value in MATLAB? ›

Value objects are associated with a specific variable. Handle objects can be referenced by multiple variables. Whether you implement a handle or value class depends on what your class represents and how you want objects to behave. MATLAB® handle variables support reference semantics.

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

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™.

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 to use find function in MATLAB? ›

Find() function in MATLAB
  1. k = find(X): It returns the indices of all non zero elements.
  2. k = find(X, n): It returns the first n indices of non zero elements in X.
  3. k = find(X, n, direction): direction can be 'first' or 'last'. ...
  4. [row, col] = find(): It is used to get row and column subscript for all non zero elements.
Nov 1, 2022

How do you check if two objects are identical in MATLAB? ›

When comparing two handle objects, use == to test whether objects have the same handle. Use isequal to determine if two objects with different handles have equal property values. When comparing empty object arrays, isequal returns logical 1 ( true ) only when the arrays have the same size and class.

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? ›

mp = findprop( h , property ) returns the matlab. metadata. Property object associated with the named property of the object h . property can be a property defined by the class of h or a dynamic property defined only for the object h .

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.

References

Top Articles
Fiesta Mart #66 - 333 South Mason Road, Katy, Texas, United States - Updated July 2024 - Guide.in.ua
Fiesta Mart #66 · Fiesta Mart L.L.C. · 333 S Mason Road, Katy, TX 77450
Dew Acuity
Kraziithegreat
Ou Class Nav
Swimgs Yung Wong Travels Sophie Koch Hits 3 Tabs Winnie The Pooh Halloween Bob The Builder Christmas Springs Cow Dog Pig Hollywood Studios Beach House Flying Fun Hot Air Balloons, Riding Lessons And Bikes Pack Both Up Away The Alpha Baa Baa Twinkle
Employeeres Ual
Geometry Escape Challenge A Answer Key
Full Range 10 Bar Selection Box
Washington Poe en Tilly Bradshaw 1 - Brandoffer, M.W. Craven | 9789024594917 | Boeken | bol
Oc Craiglsit
Craigslist Apartments In Philly
Mbta Commuter Rail Lowell Line Schedule
Q33 Bus Schedule Pdf
1v1.LOL - Play Free Online | Spatial
Craigslist Portland Oregon Motorcycles
Erica Banks Net Worth | Boyfriend
Puss In Boots: The Last Wish Showtimes Near Cinépolis Vista
Menus - Sea Level Oyster Bar - NBPT
Craigslist Apartments Baltimore
Colonial Executive Park - CRE Consultants
Scripchat Gratis
Kroger Feed Login
Margaret Shelton Jeopardy Age
FAQ's - KidCheck
Catchvideo Chrome Extension
Doctors of Optometry - Westchester Mall | Trusted Eye Doctors in White Plains, NY
Pixel Combat Unblocked
Keshi with Mac Ayres and Starfall (Rescheduled from 11/1/2024) (POSTPONED) Tickets Thu, Nov 1, 2029 8:00 pm at Pechanga Arena - San Diego in San Diego, CA
San Jac Email Log In
Himekishi Ga Classmate Raw
Desales Field Hockey Schedule
Ff14 Sage Stat Priority
APUSH Unit 6 Practice DBQ Prompt Answers & Feedback | AP US History Class Notes | Fiveable
Sun-Tattler from Hollywood, Florida
Max 80 Orl
Ni Hao Kai Lan Rule 34
Junee Warehouse | Imamother
Can You Buy Pedialyte On Food Stamps
Ksu Sturgis Library
Barber Gym Quantico Hours
Jaefeetz
Pixel Gun 3D Unblocked Games
What is a lifetime maximum benefit? | healthinsurance.org
Sherwin Source Intranet
Sky Dental Cartersville
Meet Robert Oppenheimer, the destroyer of worlds
Is TinyZone TV Safe?
Maurices Thanks Crossword Clue
Koniec veľkorysých plánov. Prestížna LEAF Academy mení adresu, masívny kampus nepostaví
Unity Webgl Extreme Race
Latest Posts
Article information

Author: Jerrold Considine

Last Updated:

Views: 6101

Rating: 4.8 / 5 (78 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Jerrold Considine

Birthday: 1993-11-03

Address: Suite 447 3463 Marybelle Circles, New Marlin, AL 20765

Phone: +5816749283868

Job: Sales Executive

Hobby: Air sports, Sand art, Electronics, LARPing, Baseball, Book restoration, Puzzles

Introduction: My name is Jerrold Considine, I am a combative, cheerful, encouraging, happy, enthusiastic, funny, kind person who loves writing and wants to share my knowledge and understanding with you.