Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Not enough input arguments

조회 수: 1 (최근 30일)
Anonymous
Anonymous 2020년 1월 24일
마감: MATLAB Answer Bot 2021년 8월 20일
Could somebody please explain what this error is and how to fix it.
(Error in goldenmax721 (line 5) xmax_old=max(f(xl),f(xu));
Code:
function[xmax,fval]=goldenmax(f,ea,xl,xu)
phi=0.5*(1+sqrt(5));
tol=1;
iter=0;
xmax_old=max(f(xl),f(xu));
while tol>ea
iter=iter+1;
d=(phi-1)*(xu-xl);
x1=xl+d;
x2=xu-d;
if f(x1)>f(x2)
xl=x2;
x2=x1;
d=(phi-1)*(xu-xl);
x1=xl+d;
xmax=x1;
fval=f(x1);
else
xu=x1;
x1=x2;
d=(phi-1)*(xu-xl);
x2=xu-d;
xmax=x2;
fval=f(x2);
end
tol=abs((xmax-xmax_old))*100;
xmax_old=xmax;
end
end

답변 (2개)

Walter Roberson
Walter Roberson 2020년 1월 24일
You cannot run that code by simply pressing the green Run button to run it. You must go down to the command line and invoke the function passing in four arguments, the first of which is a function handle and the other three of which are numeric. (Or you could write a bit of code that made the call instead of doing it at the command line.)

KSSV
KSSV 2020년 1월 24일
YOu have to define/ give values of f,ea,xl,xu to the function. I think you are running the function directly.
f = your value ; % enter your value
ea = your value ;
xl = your value ;
xu = yourvalue ;
[xmax,fval]=goldenmax(f,ea,xl,xu)

Community Treasure Hunt

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

Start Hunting!

Translated by