Creating a Vector with specified entries

4 次查看(过去 30 天)
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