필터 지우기
필터 지우기

matrix repetition

조회 수: 2 (최근 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.
  댓글 수: 1
Andrei Bobrov
Andrei Bobrov 2012년 1월 9일
reshape(M(:,:,ones(k,1)),size(M,1),[])

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

채택된 답변

Rick Rosson
Rick Rosson 2012년 1월 9일
out = repmat(M,1,k);
  댓글 수: 1
zozo
zozo 2012년 1월 9일
Thank you sir! :)

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

추가 답변 (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에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by