Borrar filtros
Borrar filtros

array manipulation such as [ 1 2 5 7 3 .... ] --> [ 1 1 1 ... 2 2 2 ... 5 5 5 ... 7 7 7 ... 3 3 3 ... .... ].

1 visualización (últimos 30 días)
JK
JK el 17 de Sept. de 2017
Respondida: Jan el 17 de Sept. de 2017
Using
A = [ 1 2 5 7 3 .... ],
I would like to create
B = [ 1 1 1 ... 2 2 2 ... 5 5 5 ... 7 7 7 ... 3 3 3 ... .... ]
Can you please show me a way to do that? Thanks.

Respuesta aceptada

Jan
Jan el 17 de Sept. de 2017
repelem(A, 3)

Más respuestas (1)

michio
michio el 17 de Sept. de 2017
A = [ 1 2 5 7 3];
tmp = repmat(A,[3,1]);
B = tmp(:)';

Categorías

Más información sobre Multidimensional Arrays 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