You may be interested in the Matlab File Exchange entry called "Newton Raphson Solver with adaptive Step Size". It implements the Newton-Raphson method to extract the roots of a polynomial.
In particular, this function has a while
staement on line 147. Simply replace
while( err > ConvCrit && n < maxIter)
with
while( err > ConvCrit) %removing the maximum iteration criterion