MATLAB: How to reshape every cell in a structure

MATLAB

Hi,
I am trying to reshape every cell in a 1×4 structure with 10 fields. A simplified example would look like this but when I try to reshape every 1×48 cell into 4×12 cells I get the following error: Inputs to STRUCTFUN must be scalar structures.
b = struct('a', {[1:48], [1:48], [1:48], [1:48]})
structfun(@(a) reshape(a, 12, 4), b, 'UniformOutput', false)
Thoughts ?

Best Answer

arrayfun(@(x) reshape(b(x).a, 12, 4), 1:numel(b), 'UniformOutput', false)