MATLAB: Loop through a multi layered structure

loopsstructures

CompanyInfo=struct('ProjectName', '', 'Activities', struct ('Name', '',...
'Length',0,...
'Date', struct ('Day',0, ...
'Month', 0)));
CompanyInfo.Activities = cell (1,3);
Once I have filled in all the fields, I want to calculate the length of each project with a loop, for example, calculating the Length of the first project by adding the length of its activities, but, how can I do it?

Best Answer

Why a loop? Why not simply use brackets to concatenate all lengths into a single vector:
allLengths = [CompanyInfo.Length]