Duplicating rows in a matrix
显示 更早的评论
Hi there
I have a matrix that i need to make twice as long. i.e i need to double the length of columns. eg i need:
[0 1 0 0]
[0 2 0 0]
to become:
[0 1 0 0]
[0 1 0 0]
[0 2 0 0]
[0 2 0 0]
Thanks
1 个评论
Just use REPELEM: https://www.mathworks.com/help/matlab/ref/repelem.html
A = [0,1,0,0;0,2,0,0]
B = repelem(A,2,1)
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!