How make this matrix using for loop?

-1 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0
-1 -1 0 0 0 0 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 0 0 0 0 0
-1 -1 -1 0 0 0 0 0 0 0 0 0 0 0
1 1 1 0 0 0 0 0 0 0 0 0 0 0
-1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0
1 1 1 1 0 0 0 0 0 0 0 0 0 0
-1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0
1 1 1 1 1 0 0 0 0 0 0 0 0 0

 Respuesta aceptada

Stephen23
Stephen23 el 20 de Sept. de 2017

0 votos

Why use a loop?
>> M = zeros(10,14);
>> M(1:2:end,1:5) = -tril(ones(5));
>> M(2:2:end,1:5) = +tril(ones(5));

1 comentario

Jeong_evolution
Jeong_evolution el 20 de Sept. de 2017
excellent. thanks..
I think just use for loop...

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 루프와 조건문 en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 20 de Sept. de 2017

Comentada:

el 20 de Sept. de 2017

Community Treasure Hunt

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

Start Hunting!