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 个评论
Ahmed Hussein
Ahmed Hussein 2013-6-28
编辑:Ahmed Hussein 2013-6-28
A=[0 0 0 I want A to be A=[ 0 0 0 0 0 0 . 0 0 0 . . . . and so on to 200 times then the second element and so on.

请先登录,再进行评论。

采纳的回答

Roger Stafford
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 个评论
Ahmed Hussein
Ahmed Hussein 2013-6-28
Thanks a lot, it is very useful.....
Roger Stafford
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 CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by