Fastest & most effective way to create this matrix:

조회 수: 1 (최근 30일)
Eitan
Eitan 2014년 12월 19일
댓글: Sean de Wolski 2014년 12월 19일
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.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2014년 12월 19일
one way
a =[1 2 3
4 5 6
7 8 9];
out = kron([0 0 ; 0 1],a);

추가 답변 (1개)

Orion
Orion 2014년 12월 19일
편집: Orion 2014년 12월 19일
clear A;
A(4:6,4:6) = reshape(1:9,3,3)'
  댓글 수: 2
Eitan
Eitan 2014년 12월 19일
Thank you! I actually used that code because it looks shorter. you guys are great!
Sean de Wolski
Sean de Wolski 2014년 12월 19일
I'd expect this to be the fastest way to do this.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by