This very simple function computes the n n-th roots of a given complex number. The attained complex roots can be plotted on a polar diagram.
It is more performante then
roots([1, zeros(1,n-1), -x]),
since it is based on very simple geometric properties of complex roots.
Marco Cococcioni (2020). Complex Roots Finder (https://www.mathworks.com/matlabcentral/fileexchange/10357-complex-roots-finder), MATLAB Central File Exchange. Retrieved .
really nice for eduactional purposes!
Simple but didactically very useful!
Fixed now, using angle.m for the phase angle. Error checking, good help. Its faster than the roots solution. If you want only the roots, then no plot is generated, but the plot can be of value for educational purposes.
This crashes when I run it, lacking the function phase.m. I searched the MathWorks site, but no phase.m is found. Regardless, there is already an existing matlab function that returns phase angle: angle.m.
Help for rootsc is good, with an example, but there is no error checking at all on the parameters.
Of course, if all you really wish to do is find the n n'th roots of x, the one-liner below will work very nicely:
roots([1, zeros(1,n-1), -x])
- function PHASE replaced with ANGLE