MATLAB: Expanding the existing Matrix

expand matrixmatrix

Hello,
I have matrix 365 x 1, how can I expand the matrix into 8760 x 1 -> (365 times 24), replacing all the newly added numbers with every 24th number.
eg: matrix [2,4,5,2,3 …. ] -> [2,2,2,2,2,…,2,2,4,4,4,…,4,4,4,…and so on).
I would be really grateful for help

Best Answer

Use repelem or kron, e.g. where V is your input vector:
Z = repelem(V,24)
or
Z = kron(V,ones(24,1)) % adjust to suit V's orientation.