MATLAB: Take each item in a cell array, duplicate it, and rearrange to a longer list in a column vector

cell arrays

I have a cell array:
A = {a,b,c,d}
I'd like to transpose this into the following format, by specifically duplicating each element x number of times and arranging them as a column
B =
{a,
a,
b,
b,
…}

Best Answer

You may be looking for repelem:
repelem(A, x)'