Using imagesc to show the relation between IPR VS ( \sigma vs E), problem with matrix

2 次查看(过去 30 天)
I calculated the IPR for quantum system. this resulted in an N x 1 vector.
For this IPR there is the related eigenstates and eigenvalues, so we have another the vector for the eigenvalues E, and there is the $/sigma$ values.<br/>
So there is different E & IPR vectors for each sigma.<br/>In the end we have the IPR Matrix (vector matrix for different sigma values), and E matrix (vector matrix for different sigma values) and the vector sigma.<br/> imagesc takes (vector,vector,matrix) or imagesc(E,sigma,IPR). but there is a problem, because E isn't a vector anymore. <br/> how do I solve this? or did I just not understand the imagesc command? the code is below.
I flatten E to try and solve this, but I dont know if this is the right solution.
I also tryed to add it layer by layer and hold it but it also doesnt seem to work
N = 2^9;
z = ones(N-1,1);
c = 1;
ranNum = diag(rand([N 1]));
Nsig = 10^2;
sigma = ones(Nsig,1).';
E = ones(Nsig,N);
IPR = ones(Nsig,N);
for j = 1:Nsig
sigma(j) = 0.01 + 0.01*(j-1);
H1 = c*(diag(z,1)+ diag(z,-1) + diag(1,N-1)+ diag(1,-N+1));
V1 = sigma(j) * ranNum ;
H = H1 + V1;
[psi,~] = eig(H);
E(j,:) = eig(H);
P1 = abs(psi).^2;
IPR(j,:) = sum(P1.^2);
imagesc(E(j,:),sigma(j),IPR(j,:))
colormap('turbo')
colorbar
xlabel('E')
ylabel('sigma')
h = colorbar;
ylabel(h, 'IPR')
hold on
end

回答(1 个)

Image Analyst
Image Analyst 2022-1-16
Try using drawnow; instead of hold on:
N = 2^9;
z = ones(N-1,1);
c = 1;
ranNum = diag(rand([N 1]));
Nsig = 10^2;
sigma = ones(Nsig,1).';
E = ones(Nsig,N);
IPR = ones(Nsig,N);
for j = 1:Nsig
fprintf('j = #%d of %d.\n', j, Nsig)
sigma(j) = 0.01 + 0.01*(j-1);
H1 = c*(diag(z,1)+ diag(z,-1) + diag(1,N-1)+ diag(1,-N+1));
V1 = sigma(j) * ranNum ;
H = H1 + V1;
[psi,~] = eig(H);
E(j,:) = eig(H);
P1 = abs(psi).^2;
IPR(j,:) = sum(P1.^2);
imagesc(E(j,:),sigma(j),IPR(j,:))
colormap('turbo')
colorbar
xlabel('E')
ylabel('sigma')
h = colorbar;
ylabel(h, 'IPR')
% hold on
drawnow;
end

类别

Help CenterFile Exchange 中查找有关 Particle Swarm 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by