Help me with this error ?

2 次查看(过去 30 天)
Nguyen Trong Nhan
Nguyen Trong Nhan 2014-6-29
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.

回答(1 个)

Star Strider
Star Strider 2014-6-29
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

产品

Community Treasure Hunt

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

Start Hunting!

Translated by