Why does my nonlinear constraint return "not enough input arguments"?
显示 更早的评论
TranchesVIL takes a 1x4 input, fun3 takes a 1x3 input. par0 is 1x3.
fun3=@(X)sum(sum((TranchesVIL(phi,X0,sigma,[alpha,X],r,R,L(2:6),U(2:6),T,n,s)-CDO(2:6,:)).^2));
nonlcon2=@(X)nonlcon(sigma,X);
[X_j(k,:),SSE_CDO(k)]=fmincon(fun3,par0,[],[],[],[],lb_alpha(2:4),ub_alpha(2:4),@nonlcon,optionsT);
nonlcon is defined as follows:
function [c,ceq] = nonlcon(sigma,x)
ceq=0;
c=sigma+x(3)*(x(1)^2+x(2)^2)-0.7;
end
sigma is a 1x115 vector of variables.
The entire error I recieve is:
Not enough input arguments.
Error in nonlcon (line 3)
c=sigma+x(3)*(x(1)^2+x(2)^2)-0.7;
Error in fmincon (line 622)
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});
Error in main (line 68)
[X_j(k,:),SSE_CDO(k)]=fmincon(fun3,par0,[],[],[],[],lb_alpha(2:4),ub_alpha(2:4),@nonlcon,optionsT);
Caused by:
Failure in initial nonlinear constraint function evaluation. FMINCON cannot continue.
Why do I recieve this error? If the x inserted in the objective function is a 1x3, then is it not the same 1x3 that is inserted into the nonlcon and hence there are sufficient input arguments?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Nonlinear Optimization 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!