EXAMPLE 2: A structure with a field with a subfield
s.field1.subfield
s = struct('field1',struct('subfield',cell(1)));
EXAMPLE 3: An array of structures
v(1).field1
...
v(100).field1
s = struct('field1',cell(1));
v = repmat(s,100,1);
Even though the data elements pointed to by the different fields in a structure are not stored contiguously, a benefit of preallocating structures is that you avoid the (possibly time-consuming) operation of dynamically growing the structure field header. Please refer to the following documentation page for more information:
Best Answer