FUNCTION REFERENCE

findobj

Find graphics and UI component handles by properties.

Find graphics and UI component handles by properties.

Syntax

h = findobj(scope, 'Type', kind, property, value, ...)

Syntax

h = findobj(scope, '-depth', d, 'Type', kind, property, value, ...)

Syntax

h = findobj(scope, 'Tag', tag, ...)

The scope is groot or 0, a figure number, or one live figure, uifigure, UI container, axes, uiaxes, line, volume or UI component handle. Omit scope to search from root. A depth of 0 searches the scope itself, and Inf searches all descendants. Walks both classic figures and UI component trees including uiaxes graphics children (lines, patches, text, volumes, scatter, bar, stair, stem, images, constant lines and rectangles). Property/value filters are combined with AND; repeated properties must each match.

HandleVisibility rule: classic figures and UI children default to 'on'; uifigure defaults to 'off'. Searching from root (groot, 0, or omitted scope) skips figures and subtrees whose HandleVisibility is 'off' (or 'callback' outside a callback) unless groot ShowHiddenHandles is 'on'. Passing a uifigure directly as scope searches its visible descendants.

Results use figure number, axes position and stored line order for classic figures, and tree order for UI hierarchies. Within an axes, volumes are returned in stacking order, front to back.

Example

f = uifigure('Visible', 'off'); ax = uiaxes(f); plot(ax, 1:4, (1:4).^2); h = findobj(f, 'Type', 'line'); close(f);

Differences from MATLAB: handle-array scopes, unfiltered lookup, logical operators (-not/-and/-or), -property, regular expressions and the 'flat' option are rejected.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.