How do I double the size of a given matrix?

5 次查看(过去 30 天)
A = [ 1 2
3 4
]
I want to double the size of matrix A by adding a duplicate of row 1 underneath it.
And also adding a duplicate of row 2 underneath it.
This is a simple example, but I will be doing this for a much larger matrix of 300x500. What is the best way to tackle this?
B = [ 1 2
1 2
3 4
3 4
]

回答(1 个)

KSSV
KSSV 2022-4-8
编辑:KSSV 2022-4-8
A = [ 1 2
3 4] ;
iwant = repelem(A,2,1)
iwant = 4×2
1 2 1 2 3 4 3 4

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by