MATLAB: How can i access field values of a struct by indexing

arrayfieldindexingMATLABmatrixstructures

My struct has several fields containing a matrix. How can I get the first 100 values of each field without using a for loop.
a = b.(fieldnames(b))(1:100,:); % wont work

Best Answer

a = structfun(@(F) F(1:100,:), b, 'uniform', 0)