Plotting eigenvalues in complex plane of a sparse matrix

53 次查看(过去 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

采纳的回答

Steven Lord
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 个评论
AtoZ
AtoZ 2018-10-29
编辑:AtoZ 2018-10-29
@Steven Thanks for your answer. I did believe that this could be the reason that I may need to recheck my matrix E. What I actually wanted to ask is that; is there a way one can plot all of the real vs few selected imag eigenvalues? for instances, the smallest 4, or the largest 4 (in absolute value). Lets say we zoom into the y-axis and set it to a smaller value so that the imaginary ones dont get squeezed into real axis, and then lets say we want to select to plot all of real vs 4 largest abs. imaginary eigenvalues? Is that possible.?
Steven Lord
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
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

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

产品


版本

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by