isvalid
Tells whether a handle-type object, such as a timer, is still valid.
Category: Programming > Programming Utilities
Syntax
tf = isvalid(obj)
Returns true for each element of obj that refers to an existing object, false for deleted ones.
Description
A timer variable keeps existing after delete(t), but it no longer refers to a usable object. isvalid is the safe way to tell the two states apart before calling start or reading properties.
Input arguments
obj- A timer object or an array of them. Other values give
false.
Output arguments
tf- Logical array the size of
obj.
Example
Before and after delete
t = timer('TimerFcn', @(~,~) disp('tick'));
disp(isvalid(t))
delete(t)
disp(isvalid(t))
disp(isvalid(5))
Output
1
0
0