How to keep track of order eigenvalue in eig or eigs?

118 views (last 30 days)
I have a matrix equation defined at each point of variable k. The equation is where
and is a 6-by-6 matrix.
Once I solve my matrix and I plot the eigenvalues using eig (and eigs) results, I get the following:
But the correct results are 3 two-fold lines of the following form (here the x-axis is little shifted and in some other units, but essentially it is same as my x-axis).
I am trying to figure out what I am doing wrong. My solution looks someone close to the correct solution but that mess in between the lines is annoying.
May be the the order in which eig() (or eigs()) function return eigenvalues is my problem. I am have used both eig(M_k) and eigs(M_k) function. They both give almost identical results.

Accepted Answer

Ameer Hamza
Ameer Hamza on 13 Apr 2020
The order of eigenvalues and eigenvectors is an issue with the MATLAB's eig() function. John's submission on FEX provides a workaround: https://www.mathworks.com/matlabcentral/fileexchange/22885-eigenshuffle
  4 Comments
Kamilu Sanusi
Kamilu Sanusi on 1 May 2023
I would appreciate if you can help me with this problem. I have a system matrix A containing a damping variable D of which I want to see how it affects the position of eigenvalues on pzmap.
  1. Please how do I link the eigen values of the same value of D together by a line?
  2. How do i link only corresponding eigenvalue Lambda1 of different value oF D together, and the same thing applicable to other corresponding values of lampdas on the pz maz
  3. with arrow showing possible direction of motion of eigenvalue as a result of change in D
Ta1 = 24; Ta2 = 27; Ta3= 20;
H11 = -0.0641; H12 = 0.0359;
H21 = 0.1176; H22 = -0.2057;
H31 = 0.2077; H32 = 0.1961;
for D = [7 15 25 40 70 700]
A = [0 0 1 0 -1;0 0 0 1 -1;(-H11/Ta1) (-H12/Ta1) (-D/Ta1) 0 0;...
(-H21/Ta2) (-H22/Ta2) 0 (-D/Ta2) 0;(-H31/Ta3) (-H32/Ta3) 0 0 (-D/Ta3)];
Eig = eig(A);
a = Eig(1,1);
b = Eig(2,1);
c = Eig(3,1);
d = Eig(4,1);
e = Eig(5,1);
s = tf('s');
T = (1)/((s-a)*(s-b)*(s-c)*(s-d)*(s-e));
P = pole(T);
if D == 7
pzmap(T)
end
hold on
if D == 15
pzmap(T)
end
hold on
if D == 25
pzmap(T)
end
end
Kamilu Sanusi
Kamilu Sanusi on 1 May 2023
I would appreciate if you can help me with this problem. I have a system matrix A containing a damping variable D of which I want to see how it affects the position of eigenvalues on pzmap.
  1. Please how do I link the eigen values of the same value of D together by a line?
  2. How do i link only corresponding eigenvalue Lambda1 of different value oF D together, and the same thing applicable to other corresponding values of lampdas on the pz maz
  3. with arrow showing possible direction of motion of eigenvalue as a result of change in D
Ta1 = 24; Ta2 = 27; Ta3= 20;
H11 = -0.0641; H12 = 0.0359;
H21 = 0.1176; H22 = -0.2057;
H31 = 0.2077; H32 = 0.1961;
for D = [7 15 25 40 70 700]
A = [0 0 1 0 -1;0 0 0 1 -1;(-H11/Ta1) (-H12/Ta1) (-D/Ta1) 0 0;...
(-H21/Ta2) (-H22/Ta2) 0 (-D/Ta2) 0;(-H31/Ta3) (-H32/Ta3) 0 0 (-D/Ta3)];
Eig = eig(A);
a = Eig(1,1);
b = Eig(2,1);
c = Eig(3,1);
d = Eig(4,1);
e = Eig(5,1);
s = tf('s');
T = (1)/((s-a)*(s-b)*(s-c)*(s-d)*(s-e));
P = pole(T);
if D == 7
pzmap(T)
end
hold on
if D == 15
pzmap(T)
end
hold on
if D == 25
pzmap(T)
end
end

Sign in to comment.

More Answers (2)

Christine Tobler
Christine Tobler on 13 Apr 2020
The eigenvalues returned by EIG are not sorted in any particular order generally (for some special types of matrices (e.g. exactly symmetric), they might often be sorted in the same order, but we make no guarantees that this is always the case). For EIGS the eigenvalues are sorted in the order given by option sigma (e.g. 'largestabs', ...).
To sort the eigenvalues returned, just call sort after computing EIG:
d = eig(A);
d = sort(A);
or, for eigenvectors too,
[U, D] = eig(A);
[~, ind] = sort(diag(D));
D = D(ind, ind);
U = U(:, ind);
Since you are computing EIG of multiple matrices, if the lines describing each eigenvalue in your plot cross, this will not show continuous lines. It's not possible for each individual computation of eigenvalues to know about the connection to another, very similar, matrix A and its eigenvalues. In this case, the File Exchange package eigenshuffle that Ameer recommends may help you.

Hongwei Guo
Hongwei Guo on 17 Apr 2022
After a long time struggling, I think I found a better way to sort the eigen values to the original order. First, I've tried eigenshuffle function, it does not work well, at least for my case. BTW, I am solving a eigen value problem of a Hamiltonian. Matlab's ordering can not provide correct band structure.
Here's my method: eigen value perturbation method. For a matrix A having lambda1,...lambdaN as eigen values, A+E must have the eigen values of lambda1+eps1,..., lambdaN+epsN, where perturbation matrix E = diag([eps1,...,epsN]). If we control the value of eps_i to be different, we actually can add a different marker to the original eigen value, this marker can be simply ascending values or just random. Later we can sort the eigen values of by the perturbation eps_i. I'm not going to post code here, if you guys have questions, you can ask here. Thanks!
  5 Comments
Hongwei Guo
Hongwei Guo on 31 Jul 2022
Hello David, The above mentioned eigen value perturbation method is not applicable for all cases. For bandstructure problem, you might be using a real-space representation or a k-space representation, or in any other representations, but what we want to get is the relation between energy E and momentum p (in other words, k), so you need to get both the energy eigen value, and momentum eigen value, afer you get the eigen vectors i.e. wavefunctions of the original Hamiltonian, then plot E-k curve, that is the 'sorted' curve you wanted. But, if E doesn't commute with p, they enery operator and momentum operator doesn't share same eigen vectors, and may be E or p is not a good quantum number, you may not get a desired sorted bandstructure. I don't know if i made this comment clear, feel free to ask.
Hongwei Guo
Hongwei Guo on 31 Jul 2022
BTW, there is no such thing, called original order of eigen values.

Sign in to comment.

Categories

Find more on Linear Algebra in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!