Repeat every element in matrix
2 次查看(过去 30 天)
显示 更早的评论
Dears,
I have a matrix A(3200,3), I want to repeat each element (not repeat the matrix)in this matrix 200 times.
Thank you
2 个评论
采纳的回答
Roger Stafford
2013-6-28
编辑:Roger Stafford
2013-6-28
A = reshape(repmat(A(:)',200,1),[],3);
This repeats the elements in the columns. If you want to repeat the along the rows do this:
A = reshape(repmat(reshape(A',[],1),1,200)',[],size(A,1))';
(Corrected)
4 个评论
Roger Stafford
2013-6-29
That code I gave you has one more transpose than is necessary. You can do it this way instead:
A = reshape(repmat(reshape(A',1,[]),200,1),[],size(A,1))';
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!