Main Content

isvalid

Class: handle

Determine valid handles

Syntax

B = isvalid(H)

Description

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.

Input Arguments

expand all

Input array, specified as an array of object handles.

Output Arguments

expand all

Result of validity test, returned as a logical array the same size as H in which each element is true if the corresponding element in H is a valid handle.

Attributes

Accesspublic
Sealedtrue

To learn about attributes of methods, see Method Attributes.

Examples

Test for Valid Handles

This example tests a handle array for valid members:

H = plot(rand(5));
delete(H(3:4))
B = isvalid(H)
B =

     1
     1
     0
     0
     1

Extended Capabilities

Thread-Based Environment
Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.