MATLAB: Determine total length/size of a structure array with fields as structure arrays
问题 I have a structure array containing fields as structure arrays of varying length. For example: 's' is a structure 'data' is a field in 's', and also a structure array itself and length(s(n).data) ~= length(s(m).data) I want to preallocate an array that takes a time stamp from every field s.data.timestamp. Is there a way to do this without using a for loop twice? This is what I have so far: % find the total length count=0; for x=1:length(s) count=count+length(s(x).data); end % preallocate