sort output of roots or residue so that the repeated roots occur together

6 次查看(过去 30 天)
The output of the roots command come out in complex conjugate pairs.
e.g.
roots([1 8 38 88 121])
ans =
-2.0000 + 2.6458i
-2.0000 - 2.6458i
-2.0000 + 2.6458i
-2.0000 - 2.6458i
I want it to come out as:
-2.0000 + 2.6458i
-2.0000 + 2.6458i
-2.0000 - 2.6458i
-2.0000 - 2.6458i
so that I can algorithmically recognize repeated roots.
(The roots command used to do this. The current output is not an improvement>)
Please advise!
Dr. Vallorie Peridier, Temple University

回答(1 个)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021-8-30
编辑:KALYAN ACHARJYA 2021-8-30
>> data=roots([1 8 38 88 121])
data =
-2.0000 + 2.6458i
-2.0000 - 2.6458i
-2.0000 + 2.6458i
-2.0000 - 2.6458i
>> result=sort([real(data) imag(data)],'descend')*[1;1i]
result=
-2.0000 + 2.6458i
-2.0000 + 2.6458i
-2.0000 - 2.6458i
-2.0000 - 2.6458i
>>

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by