MATLAB: Copy cells a variable number of times

arraycell arraycell manipulationcopy cellcopy matrix

Hi all
i have this code
for i=1:length(a)
C(i)=repmat(b(i),1,a(i))
end
where b is a cell array
16x5 double
16x5 double
13x5 double
and a is an array
[101,17,1]
i want to copy the first cell 101 times, the second cell, 17 times and last cell only one time, but using the upper code i can't do that…any idea?
Thank you for the help!!
Regards

Best Answer

for i=1:length(a)
C{i}=repmat(b{i},1,a(i));
end