ishghandle

Tests whether values are valid Handle Graphics object handles, optionally of a given type.

Category: Graphics > Graphics Objects

Syntax

tf = ishghandle(H)

True for each element that is a valid graphics handle.

tf = ishghandle(H, type)

True only for handles whose type is type, such as 'line' or 'axes'.

Description

It differs from ishandle in that it considers only graphics objects, not UI objects created by older toolkits. In practice the two give the same answer for plots. Passing a type makes it a handy guard before calling type-specific code.

Input arguments

H
Value or array to test.
type
Object type name, such as 'figure'.

Output arguments

tf
Logical array the size of H.

Example

Check the type

figure
h = plot(1:3);
disp(ishghandle(h))
disp(ishghandle(h, 'line'))
disp(ishghandle(h, 'axes'))
delete(h)
disp(ishghandle(h))
Output
   1
   1
   0
   0

See also

ishandle isgraphics isvalid gca gcf