isgraphics

True for valid graphics object handles

Description

example

tf = isgraphics(H) returns true for elements of H that are valid graphics objects and false where elements are not valid graphics objects or are graphics objects that have been deleted.

tf = isgraphics(H,type) returns true for elements of H that are valid graphics objects of the type specified by the type argument. An object type is the value contained in the object’s Type property.

Examples

collapse all

Create a plot and return the handle array. Test array for valid handles.

H = plot(rand(5));

isgraphics(H)
ans = 5x1 logical array

   1
   1
   1
   1
   1

Create a plot and return the handle array. Concatenate with other graphics objects and test for handles that are of type Line.

H = plot(rand(5)); 

a = [H;gca;gcf]; 
isgraphics(a,'line')
ans = 7x1 logical array

   1
   1
   1
   1
   1
   0
   0

Input Arguments

collapse all

Input variable or expression that evaluates to graphics object handles.

Object type, specified as a character vector. An object’s type is contained in its Type property.

Output Arguments

collapse all

Result, returned as a logical array or an empty GraphicsPlaceholder array. If the result is a logical array, 1 indicates elements of the input array that are valid, and 0 indicates elements that are invalid. The result is an empty GraphicsPlaceholder array when the input array is empty.

See Also

Functions

Introduced in R2014b