How do I create a density plot?
3 views (last 30 days)
Show older comments
Hi, I'm trying to make a density plot using pcolor that shows we1 on one axis, t on the other and the colour map as the trace distance between the matrices I've defined. I just want to produce a list of values for varying we1 and t but I get the error:
Error using * Inner matrix dimensions must agree.
Error in Untitled8 (line 16) H1=we1*kron(PauliX,eye(2))+A1*(kron(PauliX,PauliX)+kron(PauliY,PauliY)+kron(PauliZ,PauliZ));
How should I do this differently?
n=0.1;
we1=0:0.001:n;
m=500;
t=0:m;
A1=0.00448;
PauliX=[0 1; 1 0];
PauliY=[0 -1i; 1i 0];
PauliZ=[1 0; 0 -1];
rhoE=[0.5 + 0.115047 0.564418 - 0.0959956*1i; 0.564418 + 0.0959956*1i 0.5 - 0.115047];
rhoN=[0.5 0; 0 0.5];
rhoEN=kron(rhoE,rhoN);
SWAP=[1 0 0 0; 0 0 1 0; 0 1 0 0; 0 0 0 1];
for i=1:length(t)
for j=0:length(we1)
H1=we1.*kron(PauliX,eye(2))+A1*(kron(PauliX,PauliX)+kron(PauliY,PauliY)+kron(PauliZ,PauliZ));
U1=expm(-1i*H1*t);
rhoENout=U1*rhoEN*U1';
USWAP=expm(-1i*SWAP*t);
SWAPout=USWAP*rhoEN*USWAP';
tdSWAPEN1=(rhoENout-SWAPout)^2;
tdSWAPEN2=sqrt(sum(tdSWAPEN1(:)));
end
end
X=we1;
Y=t;
C=tdSWAPEN2;
pcolor(X,Y,C)
axis equal tight
2 Comments
Dan Gianotti
on 4 Aug 2017
Edited: Dan Gianotti
on 4 Aug 2017
I haven't looked too closely at what you're trying to do, but at least one problem is in this part:
we1.*kron(PauliX,eye(2))
since size(we1) is [1,101] and size(kron(...)) is [4,4].
Answers (0)
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!