ishandle
Tests which elements of an array are valid graphics or UI handles.
Category: Graphics > Graphics Objects
Syntax
tf = ishandle(H)
Returns true for each element of H that refers to an existing object.
Description
A handle becomes invalid once its object is deleted or its figure is closed, while the variable that held it remains. ishandle is the standard check before using such a stored handle. A plain number is accepted too and is true only if it matches an existing figure number.
Input arguments
H- Any array; non-handle values simply give false.
Output arguments
tf- Logical array of the same size as
H.
Example
Before and after deleting
f = figure;
h = plot(1:3);
disp(ishandle(h))
delete(h)
disp(ishandle(h))
disp(ishandle(99999))
Output
1
0
0
Notes
In MatLivre, ishandle accepts a single handle or number; arrays that mix handle objects with numbers are not supported.