I can't seem to figure out why I am getting the error for the code
function [r,n]= Problem25b(f,x1,tol,N)if nargin<4 || isempty(N), N=20; end if nargin<3 || isempty(tol), tol=1e-6; end fp=matlabFunction(diff(f)); f2p=MatLabFunction(diff(f,2)); x=zeros(1,N+1); x(1)=x1; for n=1:N x(n+1)=x(n)-(f(x(n))*fp(x(n)))/(fp(x(n)))^(2)-f(x(n))*f2p(x(n)); if abs(x(n+1)-x(n))<tol r=x(n+1); return end end
when I run it I get the error:
[r,n]=Problem25b('x^(3)+2x^(2)+x+2',-3,1e-6,20)Undefined function 'matlabFunction' for input arguments of type 'double'.Error in Problem25b (line 5) fp=matlabFunction(diff(f));
Best Answer