List(Vecor) Generation
Mostrar comentarios más antiguos
Can I generate list [1 2 3 2 3 4 3 4 5 4 5 6 ....] without for loop?
Thanks!
Respuesta aceptada
Más respuestas (2)
Walter Roberson
el 8 de Sept. de 2019
T=1:3*n;
Vec = floor(T/3) + mod(T-1,3) + 1;
Andrei Bobrov
el 8 de Sept. de 2019
Editada: Andrei Bobrov
el 8 de Sept. de 2019
m=3;
n=4;
T = 1:m*n;
out = ceil(T/m) + mod(T-1,m);
or
out = floor(T/n) + mod(T-1,m) + 1;
or
out = repmat(1:m,1,n) + repelem(0:n-1,m);
Categorías
Más información sobre MATLAB Classes en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!