How to check a type of specified variable is a specified type in MatLab? - isa -- MatLab

How to check a type of specified variable is a specified type in MatLab? - isa -- MatLab

How to check a type of specified variable is a specified type in MatLab?
[Ans]
isa

[description]
<answer>=isa(<A>,<dataType>)
<answer>=isa(<A>,<categoryType>)

<answer>=isa(<A>,<dataType>)
It will return true if type of <A> is the type <dataType>

<answer>=isa(<A>,<categoryType>)
It will return true if type of <A> belongs to the category <categoryType>


more details on:


code:
clear
clc typeS='float';
inst1=56;
isa(inst1,typeS)
inst2=logical(1);
isa(inst2,typeS)
inst3=true;
isa(inst3,typeS)
inst4='A';
isa(inst4,typeS)
inst5=[4 5 6 'A'];
isa(inst5,typeS)
inst6={1,2,3,'A'};
isa(inst6,typeS)

result:

ans =


1


ans =


0


ans =


0


ans =


0

Comments