Avoiding automatic sorting of eigenvalues
Mostrar comentarios más antiguos
I have been trying to find and plot the eigenvalues of a matrix with the following code:
hbar = 6.58211*10^-4;
wph = linspace(0.5/hbar, 1.5/hbar,10000);
w1 = 2000/hbar;
w2 = 2001/hbar;
g = 0;
pump = 50;
clear eigen
for i=numel(wph):-1:1
h= [0 0 pump 0 0;
0 0 0 pump 0;
pump 0 0 0 0;
0 pump 0 0 g;
0 0 0 g w2-w1-wph(i)];
eigen(:,i)=eig(h)*hbar;
end
figure;
plot(wph*hbar, eigen(2,:), '-','Linewidth',2);
hold on;
plot(wph*hbar, eigen(1,:), '--','Linewidth',2);
plot(wph*hbar, eigen(3,:), ':','Linewidth',2);
plot(wph*hbar, eigen(5,:),'Linewidth',2);
plot(wph*hbar, eigen(4,:), '--','Linewidth',2);
xlabel('\omega_{ph}(meV)');
ylabel('Energy (meV)');
grid on;
Symbolically, the eigenvalues obtained are:
pump
pump
-pump
-pump
w2 - w1 - wph
As the value of the variable wph varies, the value of the last eigenvalue changes and it becomes the greatest valued to the least.
Using the above mentioned code, the plot obtained was:

The plot is wrong. The eigenvalues are sorted in between and thus the above result is obtained. Is there any way to stop this?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Linear Algebra en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!