I first tried to replace the second for loop with
if true
% code
j=eye(100)
end
And adjusted my code to look like this
if true
% code
function X=jacobian(A,B,P,delta,max1)
N = length(B);
for k=1:max1
j=eye(100)
X(1:j)=(B(1:j)-A(1:j,[1:j-1,j+1:N])*P([1:j-1,j+1:N]))/A(1:j,1:j);
end
err=abs(norm(X'-P));
relerr=err/(norm(X)+eps);
P=X';
if (err<delta)||(relerr<delta)
RETURN
end
X=X';
end
end
And I am getting an answer but not sure if it is right. It is spitting out one answer in comparison to my previous code which would spit out a matrix