%How can i create this vector? Please I need your help.
Mostrar comentarios más antiguos
Vector = [1 1 1 1 1 0 0 2 2 2 2 2 0 0 3 3 3 3 3 ...];
2 comentarios
Dennis
el 9 de Mayo de 2018
What pattern do you want? I see 1 block of 1s, 3 blocks of 2s, so you want 5/6 blocks of 3s?
Maryam John
el 9 de Mayo de 2018
Respuesta aceptada
Más respuestas (2)
John D'Errico
el 9 de Mayo de 2018
1 voto
help repelem
Simple use of repelem and basic MATLAB indexing:
V = repelem(1:50,7);
V(6:7:end) = 0;
V(7:7:end) = 0;
Or for older MATLAB versions:
V = repmat(1:50,7,1);
V(6:7,:) = 0;
V = reshape(V,1,[]);
Categorías
Más información sobre Matrix Indexing 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!