2

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.

2

1 Answer 1

1

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,

Sign up to request clarification or add additional context in comments.

4 Comments

That's exactly what I needed. Thanks!
You're welcome. Please mark the question as "solved" if it is the case by accepting the answer. It will tell the community that you no longer need help on that matter. You can upvote too, if you liked the answer :)
I tried to upvote it but I do not have 15 rep yet, sorry :(
Don't worry it's fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.