MATLAB: Easiest Way to Assign Graphics Objects to a 1-by-n Struct

struct

How to assign graphics objects to a 1-by-5 struct field? Is there an easier way than using a for loop and assign the values elementwise?
When there is more than one row, it works perfectly and I get 10 rectangles:
Rectangles1(2, 5).r = rectangle();
But when I run the code below with only one row, MATLAB only creates one rectangle, instead of 5 rectangles?
Rectangles2(1, 5).r = rectangle();

Best Answer

template = ones(2,5); %shape matters, content does not
Rectangles2 = cell2mat( arrayfun( @(r) struct('r', rectangle()), template, 'Uniform', 0) );
This will, however, overwrite the entire contents of Rectangles2