Empty output with newtons method
Show older comments
Hi all
im new to matlab and im attempting to create a newtons method calculator. I keep getting an empty square bracket as an output. Can you kindly look into my code to see where the problem arises:
function approx = newton(f,nmax,tol,x0)
i = 1;
while (i<nmax)
x1 = x0 - f(x0)./diff(f(x0));
if (abs((x1 - x0)/x1) < tol)
break
end
i = i + 1;
x0 = x1;
disp(x1)
end
approx = x1;
end
Thank you
Accepted Answer
More Answers (0)
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!