MATLAB: Not enough inpout arguments in while loop

errorMATLABnot enough input argumentswhile loop

Hello, I have a code that i need to use for SQP optimization with the Newton step method. When I run it, it keeps telling me not enough inpout arguments in while loop.
function [x,grad,hessian,xk,lamda] = myNewton(f,g,H,h,dh,x0,tol,maxiter)
if nargin<6, maxiter=100; end
if nargin<5, tol=1e-10; end
k=0; x=x0(1:2,1); xk=x0(1:2,1);lamda=x0(3,1);
fprintf('Iter f(x)\n')
while (norm(feval(g,x))>tol && k<maxiter )
Why does it keep telling me that i don't have enough inpout arguments? Thank you!

Best Answer

if nargin<6, maxiter=100; end
if nargin<5, tol=1e-10; end
You have 8 possible arguments to that function, so the 6 should be 8 and the 5 should be 7.
Related Question