Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Not enough input arguments

1 visualización (últimos 30 días)
Anonymous
Anonymous el 24 de En. de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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

Respuestas (2)

Walter Roberson
Walter Roberson el 24 de En. de 2020
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 el 24 de En. de 2020
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)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by