How to check class of variable is struct in MatLab? - isstruct -- MatLab
How to check class of variable is struct in MatLab? - isstruct -- MatLab
How to check class of variable is struct in MatLab?
[Ans]
isstruct
[description]
<answer>=isstruct(<s1>)
If <s1> is a structure, it will return true. Otherwise, return false.
more details on:
code:
clear
clc
s1=struct
s2=struct([])
s3=struct('a','1')
s4=struct('a',[1 2])
s5=struct('a',[[1] [2]])
s6=struct('a',[['1'] ['2']])
s7=struct('a',1,'b',2,'c',3)
s8=struct('a',1,'b',2,'c',{3,4})
s8(1)
s8(2)
%compiler error
%s8(3,1)
%s8(3,2)
s9=struct('a',{3,4})
s9(1)
s9(2)
s10=struct(s9)
s11=s9
result:
s1 =
s2 =
s3 =
a: '1'
s4 =
a: [1 2]
s5 =
a: [1 2]
s6 =
a: '12'
s7 =
a: 1
b: 2
c: 3
s8 =
a
b
c
ans =
a: 1
b: 2
c: 3
ans =
a: 1
b: 2
c: 4
s9 =
a
ans =
a: 3
ans =
a: 4
s10 =
a
s11 =
a
Comments
Post a Comment