When I take the integer root of a complex number, which root will MATLAB return?

1 次查看(过去 30 天)
When I take the integer root of a complex number, which root will MATLAB return?
There are "n" roots that are a solution to "r = z^(1/n)". How can I anticipate which root will be returned?

采纳的回答

MathWorks Support Team
MATLAB returns the root closest to the positive x-axis. This corresponds to the root with smallest absolute phase angle as returned by the ANGLE function.
When there are two roots symmetric about the x-axis (as is the case for a negative real number or a pure imaginary number), MATLAB returns the root with a positive imaginary part.
To obtain all "n" roots of the complex number "z", use the commands:
P = -1;P(n+1) = z;
r = roots(P)
or
k=1:n;
y = abs(z)^(1/n)*exp(i/n*(angle(z)+2*k*pi))
or
y2 = z^(1/n);
y2 = abs(y2)*exp(i*(angle(y2)+2*[1:n]*pi/n))
The results "y" and "y2" will be identical.
When "z" is a matrix of complex values, use the commands:
[z k] = meshgrid(z,1:n);
y = abs(z).^(1/n).*exp(i/n*(angle(z)+2*k*pi))
or
[z k] = meshgrid(z,1:n);
y2 = z.^(1/n);
y2 = abs(y2).*exp(i*(angle(y2)+2*k*pi/n))
Again, the results "y" and "y2" will be identical.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by