This is my code. I get my x value correctly, and stops there. The if condition is not iterating and I'm not able to find the root or the number of iterations.
Can anybody please clear me about this?
function [x,i]=newton(R,f,Re,x0,maxiter,tol)
for i=1:maxiter
x=x0-(colebrook(R,f,Re)/colebrook_deriv(R,f,Re))
if (x-x0)<tol
break
disp(['root= ',num2str(x)])
end
fprintf('The number of iterations is: %d\n',i)
end
0 Comments
Sign in to comment.