matrix repetition

20 次查看(过去 30 天)
zozo
zozo 2012-1-9
Hello,
I have a matrix M of dimensions (m by n). I want to repeat this matrix 'k' number of times along the column.
For example:
If
M=[1 3 4 5;4 5 6 7;9 3 4 2]
and k=4(say),then
out=[1 3 4 5 1 3 4 5 1 3 4 5 1 3 4 5;4 5 6 7 4 5 6 7 4 5 6 7 4 5 6 7;9 3 4 2 9 3 4 2 9 3 4 2 9 3 4 2]
please help.

采纳的回答

Rick Rosson
Rick Rosson 2012-1-9
out = repmat(M,1,k);

更多回答(1 个)

Walter Roberson
Walter Roberson 2012-1-9
repmat(M, 1, 4)
(Note: your example only uses 3 repetitions for the first row)
  1 个评论
zozo
zozo 2012-1-9
sorry..it shud be 4. dats my mistake.
thanks! :)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by