1 view (last 30 days)

Hello,

Ihave this code:

function [A,B] = trying(d)

A=zeros(d,d,2,d);

sigma_x = [0,1;1,0];

sigma_z = [1,0;0,-1];

if d==2

x = sigma_x;

z = sigma_z;

end

if d==4

x = kron(sigma_x,sigma_x);

z = kron(sigma_z,sigma_z);

end

[xv1,xv2] = eig(x);

%xv1 = [xv1(:,2),xv1(:,1)];

[zv1,zv2] = eig(z);

%zv1 = [zv1(:,2),zv1(:,1)];

for i=1:d

% for k = 1:2

A(:,:,1,i)= xv1(:,i)*transpose(xv1(:,i));

A(:,:,2,i)= zv1(:,i)*transpose(zv1(:,i));

% end

end

end

However, I have inverse result For instance the result should be like that:

A(:,:,1,1) =

0.5000 0.5000

0.5000 0.5000

A(:,:,2,1) =

1 0

0 1

A(:,:,1,2) =

0.5000 -0.5000

-0.5000 0.5000

But I have this result:

A(:,:,1,1) =

0.5000 -0.5000

-0.5000 0.5000

A(:,:,2,1) =

0 0

0 1

A(:,:,1,2) =

0.5000 0.5000

0.5000 0.5000

So I tried the that But it did not work

xv1 = [xv1(:,2),xv1(:,1)];

zv1 = [zv1(:,2),zv1(:,1)];

for i=1:d

for k = 1:2

A(:,:,1,i)= xv1(:,k)*transpose(xv1(:,k));

A(:,:,2,i)= zv1(:,k)*transpose(zv1(:,k));

end

end

Any idea?

Christine Tobler
on 7 Jul 2020

Christine Tobler
on 10 Jul 2020

Opportunities for recent engineering grads.

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

Start Hunting!
## 2 Comments

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/560495-result-of-a-1-1-coming-as-result-of-a-1-2#comment_927275

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/560495-result-of-a-1-1-coming-as-result-of-a-1-2#comment_927275

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/560495-result-of-a-1-1-coming-as-result-of-a-1-2#comment_927287

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/560495-result-of-a-1-1-coming-as-result-of-a-1-2#comment_927287

Sign in to comment.