TranchesVIL takes a 1×4 input, fun3 takes a 1×3 input. par0 is 1×3.
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 1×115 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 1×3, then is it not the same 1×3 that is inserted into the nonlcon and hence there are sufficient input arguments?
Best Answer