res = isa(var, className)
| Parameter | Description |
|---|---|
| var | a variable |
| className | a class or type name as a string |
| Parameter | Description |
|---|---|
| res | a logical: true or false |
isa returns logical 1 when var is an instance of className, and logical 0 otherwise.
className can be a Nelson type name such as double, cell, numeric, float, or integer.
For classdef objects, isa accepts the class name and supported superclass names, including handle for handle classes.
For sparse arrays, isa tests the stored value class, such as double or logical. Use issparse to test sparse storage.
A = 3;
res = isa(A, 'double')
S = sparse([2 0 3]);
isDouble = isa(S, 'double')
isSparse = issparse(S)
clear classes
d = [tempdir(), 'nelson_help_isa/'];
mkdir(d);
filewrite([d, '/NelsonHelpIsaCounter.m'], ["classdef NelsonHelpIsaCounter < handle"; " properties"; " Count = 0"; " end"; "end"]);
addpath(d);
obj = NelsonHelpIsaCounter();
isCounter = isa(obj, 'NelsonHelpIsaCounter')
isHandle = isa(obj, 'handle')
delete(obj)
| Version | Description |
|---|---|
| 1.0.0 | initial version |
| 2.0.0 | classdef object support documented |
| 2.0.0 | sparse arrays are tested by stored value class |