Not enough inpout arguments in while loop

조회 수: 2 (최근 30일)
Maria Lepouri
Maria Lepouri 2018년 11월 1일
편집: Maria Lepouri 2018년 11월 1일
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!

채택된 답변

Walter Roberson
Walter Roberson 2018년 11월 1일
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.
  댓글 수: 1
Maria Lepouri
Maria Lepouri 2018년 11월 1일
Thank you! It worked i totally forgot to change that.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Elias Gule
Elias Gule 2018년 11월 1일
fprintf('%4u %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f\n',k,fn,x,lamda,norm(grad))
looks suspicious. fprintf appears to be expecting 7 inputs while only 5 are being supplied.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by