Creating a Vector with specified entries

4 visualizaciones (últimos 30 días)
Kevin
Kevin el 8 de Ag. de 2013
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

Respuesta aceptada

per isakson
per isakson el 8 de Ag. de 2013
This is better
n = 12;
num = repmat( [1:n], 2, 1 );
num = transpose( num(:) )

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by