Use of kron with more than two matricies

19 ビュー (過去 30 日間)
Ashton Linney
Ashton Linney 2020 年 3 月 25 日
コメント済み: Matt J 2020 年 3 月 25 日
I have four 4x4 matricies called: ox, ru, cr, po.
I have been successful in using the Kronecker tensor product for two of the matricies, I being a 4x4 identity matrix.
mat = kron(I,ox) + kron(ru,I);
However, when I try doing the same with all four matricies...
mat = kron(I,I,I,ox) + kron(I,I,ru,I) + kron(I,cr,I,I) + kron(po,I,I,I);
I get an error saying 'Too many input arguments.'
Is here a way to achieve the result for four matricies?
Thank you.

採用された回答

Matt J
Matt J 2020 年 3 月 25 日
編集済み: Matt J 2020 年 3 月 25 日
One way would be to use my KronProd class
as follows,
kp=@(A,B,C,D) sparse(KronProd{D,C,B,A});
mat = kp(I,I,I,ox) + kp(I,I,ru,I) + kp(I,cr,I,I) + kp(po,I,I,I);
  2 件のコメント
Ashton Linney
Ashton Linney 2020 年 3 月 25 日
Thank you Matt! I have used the class and it has achieved what I was hoping for perfectly.
Matt J
Matt J 2020 年 3 月 25 日
You're welcome. You could also do it without the class, as follows,
kp=@(A,B,C,D) kron(kron(A,B),kron(C,D));
mat = kp(I,I,I,ox) + kp(I,I,ru,I) + kp(I,cr,I,I) + kp(po,I,I,I);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by