Not enough input arguments error when using fimincon
Mostrar comentarios más antiguos
I'm new to Matlab. I was trying to perform optimisation on "8w+7x+15y+12z=0" but I got this error.
Not enough input arguments.
Error in sec2_4>@(w,x,y,z)(8*w)+(7*x)+(15*y)+(12*z)
Error in fmincon (line 536)
initVals.f = feval(funfcn{3},X,varargin{:});
Error in sec2_4 (line 20)
fmincon(f,x0,A,b,Aeq,beq,lb,ub)
Caused by:
Failure in initial objective function evaluation. FMINCON
cannot continue.
The following is my code. I'm not sure is this because I got more than 2 parameters. Is it that I need to get a contour plot and assign better x0? But I don't think fcontour works for my equation.
f = @(w,x,y,z) (8*w)+(7*x)+(15*y)+(12*z);
Aeq = [1,1,1,1];
beq = [140];
lb = [0,0,0,0];
ub = [140,285,90,85];
A = [-1,-1,0,0;1,1,0,0];
b = [-80;40];
x0 = [140,285,90,85];
fmincon(f,x0,A,b,Aeq,beq,lb,ub)
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Problem-Based Optimization Setup en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!