Plotting eigenvalues in complex plane of a sparse matrix
30 次查看(过去 30 天)
显示 更早的评论
I have a 198 x 198 matrix whose eigenvalues I want to plot in complex plane. However, what I want to achieve in plot seems to be 4 complex eigenvalues (having nonzero imaginary part) and a continuum of real eigenvalues. The desired plot looks like
What I have been able to achieve so far is through the following code
clear
k=49;n=2*k+1;p=2.5;v=5;T=1;b=(v*T^2*exp(2*i*p))/(1+T^2)^2;g=v/(1+T^2)^2;
format short
e = ones(n,1)*[1 -2*cos(p) 1];
A = spdiags(e,[-1 0 1],n,n);
A(k+1,k+1)=-2*cos(p)-g;
full(A);
e1 = ones(n,1)*[-1 2*cos(p) -1];
B = spdiags(e1,[-1 0 1],n,n);
B(k+1,k+1)=2*cos(p)+g;
full(B);
C=zeros(n,n);
C(k+1,k+1)=b;
D=zeros(n,n);
D(k+1,k+1)=-b;
E=[A,C;D,B];
full(E); % The full sparse matrix whose eigenvalues are to be plotted
d = eig(full(E))
plot(d,'o')
axis([-5 5 -.5 .5])
xlabel('Real')
ylabel('Imaginary')
Leading to the following output
0 个评论
采纳的回答
Steven Lord
2018-10-29
However, what I want to achieve in plot seems to be 4 complex eigenvalues (having nonzero imaginary part) and a continuum of real eigenvalues.
What makes you believe that the eigenvalues you're computing should have that specific distribution? Is there a particular property of your E matrix that suggests / requires it has exactly 4 complex eigenvalues and the rest real? When I compute both eigenvalues and eigenvectors and check that they satisfy the definition, the residuals are very small in absolute value so it seems like they're being computed correctly.
>> [V, d] = eig(full(E));
>> residuals = full(E)*V-V*d;
>> max(abs(residuals), [], 'all') % syntax introduced in R2018b
ans =
6.5221e-15
When I plot the results using the automatically determined limits, many of the eigenvalues do appear to be real. Those that don't seem to have very small imaginary parts (between -0.025 and 0.025) and setting the limits on your Y axis to the range [-0.5 0.5] squeezes them visually towards the imag(d) = 0 line.
plot(diag(d), 'o')
2 个评论
Steven Lord
2018-10-29
I'm not sure I understand what you're asking. Depending what you're trying to do I think using maxk with two outputs to identify the elements with the largest (and mink with two outputs the smallest) imaginary parts in your array and plotting just those elements along with those whose imaginary parts are small enough to be considered purely real would do what you want.
更多回答(1 个)
Vinay kumar singh
2020-9-18
>> [V, d] = eig(full(E));
>> residuals = full(E)*V-V*d;
>> max(abs(residuals), [], 'all') % syntax introduced in R2018b
ans =
6.5221e-15
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!