MATLAB Answers

Second Element is not 1 but It is coming as 1

1 view (last 30 days)
Hello,
I have this matrix:
I saved this matrix in a list like : projectors_of_sigma_x_minus_sigma_z = [[(sqrt(2)-1);1],[(-sqrt(2)-1);1]];
and this is my code :
function B = CHSHmeasurement
B=zeros(2,2,2,2);
projectors_of_sigma_x_minus_sigma_z = [[(sqrt(2)-1);1],[(-sqrt(2)-1);1]];
B(:,:,2,1) = projectors_of_sigma_x_minus_sigma_z(1);
B(:,:,2,2) = projectors_of_sigma_x_minus_sigma_z(2);
end
But I have this result:
However I have not 1 as the second element of projectors_of_sigma_x_minus_sigma_z. I have [(-sqrt(2)-1);1] for the second element of projectors_of_sigma_x_minus_sigma_z(2); Where am I wrong ?

  0 Comments

Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 25 Jun 2020
Edited: madhan ravi on 25 Jun 2020
>> B=zeros(2,2,2,2);
projectors_of_sigma_x_minus_sigma_z = [[(sqrt(2)-1);1],[(-sqrt(2)-1);1]]
B(:,:,2,1) = projectors_of_sigma_x_minus_sigma_z(1)
B(:,:,2,2) = projectors_of_sigma_x_minus_sigma_z(2)
projectors_of_sigma_x_minus_sigma_z =
0.4142 -2.4142
1.0000 1.0000
B(:,:,1,1) =
0 0
0 0
B(:,:,2,1) =
0.4142 0.4142
0.4142 0.4142
B(:,:,1,2) =
0 0
0 0
B(:,:,2,2) =
0 0
0 0
B(:,:,1,1) =
0 0
0 0
B(:,:,2,1) =
0.4142 0.4142
0.4142 0.4142
B(:,:,1,2) =
0 0
0 0
B(:,:,2,2) =
1 1
1 1
>>
You're copying a scalar to that entire page.

  9 Comments

Show 6 older comments
Gözde Üstün
Gözde Üstün on 26 Jun 2020
I am actually trying that:
function [A,B] = CHSHmeasurement(d)
A=zeros(d,d,2,d);
B=A;
projectors_of_sigma_x = [1/sqrt(2)*[1;1],1/sqrt(2)*[1;-1]];
projectors_of_sigma_x_minus_sigma_z = [[(sqrt(2)-1);1],[(-sqrt(2)-1);1]];
for k = 1:d
for l =1:length(projectors_of_sigma_x)
% A(k,k,1,k)=projectors_of_sigma_x(l);
A(:,:,1,k)=repmat(projectors_of_sigma_x(l),2,2);
end
for o = 1: length(projectors_of_sigma_x_minus_sigma_z)
%B(k,k,2,k)=projectors_of_sigma_x_minus_sigma_z(o);
B(:,:,2,k)=repmat(projectors_of_sigma_x_minus_sigma_z(o),2,2);
end
end
end
But I have a wrong result
Gözde Üstün
Gözde Üstün on 26 Jun 2020
And Sorry I missed your previous answer
projectors_of_sigma_x_minus_sigma_z(:, 1)
This is for what ?
Gözde Üstün
Gözde Üstün on 26 Jun 2020
Sorry I just saw your answer now Thank you very much :)

Sign in to comment.

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!