MATLAB: Access to nested structs MATLABnested structs I have a struct say a.b.c.d, but want to avoid hard coded 'b.c.d'. Ist there an easy way to access the data dynamically, for example with a cell field like {'b' 'c' 'd'}? Best Answer Use getfield with a comma-separated list:a.b.c.d = pi;x = {'b','c','d'};getfield(a,x{:})ans = 3.1416https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.htmlhttps://www.mathworks.com/matlabcentral/answers/320713-how-to-operate-on-comma-separated-lists Related SolutionsMATLAB: Access Field from Struct You need to use concatenation brackets [ ]a=[structname.MeansArea]Read here: https://www.mathworks.com/help/matlab/ref/double.cat.html MATLAB: How to save cell array of workspace vars into mat save('test.mat', vars{:})How it works:https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.htmlhttps://www.mathworks.com/matlabcentral/answers/320713-how-to-operate-on-comma-separated-lists Related QuestionDo I Get This Error for This Non-scalar StructureHow to extract and organize data in a structureHelp with nested structureAdd a new array to a strucure
Best Answer