필터 지우기
필터 지우기

Tensor Product According to Input (Dynamically)

조회 수: 2 (최근 30일)
Gözde Üstün
Gözde Üstün 2020년 7월 3일
댓글: Gözde Üstün 2020년 7월 6일
Hello:
I am trying to use tensor product according to inout number d
How can I write this code better? I am asking that becuase if I have 100 for d I cant write if by hand I want to write more clever things with for but I dont know
function A = td(d)
sigma_x = [0,1;1,0];
if d ==2
A = sigma_x;
if d ==4
A = kron(sigma_x,sigma_x);
end
if d == 8
A = kron(kron(sigma_x,sigma_x),sigma_x);
end
if d ==16
A = kron(kron(kron(sigma_x,sigma_x),sigma_x),sigma_x);
end

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2020년 7월 6일
If your variable sigma_x is 90 rotated eye matrix, then you can use
A = rot90(eye(d));
Good luck
  댓글 수: 1
Gözde Üstün
Gözde Üstün 2020년 7월 6일
my variable first variable is :
0 1
1 0
my second variable is:
1 0
0 -1

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

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by