how to have sub struct in matlab

matlab, struct

Solution

the easiest way

a.b.c = 1;
a.b.d = 'something else';

you got the point...

More formally,

a = struct( 'b', struct( 'c', [1 2 3], 'd', {{4}} ),...
            'subStruct', struct( 'e', [], 'f', 'string' ) );

you may use `struct` within `struct` - no problem.

Problem

I have a pretty simple question. I understand how to create a simple struct, but now I would like to know how to create a struct within a struct, a sub struct if you will. I am not sure if this is doable because I have not really seen any examples, but if someone could possible show how to do this, it would be much appreciated.

Original source