How do I access structure fields dynamically?
Try dynamic field reference where you put a string in the parenthesis as seen on the line defining stuff. S = struct(‘A’, [1 2], ‘B’,[3 4 5]); SNames = fieldnames(S); for loopIndex = 1:numel(SNames) stuff = S.(SNames{loopIndex}) end I concur with Steve and Adam. Use cells. This syntax is right for people in other situations … Read more