Creating a Vector with specified entries

조회 수: 3 (최근 30일)
Kevin
Kevin 2013년 8월 8일
Hey guys,
I'd like to create a vector that goes from 1 to n that looks like this:
[1 1 2 2 3 3 ... n n]
Any ideas?
KD

채택된 답변

per isakson
per isakson 2013년 8월 8일
This is better
n = 12;
num = repmat( [1:n], 2, 1 );
num = transpose( num(:) )

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by