Using nested loops to solve kronecker product

조회 수: 1 (최근 30일)
Wei Hern
Wei Hern 2013년 12월 8일
댓글: sixwwwwww 2013년 12월 9일
dear all, my question is how do solve kronecker's product of a 10x10 matrix or any matrix size using nested loops rather than the conventional Kron function.
for eg,
aa=round(rand(10,10)*10-5)
bb=round(rand(10,10)*20-10)
what do i write in the script to solve the multiplication of aa*bb using kroneckers rule.
thanks!

채택된 답변

sixwwwwww
sixwwwwww 2013년 12월 8일
편집: sixwwwwww 2013년 12월 8일
you can do it as follows(if you have square matrices of same size):
A = round(rand(10,10)*10-5);
B = round(rand(10,10)*20-10);
for i = 1:size(A, 1)
for j = 1:size(A, 2)
AB{i, j} = A(i, j) * B;
end
end
AB = cell2mat(AB);
disp(AB)
Good luck!
  댓글 수: 4
Wei Hern
Wei Hern 2013년 12월 9일
yes it works now! and I'm guessing that when i change the first value of the matrix, it would also be able to calculate no matter what the size of the matrix is? thanks heaps!
sixwwwwww
sixwwwwww 2013년 12월 9일
you are welcome. you can accept this answer if it is helpful to you

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by