I have a huge dynamic structure. It looks something like this:
s.one.name = 'Mr. Doe';
s.one.time = '12:00';
s.one.ID = '209';
s.one.data = 'Data1';
s.two.name = 'Ms. Jane';
s.two.time = '13:00';
s.two.ID = '210';
s.two.data = 'Data2';
s.three.name = 'Ms. Alice';
s.three.time = '14:00';
s.three.ID = '212';
s.three.data = 'Data3';
s.four.name = 'Mr. Smith';
s.four.time = '14:00';
s.four.ID = '212';
s.four.data = 'Data4';
Now, I want to access and store only the first two fields one
and two
(out of all the given fields) and its corresponding data into a new dynamic structure snew
.
I have tried doing the following things:
for ii = 1:2
snew = [s.(ii)];
end
Error: Argument to dynamic structure reference must evaluate to a valid field name.
Could anyone help me out in acheiving this task?
Thank you in advance