How can I determine which roots are closest to the unit circle?

1 次查看(过去 30 天)
Hi all!
I have a problem that I'm currently facing. Lets say I have a column vector (6x1) in which all elements provides me the roots of a polynomial.
For example,
root_out = 6×1 complex
-2.446362435057714 - 0.000000000000002i
-0.408770174717145 - 0.000000000000000i
0.862312857431274 - 0.529586047198464i
0.842065522070228 - 0.517151225883085i
0.862312857431279 + 0.529586047198471i
0.842065522070224 + 0.517151225883078i
Out of this list (Which may vary in size for its rows), how do I determine which root_out elements (could be more than 1) are closest to the unit circle efficiently? (Maybe in something like a search/range function?)

采纳的回答

Jan
Jan 2019-1-11
编辑:Jan 2019-1-11
x = [ -2.446362435057714 - 0.000000000000002i, ...
-0.408770174717145 - 0.000000000000000i, ...
0.862312857431274 - 0.529586047198464i, ...
0.842065522070228 - 0.517151225883085i, ...
0.862312857431279 + 0.529586047198471i, ...
0.842065522070224 + 0.517151225883078i, ...
0.842065522070228 - 0.517151225883085i]; % Repeated 4th line
r = abs(x);
d = abs(r - 1);
index = (d == min(d));
result = x(index)
Now result contains the value(s), which are nearest to the unit circle. I've repeated the 4th value to test the output of multiple minimal values.
  3 个评论
Jan
Jan 2019-1-13
编辑:Jan 2019-1-13
Find n=3 points with smallest distance to unit circle:
n = 3;
radius = abs(x);
dist = abs(r - 1);
[~, index] = sort(dist);
x(index(1:n))
With Matlab >= R2017b:
n = 3;
radius = abs(x);
dist = abs(r - 1);
[~, index] = mink(dist, n);
x(index)

请先登录,再进行评论。

更多回答(1 个)

Torsten
Torsten 2019-1-11
[~,ix] = min(abs(real(root_out).^2+imag(real_out).^2-1)./sqrt(real(root_out).^2+imag(real_out).^2));
root_out(ix)

Community Treasure Hunt

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

Start Hunting!

Translated by