Fastest & most effective way to create this matrix:

1 visualización (últimos 30 días)
Eitan
Eitan el 19 de Dic. de 2014
Comentada: Sean de Wolski el 19 de Dic. de 2014
Hey there, I have been searching for hours for a good solution & not found one yet. I need to create this matrix (6X6):
A = 0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 1 2 3
0 0 0 4 5 6
0 0 0 7 8 9
It must be in an effective & short way. Thank you if anyone can help with this one.

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 19 de Dic. de 2014
one way
a =[1 2 3
4 5 6
7 8 9];
out = kron([0 0 ; 0 1],a);

Más respuestas (1)

Orion
Orion el 19 de Dic. de 2014
Editada: Orion el 19 de Dic. de 2014
clear A;
A(4:6,4:6) = reshape(1:9,3,3)'
  2 comentarios
Eitan
Eitan el 19 de Dic. de 2014
Thank you! I actually used that code because it looks shorter. you guys are great!
Sean de Wolski
Sean de Wolski el 19 de Dic. de 2014
I'd expect this to be the fastest way to do this.

Iniciar sesión para comentar.

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by