replicate values of a vector
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Friedrich
2012년 5월 23일
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)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!