matrix repetition

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.

댓글 수: 1

Andrei Bobrov
Andrei Bobrov 2012년 1월 9일
reshape(M(:,:,ones(k,1)),size(M,1),[])

댓글을 달려면 로그인하십시오.

 채택된 답변

Rick Rosson
Rick Rosson 2012년 1월 9일

1 개 추천

out = repmat(M,1,k);

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 1월 9일

1 개 추천

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! :)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2012년 1월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by