Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Not enough input arguments
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (2)
Walter Roberson
le 24 Jan 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.)
0 commentaires
KSSV
le 24 Jan 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)
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!