Dear all, I am new to optimization toolbox and 'fmincon' function throws error message :'Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.' Please see the code below: Y is an array. F = @(x,xdata) x(1)*(exp(-x(2)*xdata))+x(3)*(exp(-x(4)*xdata)); pot_diff = abs(max(y) – min(y)); tau = 0.01*length(y); x0 = [0.02 20 0.04 10]; A = []; b = []; Aeq = []; beq = []; lb = []; ub = []; % lb = [0.1*pot_diff 0.3*tau 0.3*pot_diff 0.1*tau]; % ub = [0.6*pot_diff 0.8*tau 0.8*pot_diff 0.6*tau]; options = optimoptions(@fmincon,'Algorithm','interior-point','Display','off'); [x,fval,exitflag,output,lambda,grad,hessian] = fmincon(F,x0,A,b,Aeq,beq,lb,ub,@my_nlincon,options)

function [C,Ceq] = my_nlincon(x)

C(1) = x(3)-x(1); C(2) = x(2)-x(4); Ceq = []; return

The complete error message is : Error using @(x,xdata)x(1)*(exp(-x(2)*xdata))+x(3)*(exp(-x(4)*xdata)) Not enough input arguments. Error in fmincon (line 640) initVals.f = feval(funfcn{3},X,varargin{:}); Error in strt (line 113) [x,fval,exitflag,output,lambda,grad,hessian] = fmincon(F,x0,A,b,Aeq,beq,lb,ub,@my_nlincon,options) Caused by: Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.

Please help me solve this error. I also have doubt on using fmincon for a equation having 4 parameters.

## Best Answer