フィルターのクリア

I get matlab error :Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.

1 回表示 (過去 30 日間)
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.

採用された回答

Torsten
Torsten 2017 年 7 月 27 日
1. Input vector for the objective function F is only x, not x and xdata.
2. I don't see that you define "xdata".
3. Since I suspect that "xdata" will be a vector, take care that F returns a scalar. As it stands, F returns a vector.
Best wishes
Torsten.
  1 件のコメント
praveen
praveen 2017 年 7 月 28 日
Thanks dude. The problem is solved . Actually 'xdata' is calculated prior to the creation of function handle and it is a scalar. :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Optimization Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by