kronecker product by number of iteration

조회 수: 2 (최근 30일)
Akmyrat
Akmyrat 2014년 7월 7일
댓글: Geoff Hayes 2014년 7월 9일
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)

채택된 답변

Geoff Hayes
Geoff Hayes 2014년 7월 8일
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
Akmyrat
Akmyrat 2014년 7월 9일
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!!
Geoff Hayes
Geoff Hayes 2014년 7월 9일
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.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by