Soring varying and compex eigenvalues
显示 更早的评论
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 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
