How can put eigenvalues in ascending order?

1 次查看(过去 30 天)
Hi,
I am using something like [V,D] = eig(S) and I would like the eigenvalues in ascending order in the diagonal. V, D and S are 2x2 matrices.
Thanks.

回答(1 个)

Matt J
Matt J 2014-9-29
[~,idx]=sort(diag(D));
D=D(idx,idx);
  2 个评论
Anderson
Anderson 2014-9-29
Thank you for your reply.
I tried this but I got the eigenvalues not in the diagonal. Is it right?
Dt1 =
0 -0.5782
0.6702 0
Matt J
Matt J 2014-9-29
编辑:Matt J 2014-9-29
D(idx,idx) not D(idx,:)

请先登录,再进行评论。

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by