I want to stack each row of a matrix A in Matlab a **different** number of times according to what is reported in the vector `count`. To do that I use `repmat` in the following way: 

```
counts=[524282; 524286; 524283; 524290];
A=randn(4,19); 
f=@() cell2mat(arrayfun(@(x) repmat(A(x,:),counts(x),1), 1:size(counts,1), 'UniformOutput', 0)');
timeit(f)

```

The code takes approx 0.45 sec. 

Would you be able to suggest anything faster?