kronecker product by number of iteration

lets say A=[1 2;3 4], i want for i=1:5 times, to multiply A itself kronecker product. in this case ,manual will be kron(kron(kron(kron(kron(A,A),A),A),A),A)

 Respuesta aceptada

Geoff Hayes
Geoff Hayes el 8 de Jul. de 2014
Unless you are looking for a way to do this in one line of code, a simple for loop would do the trick
A = [1 2;3 4];
B = A;
for k=1:5
B = kron(B,A);
end

4 comentarios

Akmyrat
Akmyrat el 8 de Jul. de 2014
Editada: Star Strider el 8 de Jul. de 2014
I=[1 0;0 1]
F=[2 1;1 2]
for i=1:3
B=i+1;
end
if B<=3
A(i)=I
elseif B>3
A(i)=F
end
kron(kron(A(1),A(2)),A(3))
the result i want in auto basis, with i-iteration, Kron product by itself, if for example i change i=1:4, then result should be: kron(kron(kron(A(1),A(2)),A(3)),A(4))
please can u try...thanks !
Do you mean for your if statement to be in the for loop?
Your use of A(i) is invalid. Try it, and you will observe the In an assignment A(I) = B, the number of elements in B and I must be the same. You could use a 3D matrix instead
% pre-allocate memory to A
n = 3;
A = zeros(2,2,n);
for k=1:n
if (i+1)<=3
A(:,:,k)=I;
else
A(:,:,k)=F;
end
end
Then the Kron product would be
B = A(:,:,1);
for k=1:n
B = kron(B,A(:,:,k));
end
Akmyrat
Akmyrat el 9 de Jul. de 2014
Goeff can You please see this also !!!??
F2=[1 0 0 0;0 0 0 1]; I=[1 0;0 1]; A=[1 0 0 ;1 1 0;0 1 0]; for i=1:3 B=0; for j=1:3 B=B+A(i,j); end if B==1; R=I else B==2; R=F2 end PTM1=R; for k=i-1 PTM1 = kron(PTM1,R) end end
%% this code kron prod by each iteration it self (Kron(I,I), kron(F2,F2) ans so on..) , but i want like this result: kron(kron(I,F2),I) %% whis kron product of all iteration answers.
thanks in advance!!
Akymrat - Please format the above code so that it is readable. Highlight the code and press the {}Code button.
There is a bug in the code with the
else
B==2;
R=F2
end
I suspect you meant
elseif B==2
Please make the correction and address the case where B is neither 1 nor 2.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Elementary Math en Centro de ayuda y File Exchange.

Preguntada:

el 7 de Jul. de 2014

Comentada:

el 9 de Jul. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by