Help me with this error ?

2 views (last 30 days)
Nguyen Trong Nhan
Nguyen Trong Nhan on 29 Jun 2014
Answered: Star Strider on 29 Jun 2014
I downloaded this file from file exchange (fixedpoint iteration method find approximate root of nonlinear equation). But I don't understand why it have this error(the success variable). Help me to fix it ? . thanks very much.

Answers (1)

Star Strider
Star Strider on 29 Jun 2014
There seems to be a logic problem in the fixedpoint function.
I don’t usually suggest altering others’ code, but it might be worthwhile to experiment by inserting between these lines:
P0 = p0;
% STEP 1
the line:
success = false;
so that it reads:
P0 = p0;
success = false;
% STEP 1
I cannot guarantee that it will find the real root of your function, since I haven’t run the fixedpoint function or your code with it.
When I used the core MATLAB function roots on your polynomial:
r = roots([1 2 0 -5])
it had one real negative root and two complex roots:
r =
-1.6209e+000 + 1.1826e+000i
-1.6209e+000 - 1.1826e+000i
1.2419e+000 + i

Products

Community Treasure Hunt

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

Start Hunting!