Dear all,
I have, say the vector A=(1:12)'; and I want to replicate each of the 12 numbers 4 times. Any simple code for this?
thanks in advance

 채택된 답변

Friedrich
Friedrich 2012년 5월 23일

0 개 추천

Hi,
try repmat:
repmat(A,4,1)
Or for the other direction:
repmat(A,1,4)
In the case you want it repeated like this: [1 1 1 1 2 2 2 2 ....] you can use repmat and reshape:
reshape(repmat(A,4,1),[],1)

댓글 수: 2

antonet
antonet 2012년 5월 23일
thank you friedrich!
Andrei Bobrov
Andrei Bobrov 2012년 5월 23일
kron(A,ones(4,1))

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

추가 답변 (0개)

카테고리

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

질문:

2012년 5월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by