Elements of Array Should not be the Same
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Gözde Üstün
am 25 Jun. 2020
Kommentiert: Gözde Üstün
am 28 Jun. 2020
Hello,
I have this value for element of my list:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/322066/image.png)
And I have this code:
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]];
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)=projectors_of_sigma_x(l);
end
end
end
However I have the same element for A although I have the different elements in the projectors_of_sigma_x
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/322069/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/322072/image.png)
2 Kommentare
Akzeptierte Antwort
madhan ravi
am 25 Jun. 2020
Bearbeitet: madhan ravi
am 25 Jun. 2020
for k = 1:d
for l =1:d
A(:,:,1,k) = repmat(projectors_of_sigma_x(:,k), 1, d);
end
end
I suggest you to read https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html , first deal with 2D matrices before dealing with higher dimension matrices.
4 Kommentare
madhan ravi
am 28 Jun. 2020
When do you need ? I don't have time to analyse that sorry :( . I see that you have asked the same question already!
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Operating on Diagonal Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!