Empty output with newtons method
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!