isvalid
Return true for valid handles.
📝Syntax
res = isvalid(h)
📥Input Arguments
Parameter Description
h a handle object or handle array
📤Output Arguments
Parameter Description
res a logical scalar or logical array with the same size as h
📄Description

isvalid returns true for valid handles and false for handles invalidated by delete.

Clearing one variable does not invalidate other aliases to the same handle object.

For handle arrays, the result has the same size as the input array.

💡Examples
Check a classdef handle array.
d = [tempdir(), 'nelson_help_isvalid/'];
mkdir(d);
filewrite([d, '/NelsonHelpIsValidCounter.m'], ["classdef NelsonHelpIsValidCounter < handle"; "  properties"; "    Count = 0"; "  end"; "end"]);
addpath(d);
h(3) = NelsonHelpIsValidCounter();
isvalid(h)
delete(h(2));
isvalid(h)
🔗See Also
isa
🕔Version History
Version Description
1.0.0 initial version
2.0.0 handle array result documented
Edit this page on GitHub