MATLAB 帮助中心
确定输入是否为指定类的实例
tf = isa(A,classname)
tf = isa(A,numericCategory)
如果 A 是 classname 的实例或 classname 的子类,则 tf = isa(A,classname) 返回 1 (true)。否则,将返回 0 (false)。输入参量 A 可以具有任何数据类型。
A
classname
1
true
0
false
如果 A 是对象且 dataType 是 A 的类或 A 的超类,则 isa 返回 1。
dataType
isa
示例
如果 A 的数据类型属于 numericCategory 指定的类别,则 tf = isa(A,numericCategory) 返回 1 (true)。否则,将返回 0 (false)。
numericCategory
如果 A 是对象且 A 的类或 A 的任何超类属于指定的类别,则 isa 返回 1。
全部折叠
创建数值变量并确定其数据类型是否为 double。
double
A = 3.1416; tf = isa(A,'double')
tf = logical 1
创建一个 32 位整数数组,并确定其数据类型是否为 int32。
int32
A = int32([0 2 4 6 8])
A = 1×5 int32 row vector 0 2 4 6 8
tf = isa(A,'int32')
确定 A 的数据类型是否为 char。
char
tf = isa(A,'char')
tf = logical 0
创建一个其数据类型为 uint8 的数组。确定该数组是否具有属于 integer 类别的数据类型。
uint8
integer
A = uint8([0 2 4 6 8])
A = 1×5 uint8 row vector 0 2 4 6 8
tf = isa(A,'integer')
确定 A 的数据类型是否属于 float 类别。
float
tf = isa(A,'float')
输入数组。
类名,指定为字符向量或字符串标量。classname 可以是:
任何基本数据类型或 MATLAB® 类的名称
Java® 或 .NET 类的名称
下表显示许多常用 MATLAB 数据类型的名称。
'half'
'single'
'double'
'int8'
'int16'
'int32'
'int64'
'uint8'
'uint16'
'uint32'
'uint64'
'logical'
'char'
'string'
'struct'
'cell'
'table'
'timetable'
'function_handle'
'numeric'
'float'
'integer'
数据类型类别,指定为 'numeric'、'float' 或 'integer'。这些值表示数值类型的类别,如下表中所示。
整数或浮点数组,具有以下数据类型之一:
single
half
int8
int16
int64
uint16
uint32
uint64
单精度或双精度浮点数组,具有以下任一数据类型:
有符号或无符号整数数组,具有以下数据类型之一:
要测试输入数组是否为稀疏,请使用 issparse 函数。
issparse
要测试输入数组是否包含任何虚数或复数元素,请使用 ~isreal(A)。
~isreal(A)
全部展开
backgroundPool
ThreadPool
此函数完全支持基于线程的环境。有关详细信息,请参阅在基于线程的环境中运行 MATLAB 函数。
在 R2006a 之前推出
class | isnumeric | isfloat | isinteger | exist | isenum
class
isnumeric
isfloat
isinteger
exist
isenum
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处