Taking the kronecker product of multiple matricies, nested in an array

15 vues (au cours des 30 derniers jours)
Dipie11
Dipie11 le 9 Jan 2019
Modifié(e) : Stephen23 le 9 Jan 2019
I have a vector array that looks like this,
M = [A B B A A B]
where the A's and B's in the vector are matricies given by,
A = [1 1; 0 1]
B = [1 0; 1 0]
Basically, what I'd like to do is to take the kronecker product of all of the A's and B's in the vector M using a loop and to then store it in a new matrix S. The hard coded example would be,
S = kron(kron(kron(kron(kron(A,B),B),A),A),B);
Is there any way of doing this?
Thank you very much in advance for your help.

Réponse acceptée

Stephen23
Stephen23 le 9 Jan 2019
Modifié(e) : Stephen23 le 9 Jan 2019
A = [1,1;0,1];
B = [1,0;1,0];
C = {A,B,B,A,A,B};
S = C{1};
for k = 2:numel(C)
S = kron(S,C{k});
end

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by