How to repeat indivisual element of a matrix?

Suppose, i have a matrix a=[1 0 1 1 0 0 1 1] and i want to repeat every element of this matrix by 3 times using for loop . as the new matrix will be b=[1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1] . How easily can solve??

 Respuesta aceptada

Rene Riha
Rene Riha el 17 de Mzo. de 2018

0 votos

for i=1:length(a)
b(3*i-2:3*i)=a(i);
end

2 comentarios

Saiem Solimullah
Saiem Solimullah el 19 de Mzo. de 2018
Thank you... this is helpful..
Saiem Solimullah
Saiem Solimullah el 21 de Mzo. de 2018
mam, can u help me with the rebuilt of vector a using for loop please?

Iniciar sesión para comentar.

Más respuestas (1)

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 17 de Mzo. de 2018

Comentada:

el 21 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by