MATLAB: Question about the ‘stuct’ of matlab

structstructures

Why the second one gives rise to empty struct?
s.a=1; s.b=2; s.c={}
s =
a: 1
b: 2
c: {}
s = struct('a',1,'b',2,'c',{})
s =
0x0 struct array with fields:
a
b
c

Best Answer

That's the way the function struct is designed to work. See struct, Create structure array "[...]If value is an empty cell array {}, then s is an empty (0-by-0) structure."