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
  1 件のコメント
AVM
AVM 2020 年 6 月 28 日
@Takumi: Thanks for your reply.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by