sort output of roots or residue so that the repeated roots occur together
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
KALYAN ACHARJYA
le 30 Août 2021
Modifié(e) : KALYAN ACHARJYA
le 30 Août 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
>>
0 commentaires
Voir également
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!