Create a matrix (24,72) using 'for' loop.
Mostrar comentarios más antiguos
How can I use the loop 'for' or other, to produce the same matrix (24,72) depicted in the figure? kind regards.

Respuesta aceptada
Más respuestas (1)
Brendan Hamm
el 15 de En. de 2016
You could do this with a loop:
A = ones(24,72);
for k = 1:72
if rem(k,3) == 0
A(:,k) = 0;
end
end
or you could do this in one line:
A = repmat([1 1 0],24,72/3);
The latter is much faster and more elegant.
1 comentario
ET-TAOUSSI mehdi
el 16 de En. de 2016
Categorías
Más información sobre Loops and Conditional Statements 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!