Tensor Product According to Input (Dynamically)

2 visualizaciones (últimos 30 días)
Gözde Üstün
Gözde Üstün el 3 de Jul. de 2020
Comentada: Gözde Üstün el 6 de Jul. de 2020
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

Respuestas (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 6 de Jul. de 2020
If your variable sigma_x is 90 rotated eye matrix, then you can use
A = rot90(eye(d));
Good luck
  1 comentario
Gözde Üstün
Gözde Üstün el 6 de Jul. de 2020
my variable first variable is :
0 1
1 0
my second variable is:
1 0
0 -1

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by