Order of roots obtained from function roots

10 ビュー (過去 30 日間)
Shan  Chu
Shan Chu 2018 年 6 月 14 日
コメント済み: Shan Chu 2018 年 6 月 14 日
Dear all,
I have a funny problem. I have a third-degree polynomial f(s1) which depends on a variable 'm'. When I vary 'm', at some points, the ROOTS function returns me a different order of roots. For example,
when m=217:
s1 =
2.241355481895662 - 1.756029299682315i
1.921143944919372 + 1.773701622048629i
0.215633777118811 - 0.917762110838706i
when m=218;
s1 =
1.918712404828970 + 1.767930620926665i
2.241124388076128 - 1.749637415502876i
0.222483229595857 - 0.896179899600968i
So, do you know how to solve that problem? Thanks Best

採用された回答

John D'Errico
John D'Errico 2018 年 6 月 14 日
Roots does not assure any specific order of the returned roots, nor should it rationally do so.
Feel free to sort them in any order you desire. However, you need to recognize there is no natural ordering of a set of complex numbers. Should they be sorted in terms of increasing real part? Imaginary part? Magnitude? Angle in the complex plane?
  1 件のコメント
Shan  Chu
Shan Chu 2018 年 6 月 14 日
Great suggestion!!! I use 'sort' and it works well. THanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by