- #1
Apteronotus
- 202
- 0
Hi
The following structure has 2 elements.
people = struct(...
'name',{'bob', 'john'},...
'numKids',{0, 2}, ...
'kidsage',{[],[12,9]});
each element people(1), people(2) has three frields (name, numKids, kidsage)
Instead of declaring the structure in one line as above, I would like to define it one field at a time.
The closest working example I've been able to come up with is
people = struct
people.('name') = {'bob, 'john'}
people.('numkids') = {0, 2}
people.('kidsage') = {[], [12, 9]}
But defined in this way, the people structure only has one element.
ie.
people(1) =
name: {'bob' 'john'}
numkids: {[0] [2]}
kidsage: {[] [12, 9]}
Can anyone help?
The following structure has 2 elements.
people = struct(...
'name',{'bob', 'john'},...
'numKids',{0, 2}, ...
'kidsage',{[],[12,9]});
each element people(1), people(2) has three frields (name, numKids, kidsage)
Instead of declaring the structure in one line as above, I would like to define it one field at a time.
The closest working example I've been able to come up with is
people = struct
people.('name') = {'bob, 'john'}
people.('numkids') = {0, 2}
people.('kidsage') = {[], [12, 9]}
But defined in this way, the people structure only has one element.
ie.
people(1) =
name: {'bob' 'john'}
numkids: {[0] [2]}
kidsage: {[] [12, 9]}
Can anyone help?