There is something wrong with this program and I cannot seem to find it. I am trying to calculate the solution of a non-linear system using Newton's method. Matlab keeps saying there is a problem with sym in line 4.
function [s J] = newton(f,p0,tol,Iter)
% f is function, p0 is initial guess,
% tol is tolerance, Iter is max iterations
format long
x = sym('x');
y = sym('y');
F=f([x,y]);
J = Jacobian(F);
invJ = inv(J);
s =zeros(Iter,2);
s(1,:)=p0;
dsnorm = inf;
iter=1;
while dsnorm>tol && iter<Iter
ds=-subs(invJ,[x,y],s(iter,:))*f(s(iter,:));
s(iter+1,:)=s(iter,:)+ds';
dsnorm=norm(ds,inf);
iter=iter+1;
end
s=s(1:iter,:);
end