Soring varying and compex eigenvalues
1 次查看(过去 30 天)
显示 更早的评论
I have a linearized system "VariableKp" with a parameter variation "Kp". As the parameter vary, the eigenvalues of the system change. The objective is to see how the eigenvalues change as the parameter sweep is performed, meaning that the rows of "E" or "Q" should contain information about the same eigenvalue, and its development. The order of eigenvalues collected from the "eig" function is however random.
How can I sort these eigenvalues?
Simply using the "sort" command based on real/imag/abs does not work as the eigenvalues change during the parameter sweep.
The problem is illustrated in for example row 7/8 VS 11/12 in the last column in E.
[A,B,C,d] = ssdata(VariableKp); %112 order system.
for k=1:1:5 %Five variations of Kp
Q(:,k)=eig(VariableKp(:,:,k,1));
end
for k=1:1:5
[~,I]=sort(imag(Q(:,k)));
E(:,k) = Q(I,k);
end
E =
1.0e+03 *
-1.0594 - 1.9406i -1.0594 - 1.9406i -1.0594 - 1.9406i -1.0594 - 1.9406i -1.0594 - 1.9406i
-1.0625 - 1.9385i -1.0625 - 1.9390i -1.0625 - 1.9390i -1.0625 - 1.9390i -1.0625 - 1.9390i
-0.0451 - 0.7707i -0.0451 - 0.7707i -0.0451 - 0.7707i -0.0451 - 0.7707i 0.2732 - 0.8849i
-0.0434 - 0.7697i -0.0434 - 0.7702i -0.0434 - 0.7702i -0.0434 - 0.7702i 0.2732 - 0.8849i
-0.0390 - 0.7565i -0.0390 - 0.7565i -0.0390 - 0.7565i -0.0390 - 0.7565i 0.2732 - 0.8849i
-0.0371 - 0.7555i -0.0371 - 0.7560i -0.0371 - 0.7560i -0.0371 - 0.7560i 0.2732 - 0.8849i
-1.8911 - 0.6294i -1.8911 - 0.6294i -1.8911 - 0.6294i -1.8911 - 0.6294i -0.0451 - 0.7707i % 7
-1.8959 - 0.6249i -1.8959 - 0.6254i -1.8959 - 0.6254i -1.8959 - 0.6254i -0.0434 - 0.7702i % 8
-0.0697 - 0.0545i -0.0697 - 0.0545i -0.0697 - 0.0545i 0.0024 - 0.1147i -0.0390 - 0.7565i
-0.0697 - 0.0545i -0.0697 - 0.0545i -0.0697 - 0.0545i 0.0024 - 0.1147i -0.0371 - 0.7560i
-0.0698 - 0.0544i -0.0698 - 0.0544i -0.0698 - 0.0544i 0.0024 - 0.1147i -1.8911 - 0.6294i % should be 7
-0.0698 - 0.0544i -0.0698 - 0.0544i -0.0698 - 0.0544i 0.0024 - 0.1147i -1.8959 - 0.6254i % should be 8
....................................
Q =
1.0e+03 *
-1.0625 + 1.9385i -1.0625 + 1.9390i -1.0625 + 1.9390i -1.0625 + 1.9390i -1.0625 + 1.9390i
-1.0625 - 1.9385i -1.0625 - 1.9390i -1.0625 - 1.9390i -1.0625 - 1.9390i -1.0625 - 1.9390i
-1.0594 + 1.9406i -1.0594 + 1.9406i -1.0594 + 1.9406i -1.0594 + 1.9406i -1.0594 + 1.9406i
-1.0594 - 1.9406i -1.0594 - 1.9406i -1.0594 - 1.9406i -1.0594 - 1.9406i -1.0594 - 1.9406i
-1.8959 + 0.6249i -1.8959 + 0.6254i -1.8959 + 0.6254i -1.8959 + 0.6254i -1.8959 + 0.6254i
-1.8959 - 0.6249i -1.8959 - 0.6254i -1.8959 - 0.6254i -1.8959 - 0.6254i -1.8959 - 0.6254i
-1.8911 + 0.6294i -1.8911 + 0.6294i -1.8911 + 0.6294i -1.8911 + 0.6294i -1.8911 + 0.6294i
-1.8911 - 0.6294i -1.8911 - 0.6294i -1.8911 - 0.6294i -1.8911 - 0.6294i -1.8911 - 0.6294i
-0.0434 + 0.7697i -0.0434 + 0.7702i -0.0434 + 0.7702i -0.0434 + 0.7702i -0.0434 + 0.7702i
-0.0434 - 0.7697i -0.0434 - 0.7702i -0.0434 - 0.7702i -0.0434 - 0.7702i -0.0434 - 0.7702i
-0.0371 + 0.7555i -0.0371 + 0.7560i -0.0371 + 0.7560i -0.0371 + 0.7560i -1.5546 + 0.0000i
-0.0371 - 0.7555i -0.0371 - 0.7560i -0.0371 - 0.7560i -0.0371 - 0.7560i -1.5546 + 0.0000i
................................
0 个评论
采纳的回答
Christine Tobler
2021-1-25
This can't be done one the level of individual EIG calls, since it's necessary to track eigenvalues from one call to the next. Take a look at the File Exchange package Eigenshuffle, which takes a set of matrices and orders the eigenvalues for each matrix so that the match the eigenvalues of the previous matrix as closely as possible. Note that I think this relies on one parameter being varied, if you are varying several parameters you may have to get more creative.
2 个评论
Christine Tobler
2021-1-26
I don't know much about the internal workings of eigenshuffle, so I'm not sure about this. You might add a comment in the FileExchange page for eigenshuffle.
Otherwise, if you're up for trying to write something on your own, you might have a look at the matchpairs function, which maps one set of points to another set of points, given a matrix M where M(i, j) contains the distance between point x(i) and point y(j). In your case, this would be M = abs(E(:, k-1) - E(:, k).').
For the second input costUnmatched for matchpairs, I would just choose a value that's about 10 times as large as the largest eigenvalue - that should force matchpairs to try to match each value up with another, no matter how far apart they are.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!