MATLAB: Cell operation

cell cat

There is a cell array. A = {'ab', 'bc', 'cd'};
I'd like to get a new cell array, like: B = {'ab', 'ab', 'ab', 'bc', 'bc', 'bc', 'cd', 'cd', 'cd'}.
How to get this without using loop?
Thanks

Best Answer

B = repmat(A, 3, 1); %do the duplication
B = B(:).' ; turn the result in to a row vector
Related Question