问题
I have vector with eigenvalues:
e =
-0.4094 + 3.9387i
-0.4094 - 3.9387i
-0.0156 + 0.5645i
-0.0156 - 0.5645i
And I would like to sort this vector like that:
e_sort =
-0.0156 + 0.5645i
-0.4094 + 3.9387i
-0.0156 - 0.5645i
-0.4094 - 3.9387i
The rule is: First must be:
-a+b*i
and then:
-a-b*i
We can say, that:
0 < b_1 < b_2 < ... < b_n
Thanks,
回答1:
e1 = e(imag(e) >= 0);
e2 = e(imag(e) < 0);
newe = cat(1,sort(e1),sort(e2))
newe =
-0.0156 + 0.5645i
-0.4094 + 3.9387i
-0.0156 - 0.5645i
-0.4094 - 3.9387i
来源:https://stackoverflow.com/questions/27090398/sort-complex-vectors-in-specific-order