2
votes

I am attempting to organize a large amount of data into nested structures in MATLAB and I would like for each structure to contain a cell array but I get

A dot name structure assignment is illegal when the structure is empty. Use a subscript on the structure.

Example of code:

Year.Org1 = struct('Set1',{},'Set2',{});
Year.Org2 = struct('Set1',{},'Set2',{});

and then I want Set1/Set2/etc to be cell arrays of n-rows with column 1 str, column 2 str, column 3 value, and so on.

Any advice on initializing this structure and then accessing various parts would be greatly appreciated.

1
@Troy Not exactly a duplicate I think the OP needs {{}} and not {[]}. - Ratbert

1 Answers

1
votes

With single curly braces the structure is initialized empty. You can achieve what you want by doubling the curly braces:

Year.Org1 = struct('Set1',{{}},'Set2',{{}});

Best,