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

2 visualizaciones (últimos 30 días)
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

Respuestas (1)

Image Analyst
Image Analyst el 16 de En. de 2022
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

Categorías

Más información sobre Particle Swarm en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by