I have a nested for loop and would like to create named fields within the first loop and then save to that field within the next loop. Something like the below code where the first iteration would create structure.first and add 'works' to that field. Thanks!
structure = [];
namelist = ['first', 'second', 'third'];
p = 5;
for i = 1:p
structure(end+1) = struct(namelist(i), {});
for j = 1:10
if condition = true
structure(j).namelist(i) = 'works';
end
end
end
if condition = truecase, should that bestructure(j)...?