Problem in Eigen values plot

1 次查看(过去 30 天)
AVM
AVM 2020-6-25
评论: AVM 2020-6-28
I would like to plot the First five minimum eigenvalues in assending order w.r.t. ''g '' of the following Matrix using for loop. But am really confuse to sort the minimum eigevlaues. Can anybody help me to solve that?
clc;
syms g
omega=1.0;
D = 1.0;
n=15;
I1=eye(n);
I2=eye(2);
matdimension= n-1;
tempvector = 0:1:matdimension;
tempvector = sqrt(tempvector);
tempmatrix = diag(tempvector);
anni= circshift(tempmatrix,-1);
crea = anni';
sc=(crea)^2;
sanni=(anni)^2;
num=crea*anni;
c=crea+anni;
d=sc+sanni;
sigx=[0,1;1,0];
sigy=[0,-1i;1i,0];
sigz=[1,0; 0,-1];
sigp=(1/2)*(sigx+1i.*sigy);
sigm=(1/2)*(sigx -1i.*sigy);
g=0:0.01:2.0;
for i = 1:length(g)
A= omega.*kron(I2,num) + (D./2).* kron(sigz,I1) + g(i).*kron(sigx,c);
[~,v]=eig(A);
end
%plot(g,p1,'r',g,p2,'r',g,p3,'r',g,p4,'r',g,p5,'r')
%ax = gca;
%set(gca,'XMinorTick','on','YMinorTick','on')

采纳的回答

Takumi
Takumi 2020-6-26
Using sort function, you can sort the elements of matrix in ascending order.
clc;
close all
clear
syms g
omega=1.0;
D = 1.0;
n=15;
I1=eye(n);
I2=eye(2);
matdimension= n-1;
tempvector = 0:1:matdimension;
tempvector = sqrt(tempvector);
tempmatrix = diag(tempvector);
anni= circshift(tempmatrix,-1);
crea = anni';
sc=(crea)^2;
sanni=(anni)^2;
num=crea*anni;
c=crea+anni;
d=sc+sanni;
sigx=[0,1;1,0];
sigy=[0,-1i;1i,0];
sigz=[1,0; 0,-1];
sigp=(1/2)*(sigx+1i.*sigy);
sigm=(1/2)*(sigx -1i.*sigy);
g=0:0.01:2.0;
for i = 1:length(g)
A= omega.*kron(I2,num) + (D./2).* kron(sigz,I1) + g(i).*kron(sigx,c);
[~,v]=eig(A);
V=diag(v);
Vsort = sort(V);
Vsort(1) % minimum eigenvalue
Vsort(1:5) % First five minimum eigenvalues
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by