MATLAB: FEVAL error in implementing Newton’s method.

fevalnewton's method

This is M-File 1
function sol=newtonian(fn,dfn,x0,tol)
tol=0.000001;
old=x0+1;
while abs (x0 - old) > tol; old=x0;
x0=old - feval(fn, old)/feval(dfn, old);
end;
sol=x0;
end
M-File 2
function y=fn(x0,y)
x0=2;
y=(x0).^2-exp(x0)+2;
end
M-File 3
function dy=dfn(x0)
x0=-2;
dy=2*(x0)-exp(x0);
end
But I keep getting this ERROR:
??? Error using ==> feval
Argument must contain a string or function_handle.
Error in ==> newtonian at 5
x0=old - feval(fn, old)/feval(dfn, old);
What does this error mean?

Best Answer

Here's one awesome resource you should view, it helped me a lot last year.
Related Question