Expanding the existing Matrix

2 views (last 30 days)
Artele
Artele on 23 Feb 2020
Edited: Stephen23 on 23 Feb 2020
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

Accepted Answer

Stephen23
Stephen23 on 23 Feb 2020
Edited: Stephen23 on 23 Feb 2020
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.

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!