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

4 visualizaciones (últimos 30 días)
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

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 30 de Ag. de 2021
Editada: KALYAN ACHARJYA el 30 de Ag. de 2021
>> 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
>>

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by