Elements of Array Should not be the Same

1 visualización (últimos 30 días)
Gözde Üstün
Gözde Üstün el 25 de Jun. de 2020
Comentada: Gözde Üstün el 28 de Jun. de 2020
Hello,
I have this value for element of my list:
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
  2 comentarios
madhan ravi
madhan ravi el 25 de Jun. de 2020
Please provide the full error message. And d?
Gözde Üstün
Gözde Üstün el 25 de Jun. de 2020
Editada: Gözde Üstün el 25 de Jun. de 2020
There is no error message but as you can see I have different value for projectors_of_sigma_x = [1/sqrt(2)*[1;1],1/sqrt(2)*[1;-1]]; (v1 and v2 you can see from the images clearly) but for the A(:,:1,1) and A(:,:,1,2) I have the same matrix and d is = 2

Iniciar sesión para comentar.

Respuesta aceptada

madhan ravi
madhan ravi el 25 de Jun. de 2020
Editada: madhan ravi el 25 de Jun. de 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 comentarios
madhan ravi
madhan ravi el 28 de Jun. de 2020
When do you need ? I don't have time to analyse that sorry :( . I see that you have asked the same question already!
Gözde Üstün
Gözde Üstün el 28 de Jun. de 2020
Ahh no worries! I can wait (till the tuesday) Yeah I asked and each question includes different version of my combination because I have tried too many combiations

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by