Not enough input arguments error when using fimincon
이전 댓글 표시
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)
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!