name = class(var)
obj = class(st, className)
| Parameter | Description |
|---|---|
| var | a variable |
| st | a structure |
| className | a class name as a string |
| Parameter | Description |
|---|---|
| name | a string |
| obj | an old-style object of type className based on structure st |
class(var) returns the class name of var.
For sparse arrays, class returns the stored value class, such as double or logical. Use issparse to test sparse storage.
For classdef value and handle objects, class returns the classdef class name, including package qualification when applicable.
class(st, className) preserves Nelson old-style object creation and is independent from classdef class definitions.
A = 3;
name = class(A)
S = sparse([2 0 3]);
name = class(S)
tf = issparse(S)
clear classes
d = [tempdir(), 'nelson_help_class/'];
mkdir(d);
filewrite([d, '/NelsonHelpClassPoint.m'], ["classdef NelsonHelpClassPoint"; " properties"; " X = 0"; " end"; "end"]);
filewrite([d, '/NelsonHelpClassCounter.m'], ["classdef NelsonHelpClassCounter < handle"; " properties"; " Count = 0"; " end"; "end"]);
addpath(d);
p = NelsonHelpClassPoint();
h = NelsonHelpClassCounter();
pointClass = class(p)
handleClass = class(h)
delete(h)
| Version | Description |
|---|---|
| 1.0.0 | initial version |
| 2.0.0 | classdef value and handle object behavior documented |
| 2.0.0 | sparse arrays report their stored value class |