How to perform repmat function to repeat rows of a matrix
52 次查看(过去 30 天)
显示 更早的评论
A=[1,0,0,0,1;2,0,0,0,2;3,0,0,0,3]
I would like to repeat each row for n times and get output something like this when n is 2:
output=[1,0,0,0,1;1,0,0,0,1;2,0,0,0,2;2,0,0,0,2;3,0,0,0,3;3,0,0,0,3]
0 个评论
采纳的回答
更多回答(5 个)
Bruno Luong
2022-8-19
A=[1,0,0,0,1;2,0,0,0,2;3,0,0,0,3]
reshape(repmat(reshape(A,1,1,[]),2,1,1),[],size(A,2))
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!