sort output of roots or residue so that the repeated roots occur together
조회 수: 3 (최근 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
댓글 수: 0
답변 (1개)
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
>>
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!