[EDIT: 20110512 17:03 EDT – reformat – WDR]
I keep getting the error Undefined function or method 'Newton' for input arguments of type 'inline'. I'm doing newtons method and I can't figure out what that error means and what part of my code is wrong.
function x = Newton(f, fp, x, nmax, error)x=1;e=2.71828;f(x)=inline('(x)*(5000)*(e^(-x)))-((100)+(0.73)*(5000)*(e^(-x))');fp(x)=inline('-5000*(e^(-x))*(x-1.73)');nmax = 10;error = 1.0e-15;x = Newton(f,fp,x,nmax,error)fprintf('x(0) = %10g \n', x)for n = 1:nmax d = f(x)/fp(x); x = x - d; fprintf('x(%i) = %10g \n', n, x) if abs(d) < error fprintf('Converged! \n') return end end end
Best Answer