MATLAB: How to repeat rows in fields of structure

arrayfunMATLABrepmat

The existing strucure has to be expanded along rows of fields. The actual structure contains many fieldsnames and rows in them.
s.a=[1;2;3];
s.b=[9 1; 5 4; 3 7];
The rows have to be repeated to certain number of rows say 53.
I have used arrayfun and repmat, but error of size mismatch is shown.
Without use of for loop, how is it possible.

Best Answer

Note that practically, there is no difference between arrayfun, structfun, etc. and a loop. If anything, arrayfun can be slower than a loop.
I suspect that what you want is structfun which applies the same function to each field of the structure:
news = structfun(@(fld) repmat(fld, 53, 1), s, 'UniformOutput', false)